Merge branch 'stable-3.0' into stable-3.1

* stable-3.0:
  Upgrade jackson-core to 2.11.2
  Respect log.textLogging and log.jsonLogging using --console-log

Change-Id: Iebbf0dfc6d321f21270490ccc75058d1fcac63fe
This commit is contained in:
Thomas Draebing 2020-08-06 09:49:57 +02:00
commit 31e0cb7478
4 changed files with 24 additions and 14 deletions

View File

@ -49,8 +49,9 @@ per the local copy of link:config-gerrit.html[gerrit.config] located under
This option automatically implies '--enable-sshd'. This option automatically implies '--enable-sshd'.
--console-log:: --console-log::
Send log messages to the console, instead of to the standard Send log messages to the console. Log files will still be written to
log file '$site_path/logs/error_log'. the error log file, if log.textLogging and/or log.jsonLogging is set to
'true'.
--headless:: --headless::
Don't start the default Gerrit UI. May be useful when Gerrit is Don't start the default Gerrit UI. May be useful when Gerrit is

View File

@ -334,9 +334,7 @@ public class Daemon extends SiteProgram {
sysInjector.getInstance(PluginGuiceEnvironment.class).setDbCfgInjector(dbInjector, cfgInjector); sysInjector.getInstance(PluginGuiceEnvironment.class).setDbCfgInjector(dbInjector, cfgInjector);
manager.add(dbInjector, cfgInjector, sysInjector); manager.add(dbInjector, cfgInjector, sysInjector);
if (!consoleLog) { manager.add(ErrorLogFile.start(getSitePath(), config, consoleLog));
manager.add(ErrorLogFile.start(getSitePath(), config));
}
sshd &= !sshdOff(); sshd &= !sshdOff();
if (sshd) { if (sshd) {

View File

@ -49,11 +49,12 @@ public class ErrorLogFile {
root.addAppender(dst); root.addAppender(dst);
} }
public static LifecycleListener start(Path sitePath, Config config) throws IOException { public static LifecycleListener start(Path sitePath, Config config, boolean consoleLog)
throws IOException {
Path logdir = Path logdir =
FileUtil.mkdirsOrDie(new SitePaths(sitePath).logs_dir, "Cannot create log directory"); FileUtil.mkdirsOrDie(new SitePaths(sitePath).logs_dir, "Cannot create log directory");
if (SystemLog.shouldConfigure()) { if (SystemLog.shouldConfigure()) {
initLogSystem(logdir, config); initLogSystem(logdir, config, consoleLog);
} }
return new LifecycleListener() { return new LifecycleListener() {
@ -67,18 +68,28 @@ public class ErrorLogFile {
}; };
} }
private static void initLogSystem(Path logdir, Config config) { private static void initLogSystem(Path logdir, Config config, boolean consoleLog) {
Logger root = LogManager.getRootLogger(); Logger root = LogManager.getRootLogger();
root.removeAllAppenders(); root.removeAllAppenders();
PatternLayout errorLogLayout = new PatternLayout("[%d] [%t] %-5p %c %x: %m%n");
if (consoleLog) {
ConsoleAppender dst = new ConsoleAppender();
dst.setLayout(errorLogLayout);
dst.setTarget("System.err");
dst.setThreshold(Level.INFO);
dst.activateOptions();
root.addAppender(dst);
}
boolean json = config.getBoolean("log", "jsonLogging", false); boolean json = config.getBoolean("log", "jsonLogging", false);
boolean text = config.getBoolean("log", "textLogging", true) || !json; boolean text = config.getBoolean("log", "textLogging", true) || !(json || consoleLog);
boolean rotate = config.getBoolean("log", "rotate", true); boolean rotate = config.getBoolean("log", "rotate", true);
if (text) { if (text) {
root.addAppender( root.addAppender(SystemLog.createAppender(logdir, LOG_NAME, errorLogLayout, rotate));
SystemLog.createAppender(
logdir, LOG_NAME, new PatternLayout("[%d] [%t] %-5p %c %x: %m%n"), rotate));
} }
if (json) { if (json) {

View File

@ -108,8 +108,8 @@ def declare_nongoogle_deps():
maven_jar( maven_jar(
name = "jackson-core", name = "jackson-core",
artifact = "com.fasterxml.jackson.core:jackson-core:2.11.1", artifact = "com.fasterxml.jackson.core:jackson-core:2.11.2",
sha1 = "8b02908d53183fdf9758e7e20f2fdee87613a962", sha1 = "bc022ab0f0c83c07f9c52c5ab9a6a4932b15cc35",
) )
# Google internal dependencies: these are developed at Google, so there is # Google internal dependencies: these are developed at Google, so there is