mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
33 lines
733 B
JavaScript
33 lines
733 B
JavaScript
/**
|
|
* run this, then "ab -c 10 -n 100 localhost:4444/" to test (in
|
|
* another shell)
|
|
*/
|
|
const log4js = require('../lib/log4js');
|
|
|
|
log4js.configure({
|
|
appenders: {
|
|
cheese: { type: 'file', filename: 'cheese.log' },
|
|
},
|
|
categories: {
|
|
default: { appenders: ['cheese'], level: 'debug' },
|
|
},
|
|
});
|
|
|
|
const logger = log4js.getLogger('cheese');
|
|
const http = require('http');
|
|
|
|
http
|
|
.createServer((request, response) => {
|
|
response.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
const rd = Math.random() * 50;
|
|
logger.info(`hello ${rd}`);
|
|
response.write('hello ');
|
|
if (Math.floor(rd) === 30) {
|
|
log4js.shutdown(() => {
|
|
process.exit(1);
|
|
});
|
|
}
|
|
response.end();
|
|
})
|
|
.listen(4444);
|