diff --git a/CHANGELOG.md b/CHANGELOG.md index 86f3a4ca5..14114580a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/settings.json.docker b/settings.json.docker index 40872339d..ed1be901d 100644 --- a/settings.json.docker +++ b/settings.json.docker @@ -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": "bar@blurdybloop.com, baz@blurdybloop.com" - , "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": "foo@example.com", - "pass": "bar_foo" - } - } - } - } - */ - - ] - }, // logconfig - /* Override any strings found in locale directories */ "customLocaleStrings": {} } diff --git a/settings.json.template b/settings.json.template index 2d7f119a2..8b8766be8 100644 --- a/settings.json.template +++ b/settings.json.template @@ -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": "bar@blurdybloop.com, baz@blurdybloop.com" - , "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": "foo@example.com", - "pass": "bar_foo" - } - } - } - } - */ - - ] - }, // logconfig - /* Override any strings found in locale directories */ "customLocaleStrings": {}, diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index 78235de0e..1a8bb000e 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -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'); @@ -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 diff --git a/src/package.json b/src/package.json index 8e1f17414..8e441058a 100644 --- a/src/package.json +++ b/src/package.json @@ -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",