UNPKG

log4js

Version:
70 lines (46 loc) 4.18 kB
<!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="chrome=1"> <title>log4js-node by nomiddlename</title> <link rel="stylesheet" href="/assets/css/style.css?v=a7f232b4c6654881e6a8bd2ac48ee149603d74de"> <meta name="viewport" content="width=device-width"> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <div class="wrapper"> <header> <h1>log4js-node</h1> <p>A port of log4js to node.js</p> <p class="view"><a href="http://github.com/nomiddlename/log4js-node">View the Project on GitHub <small></small></a></p> <ul> <li><a href="index.html">Home</a></li> <li><a href="api.html">API</a></li> <li><a href="appenders.html">Appenders</a></li> <li><a href="layouts.html">Layouts</a></li> <li><a href="terms.html">Terminology</a></li> <li><a href="faq.html">FAQ</a></li> <li><a href="contrib-guidelines.html">Want to help?</a></li> <li><a href="contributors.html">Contributors</a></li> </ul> </header> <section> <h2 id="terminology">Terminology</h2> <p><code class="highlighter-rouge">Level</code> - a log level is the severity or priority of a log event (debug, info, etc). Whether an <em>appender</em> will see the event or not is determined by the <em>category</em>’s level. If this is less than or equal to the event’s level, it will be sent to the category’s appender(s).</p> <p><code class="highlighter-rouge">Category</code> - a label for grouping log events. This can be based on module (e.g. ‘auth’, ‘payment’, ‘http’), or anything you like. Log events with the same <em>category</em> will go to the same <em>appenders</em>. Log4js supports a simple hierarchy for categories, using dots to separate layers - for example, log events in the category ‘myapp.submodule’ will use the appenders defined for ‘myapp’ if none are defined for ‘myapp.submodule’. The category for log events is defined when you get a <em>Logger</em> from log4js (<code class="highlighter-rouge">log4js.getLogger('somecategory')</code>).</p> <p><code class="highlighter-rouge">Appender</code> - appenders are responsible for output of log events. They may write events to files, send emails, store them in a database, or anything. Most appenders use <em>layouts</em> to serialise the events to strings for output.</p> <p><code class="highlighter-rouge">Logger</code> - this is your code’s main interface with log4js. A logger instance may have an optional <em>category</em>, defined when you create the instance. Loggers provide the <code class="highlighter-rouge">info</code>, <code class="highlighter-rouge">debug</code>, <code class="highlighter-rouge">error</code>, etc functions that create <em>LogEvents</em> and pass them on to appenders.</p> <p><code class="highlighter-rouge">Layout</code> - a function for converting a <em>LogEvent</em> into a string representation. Log4js comes with a few different implementations: basic, coloured, and a more configurable pattern based layout.</p> <p><code class="highlighter-rouge">LogEvent</code> - a log event has a timestamp, a level, and optional category, data, and context properties. When you call <code class="highlighter-rouge">logger.info('cheese value:', edam)</code> the <em>logger</em> will create a log event with the timestamp of now, a <em>level</em> of INFO, a <em>category</em> that was chosen when the logger was created, and a data array with two values (the string ‘cheese value:’, and the object ‘edam’), along with any context data that was added to the logger.</p> </section> <footer> <p>This project is maintained by <a href="http://github.com/nomiddlename">nomiddlename</a></p> <p><small>Hosted on GitHub Pages &mdash; Theme by <a href="https://github.com/orderedlist">orderedlist</a></small></p> </footer> </div> <script src="/assets/js/scale.fix.js"></script> </body> </html>