Sha256: d72dfc616f2d70988c0d5f8cae5bfa19fd3d7d5d6df923db51c9489d6378a0e2

Contents?: true

Size: 1.29 KB

Versions: 17

Compression:

Stored size: 1.29 KB

Contents

//The connect/express logger was added to log4js by danbell. This allows connect/express servers to log using log4js.
//https://github.com/nomiddlename/log4js-node/wiki/Connect-Logger

// load modules
var log4js = require('log4js');
var express = require("express");
var app = express();

//config
log4js.configure({
	appenders: [
		{ type: 'console' },
		{ type: 'file', filename: 'logs/log4jsconnect.log', category: 'log4jslog' }
	]
});

//define logger
var logger = log4js.getLogger('log4jslog');

// set at which time msg is logged print like: only on error & above
// logger.setLevel('ERROR');

//express app
app.configure(function() {
	app.use(express.favicon(''));
	// app.use(log4js.connectLogger(logger, { level: log4js.levels.INFO }));
	// app.use(log4js.connectLogger(logger, { level: 'auto', format: ':method :url :status' }));

	//### AUTO LEVEL DETECTION
	//http responses 3xx, level = WARN
	//http responses 4xx & 5xx, level = ERROR
	//else.level = INFO
	app.use(log4js.connectLogger(logger, { level: 'auto' }));
});

//route
app.get('/', function(req,res) {
	res.send('hello world');
});

//start app
app.listen(5000);

console.log('server runing at localhost:5000');
console.log('Simulation of normal response: goto localhost:5000');
console.log('Simulation of error response: goto localhost:5000/xxx');

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
hooch-0.2.1 jasmine/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
hooch-0.2.0 jasmine/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
hooch-0.1.0 jasmine/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
hooch-0.0.8 jasmine/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
hooch-0.0.7 jasmine/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
hooch-0.0.6 jasmine/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/log4js/examples/example-connect-logger.js