Skip to content

Commit

Permalink
log4js: Deprecate the logconfig setting
Browse files Browse the repository at this point in the history
This will make it possible to upgrade log4js in a future version.
  • Loading branch information
rhansen committed Sep 28, 2021
1 parent b3b6c94 commit aec619c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 104 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

### Compatibility changes

* The `logconfig` setting is deprecated.
* For plugin authors:
* Etherpad now uses [jsdom](https://github.com/jsdom/jsdom) instead of
[cheerio](https://cheerio.js.org/) for processing HTML imports. There are
Expand Down
52 changes: 0 additions & 52 deletions settings.json.docker
Original file line number Diff line number Diff line change
Expand Up @@ -586,58 +586,6 @@
*/
"loglevel": "${LOGLEVEL:INFO}",

/*
* Logging configuration. See log4js documentation for further information:
* https://github.com/nomiddlename/log4js-node
*
* You can add as many appenders as you want here.
*/
"logconfig" :
{ "appenders": [
{ "type": "console"
//, "category": "access"// only logs pad access
}

/*
, { "type": "file"
, "filename": "your-log-file-here.log"
, "maxLogSize": 1024
, "backups": 3 // how many log files there're gonna be at max
//, "category": "test" // only log a specific category
}
*/

/*
, { "type": "logLevelFilter"
, "level": "warn" // filters out all log messages that have a lower level than "error"
, "appender":
{ Use whatever appender you want here }
}
*/

/*
, { "type": "logLevelFilter"
, "level": "error" // filters out all log messages that have a lower level than "error"
, "appender":
{ "type": "smtp"
, "subject": "An error occurred in your EPL instance!"
, "recipients": "[email protected], [email protected]"
, "sendInterval": 300 // 60 * 5 = 5 minutes -- will buffer log messages; set to 0 to send a mail for every message
, "transport": "SMTP", "SMTP": { // see https://github.com/andris9/Nodemailer#possible-transport-methods
"host": "smtp.example.com", "port": 465,
"secureConnection": true,
"auth": {
"user": "[email protected]",
"pass": "bar_foo"
}
}
}
}
*/

]
}, // logconfig

/* Override any strings found in locale directories */
"customLocaleStrings": {}
}
52 changes: 0 additions & 52 deletions settings.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -590,58 +590,6 @@
*/
"loglevel": "INFO",

/*
* Logging configuration. See log4js documentation for further information:
* https://github.com/nomiddlename/log4js-node
*
* You can add as many appenders as you want here.
*/
"logconfig" :
{ "appenders": [
{ "type": "console"
//, "category": "access"// only logs pad access
}

/*
, { "type": "file"
, "filename": "your-log-file-here.log"
, "maxLogSize": 1024
, "backups": 3 // how many log files there're gonna be at max
//, "category": "test" // only log a specific category
}
*/

/*
, { "type": "logLevelFilter"
, "level": "warn" // filters out all log messages that have a lower level than "error"
, "appender":
{ Use whatever appender you want here }
}
*/

/*
, { "type": "logLevelFilter"
, "level": "error" // filters out all log messages that have a lower level than "error"
, "appender":
{ "type": "smtp"
, "subject": "An error occurred in your EPL instance!"
, "recipients": "[email protected], [email protected]"
, "sendInterval": 300 // 60 * 5 = 5 minutes -- will buffer log messages; set to 0 to send a mail for every message
, "transport": "SMTP", "SMTP": { // see https://github.com/andris9/Nodemailer#possible-transport-methods
"host": "smtp.example.com", "port": 465,
"secureConnection": true,
"auth": {
"user": "[email protected]",
"pass": "bar_foo"
}
}
}
}
*/

]
}, // logconfig

/* Override any strings found in locale directories */
"customLocaleStrings": {},

Expand Down
5 changes: 5 additions & 0 deletions src/node/utils/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*/

const absolutePaths = require('./AbsolutePaths');
const deepEqual = require('fast-deep-equal/es6');
const fs = require('fs');
const os = require('os');
const path = require('path');
Expand All @@ -47,9 +48,13 @@ const defaultLogConfig = () => ({appenders: [{type: 'console'}]});
const defaultLogLevel = 'INFO';

const initLogging = (logLevel, config) => {
// log4js.configure() modifies exports.logconfig so check for equality first.
const logConfigIsDefault = deepEqual(config, defaultLogConfig());
log4js.configure(config);
log4js.setGlobalLogLevel(logLevel);
log4js.replaceConsole();
// Log the warning after configuring log4js to increase the chances the user will see it.
if (!logConfigIsDefault) logger.warn('The logconfig setting is deprecated.');
};

// Initialize logging as early as possible with reasonable defaults. Logging will be re-initialized
Expand Down
1 change: 1 addition & 0 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"express": "4.17.1",
"express-rate-limit": "5.3.0",
"express-session": "1.17.2",
"fast-deep-equal": "^3.1.3",
"find-root": "1.1.0",
"formidable": "1.2.2",
"http-errors": "1.8.0",
Expand Down

0 comments on commit aec619c

Please sign in to comment.