Permalink
Browse files

added fromreadme.js example, updated README

  • Loading branch information...
1 parent 68b47dd commit 1aed671137e738b44052a5743474eaac671d3587 Gareth Jones committed Jun 28, 2012
Showing with 19 additions and 3 deletions.
  1. +4 −3 README.md
  2. +15 −0 fromreadme.js
View
@@ -35,12 +35,13 @@ By default, log4js outputs to stdout with the coloured layout (thanks to [masylu
[2010-01-17 11:43:37.987] [DEBUG] [default] - Some debug messages
-See example.js:
+See example.js for a full example, but here's a snippet (also in fromreadme.js):
var log4js = require('log4js');
- log4js.loadAppender('console');
+ //console log is loaded by default, so you won't normally need to do this
+ //log4js.loadAppender('console');
log4js.loadAppender('file');
- log4js.addAppender(log4js.appenders.console());
+ //log4js.addAppender(log4js.appenders.console());
log4js.addAppender(log4js.appenders.file('logs/cheese.log'), 'cheese');
var logger = log4js.getLogger('cheese');
View
@@ -0,0 +1,15 @@
+var log4js = require('./lib/log4js');
+//log4js.loadAppender('console');
+log4js.loadAppender('file');
+//log4js.addAppender(log4js.appenders.console());
+log4js.addAppender(log4js.appenders.file('cheese.log'), 'cheese');
+
+var logger = log4js.getLogger('cheese');
+logger.setLevel('ERROR');
+
+logger.trace('Entering cheese testing');
+logger.debug('Got cheese.');
+logger.info('Cheese is Gouda.');
+logger.warn('Cheese is quite smelly.');
+logger.error('Cheese is too ripe!');
+logger.fatal('Cheese was breeding ground for listeria.');

0 comments on commit 1aed671

Please sign in to comment.