1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

Reduce logging in production.

This commit is contained in:
Jari Bakken 2015-03-10 16:30:56 +01:00 committed by Ivar Conradi Østhus
parent 0552e588ae
commit 8b9c0a6e85
2 changed files with 15 additions and 2 deletions

6
app.js
View File

@ -33,7 +33,11 @@ app.use(validator([]));
app.set('trust proxy');
app.locals.baseUriPath = baseUriPath;
app.use(log4js.connectLogger(logger, {format: ':remote-addr :status :method :url :response-timems'}));
app.use(log4js.connectLogger(logger, {
format: ':remote-addr :status :method :url :response-timems',
level: 'auto' // 3XX=WARN, 4xx/5xx=ERROR
}));
app.set('port', process.env.HTTP_PORT || process.env.PORT || 4242);
app.use(baseUriPath, express.static(__dirname + '/public'));

View File

@ -3,4 +3,13 @@ var log4js = require('log4js');
log4js.clearAppenders();
log4js.addAppender(log4js.appenders.console());
module.exports = log4js.getLogger('unleash');
var logger = log4js.getLogger('unleash');
// TODO: make level configurable
if (process.env.NODE_ENV === 'production') {
logger.setLevel(log4js.levels.ERROR);
} else {
logger.setLevel(log4js.levels.DEBUG);
}
module.exports = logger;