Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9f77734

Browse files
author
Gareth Jones
committed
test case for flush on exit
1 parent ce8b6b0 commit 9f77734

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

examples/flush-on-exit.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* run this, then "ab -c 10 -n 100 localhost:4444/" to test (in
3+
* another shell)
4+
*/
5+
var log4js = require('../lib/log4js');
6+
log4js.configure({
7+
appenders: [
8+
{ type: 'file', filename: 'cheese.log', category: 'cheese' },
9+
{ type: 'console'}
10+
]
11+
});
12+
13+
var logger = log4js.getLogger('cheese');
14+
logger.setLevel('INFO');
15+
16+
var http=require('http');
17+
18+
var server = http.createServer(function(request, response){
19+
response.writeHead(200, {'Content-Type': 'text/plain'});
20+
var rd = Math.random() * 50;
21+
logger.info("hello " + rd);
22+
response.write('hello ');
23+
if (Math.floor(rd) == 30){
24+
log4js.shutdown(function() { process.exit(1); });
25+
}
26+
response.end();
27+
}).listen(4444);

0 commit comments

Comments
 (0)