mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
Option to disable request logging.
Because all request details are available via prometheus there is no need to also log all requests. This solves #164 but we should still replace log4j with something else.
This commit is contained in:
parent
fd05d63444
commit
d4d63af2b0
11
lib/app.js
11
lib/app.js
@ -41,10 +41,13 @@ module.exports = function (config) {
|
||||
}
|
||||
|
||||
app.use(bodyParser.json({ strict: false }));
|
||||
app.use(log4js.connectLogger(logger, {
|
||||
format: ':status :method :url :response-timems',
|
||||
level: 'auto', // 3XX=WARN, 4xx/5xx=ERROR
|
||||
}));
|
||||
|
||||
if(config.enableRequestLogger) {
|
||||
app.use(log4js.connectLogger(logger, {
|
||||
format: ':status :method :url :response-timems',
|
||||
level: 'auto', // 3XX=WARN, 4xx/5xx=ERROR
|
||||
}));
|
||||
}
|
||||
|
||||
// Setup API routes
|
||||
const apiRouter = express.Router(); // eslint-disable-line new-cap
|
||||
|
@ -1,12 +1,15 @@
|
||||
'use strict';
|
||||
const { publicFolder } = require('unleash-frontend');
|
||||
|
||||
const isDev = () => process.env.NODE_ENV === 'development';
|
||||
|
||||
const DEFAULT_OPTIONS = {
|
||||
databaseUrl: process.env.DATABASE_URL,
|
||||
port: process.env.HTTP_PORT || process.env.PORT || 4242,
|
||||
baseUriPath: process.env.BASE_URI_PATH || '',
|
||||
serverMetrics: true,
|
||||
publicFolder,
|
||||
enableRequestLogger: isDev() ? true : false
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
@ -14,7 +17,7 @@ module.exports = {
|
||||
const options = Object.assign({}, DEFAULT_OPTIONS, opts);
|
||||
|
||||
// If we are running in development we should assume local db
|
||||
if(process.env.NODE_ENV === 'development' && !options.databaseUrl) {
|
||||
if(isDev() && !options.databaseUrl) {
|
||||
options.databaseUrl = 'postgres://unleash_user:passord@localhost:5432/unleash';
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ function createApp (options) {
|
||||
const config = {
|
||||
baseUriPath: options.baseUriPath,
|
||||
serverMetrics: options.serverMetrics,
|
||||
enableRequestLogger: options.enableRequestLogger,
|
||||
port: options.port,
|
||||
publicFolder: options.publicFolder,
|
||||
stores,
|
||||
|
Loading…
Reference in New Issue
Block a user