1 //The connect/express logger was added to log4js by danbell. This allows connect/express servers to log using log4js.
2 //https://github.com/nomiddlename/log4js-node/wiki/Connect-Logger
5 var log4js = require('log4js');
6 var express = require("express");
13 { type: 'file', filename: 'logs/log4jsconnect.log', category: 'log4jslog' }
18 var logger = log4js.getLogger('log4jslog');
20 // set at which time msg is logged print like: only on error & above
21 // logger.setLevel('ERROR');
24 app.configure(function() {
25 app.use(express.favicon(''));
26 // app.use(log4js.connectLogger(logger, { level: log4js.levels.INFO }));
27 // app.use(log4js.connectLogger(logger, { level: 'auto', format: ':method :url :status' }));
29 //### AUTO LEVEL DETECTION
30 //http responses 3xx, level = WARN
31 //http responses 4xx & 5xx, level = ERROR
33 app.use(log4js.connectLogger(logger, { level: 'auto' }));
37 app.get('/', function(req,res) {
38 res.send('hello world');
44 console.log('server runing at localhost:5000');
45 console.log('Simulation of normal response: goto localhost:5000');
46 console.log('Simulation of error response: goto localhost:5000/xxx');