From f9566ed30f1e800d1c7638b3fe8fbafb294a7d6f Mon Sep 17 00:00:00 2001 From: David Liu Date: Tue, 28 Oct 2014 13:27:26 +0800 Subject: [PATCH] spring-boot-1612: make console and file output configurable 1 disable the file output unless LOG_FILE is set 2 make the console optional fixes: gh-1612 --- .../boot/logging/AbstractLoggingSystem.java | 10 ++++-- .../logging/LoggingApplicationListener.java | 13 +++++-- .../boot/logging/LoggingSystem.java | 6 ++-- .../boot/logging/Slf4JLoggingSystem.java | 4 +-- .../boot/logging/java/JavaLoggingSystem.java | 24 +++++++++++-- .../logging/log4j/Log4JLoggingSystem.java | 20 +++++++++-- .../logging/logback/LogbackLoggingSystem.java | 24 +++++++++++-- .../logging/java/logging-console.properties | 13 +++++++ .../java/logging-file-console.properties | 20 +++++++++++ .../boot/logging/java/logging-file.properties | 17 +++++++++ .../boot/logging/java/logging.properties | 12 +------ .../logging/log4j/log4j-console.properties | 20 +++++++++++ .../log4j/log4j-file-console.properties | 25 +++++++++++++ .../boot/logging/log4j/log4j-file.properties | 20 +++++++++++ .../boot/logging/log4j/log4j.properties | 12 +------ .../boot/logging/log4j2/basic-log4j2.xml | 25 ------------- .../boot/logging/log4j2/log4j2.xml | 36 ------------------- .../boot/logging/logback/base.xml | 19 ---------- .../boot/logging/logback/basic-console.xml | 18 ++++++++++ .../boot/logging/logback/basic-file.xml | 23 ++++++++++++ .../boot/logging/logback/basic.xml | 16 +-------- .../boot/logging/logback/logback-console.xml | 5 +++ .../logging/logback/logback-file-console.xml | 6 ++++ .../boot/logging/logback/logback-file.xml | 5 +++ .../boot/logging/logback/logback.xml | 16 +-------- 25 files changed, 258 insertions(+), 151 deletions(-) create mode 100644 spring-boot/src/main/resources/org/springframework/boot/logging/java/logging-console.properties create mode 100644 spring-boot/src/main/resources/org/springframework/boot/logging/java/logging-file-console.properties create mode 100644 spring-boot/src/main/resources/org/springframework/boot/logging/java/logging-file.properties create mode 100644 spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-console.properties create mode 100644 spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-file-console.properties create mode 100644 spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-file.properties delete mode 100644 spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/basic-log4j2.xml delete mode 100644 spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2.xml create mode 100644 spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic-console.xml create mode 100644 spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic-file.xml create mode 100644 spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback-console.xml create mode 100644 spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback-file-console.xml create mode 100644 spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback-file.xml diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java index 28d57dfbb09..abf721cd97b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java @@ -31,10 +31,12 @@ public abstract class AbstractLoggingSystem extends LoggingSystem { private final String[] paths; - public AbstractLoggingSystem(ClassLoader classLoader, String... paths) { + public AbstractLoggingSystem(ClassLoader classLoader, boolean fileOutput, boolean consoleOutput) { this.classLoader = classLoader; - this.paths = paths.clone(); + this.paths = getLogFileName(fileOutput, consoleOutput); } + + protected abstract String[] getLogFileName(boolean fileOutput, boolean consoleOutput); protected final ClassLoader getClassLoader() { return this.classLoader; @@ -59,7 +61,9 @@ public abstract class AbstractLoggingSystem extends LoggingSystem { } protected void initializeWithSensibleDefaults() { - initialize(getPackagedConfigFile("basic-" + this.paths[this.paths.length - 1])); + String path = this.paths[this.paths.length - 1]; + path = path.replaceAll("-console", "").replaceAll("-file", ""); + initialize(getPackagedConfigFile("basic-" + path)); } protected final String getPackagedConfigFile(String fileName) { diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java index 12daee9553c..ef8671ddde4 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java @@ -74,6 +74,8 @@ public class LoggingApplicationListener implements SmartApplicationListener { private static final Map ENVIRONMENT_SYSTEM_PROPERTY_MAPPING; public static final String PID_KEY = "PID"; + + public static final String LOG_FILE = "LOG_FILE"; static { ENVIRONMENT_SYSTEM_PROPERTY_MAPPING = new HashMap(); @@ -131,8 +133,7 @@ public class LoggingApplicationListener implements SmartApplicationListener { if (System.getProperty(PID_KEY) == null) { System.setProperty(PID_KEY, new ApplicationPid().toString()); } - LoggingSystem loggingSystem = LoggingSystem.get(ClassUtils - .getDefaultClassLoader()); + LoggingSystem loggingSystem = LoggingSystem.get(ClassUtils.getDefaultClassLoader(), false, false); loggingSystem.beforeInitialize(); } } @@ -144,7 +145,13 @@ public class LoggingApplicationListener implements SmartApplicationListener { protected void initialize(ConfigurableEnvironment environment, ClassLoader classLoader) { initializeEarlyLoggingLevel(environment); cleanLogTempProperty(); - LoggingSystem system = LoggingSystem.get(classLoader); + boolean fileOutput = !StringUtils.isEmpty(environment.getProperty("logging.file")); + boolean consoleOutput = true; + if (!StringUtils.isEmpty(environment.getProperty("logging.console")) + && environment.getProperty("logging.console").equalsIgnoreCase("false")) { + consoleOutput = false; + } + LoggingSystem system = LoggingSystem.get(classLoader, fileOutput, consoleOutput); boolean systemEnvironmentChanged = mapSystemPropertiesFromSpring(environment); if (systemEnvironmentChanged) { // Re-initialize the defaults in case the system Environment changed diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java index 9109aecde61..168b0460d5c 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java @@ -74,14 +74,14 @@ public abstract class LoggingSystem { * Detect and return the logging system in use. * @return The logging system */ - public static LoggingSystem get(ClassLoader classLoader) { + public static LoggingSystem get(ClassLoader classLoader, boolean fileOutput, boolean consoleOutput) { for (Map.Entry entry : SYSTEMS.entrySet()) { if (ClassUtils.isPresent(entry.getKey(), classLoader)) { try { Class systemClass = ClassUtils.forName(entry.getValue(), classLoader); - return (LoggingSystem) systemClass.getConstructor(ClassLoader.class) - .newInstance(classLoader); + return (LoggingSystem) systemClass.getConstructor(ClassLoader.class, boolean.class, boolean.class) + .newInstance(classLoader, fileOutput, consoleOutput); } catch (Exception ex) { throw new IllegalStateException(ex); diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/Slf4JLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/Slf4JLoggingSystem.java index 07ef2746a1d..254b94b2094 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/Slf4JLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/Slf4JLoggingSystem.java @@ -27,8 +27,8 @@ import org.springframework.util.ClassUtils; */ public abstract class Slf4JLoggingSystem extends AbstractLoggingSystem { - public Slf4JLoggingSystem(ClassLoader classLoader, String... paths) { - super(classLoader, paths); + public Slf4JLoggingSystem(ClassLoader classLoader, boolean fileOutput, boolean consoleOutput) { + super(classLoader, fileOutput, consoleOutput); } @Override diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/java/JavaLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/java/JavaLoggingSystem.java index b55c6fbc650..a43ed55f8a1 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/java/JavaLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/java/JavaLoggingSystem.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,9 +51,27 @@ public class JavaLoggingSystem extends AbstractLoggingSystem { LEVELS = Collections.unmodifiableMap(levels); } - public JavaLoggingSystem(ClassLoader classLoader) { - super(classLoader, "logging.properties"); + public JavaLoggingSystem(ClassLoader classLoader, boolean fileOutput, boolean consoleOutput) { + super(classLoader, fileOutput, consoleOutput); } + + @Override + protected String[] getLogFileName(boolean fileOutput, boolean consoleOutput) { + if (fileOutput && consoleOutput) { + return new String[] { "logging-file-console.properties" }; + } + else if (fileOutput) { + return new String[] { "logging-file.properties" }; + } + else if (consoleOutput) { + return new String[] { "logging-console.properties" }; + } + else { + return new String[] { "logging.properties" }; + } + } + + @Override public void initialize(String configLocation) { diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/log4j/Log4JLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/log4j/Log4JLoggingSystem.java index 7e584a37ada..ed57f47df9c 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/log4j/Log4JLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/log4j/Log4JLoggingSystem.java @@ -51,8 +51,24 @@ public class Log4JLoggingSystem extends Slf4JLoggingSystem { LEVELS = Collections.unmodifiableMap(levels); } - public Log4JLoggingSystem(ClassLoader classLoader) { - super(classLoader, "log4j.xml", "log4j.properties"); + public Log4JLoggingSystem(ClassLoader classLoader, boolean fileOutput, boolean consoleOutput) { + super(classLoader, fileOutput, consoleOutput); + } + + @Override + protected String[] getLogFileName(boolean fileOutput, boolean consoleOutput) { + if (fileOutput && consoleOutput) { + return new String[] { "log4j-file-console.xml", "log4j-file-console.properties" }; + } + else if (fileOutput) { + return new String[] { "log4j-file.xml", "log4j-file.properties" }; + } + else if (consoleOutput) { + return new String[] { "log4j-console.xml", "log4j-console.properties" }; + } + else { + return new String[] { "log4j.xml", "log4j.properties" }; + } } @Override diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java index 450bc34c256..51991d07d7d 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java @@ -58,9 +58,27 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem { LEVELS = Collections.unmodifiableMap(levels); } - public LogbackLoggingSystem(ClassLoader classLoader) { - super(classLoader, "logback-test.groovy", "logback-test.xml", "logback.groovy", - "logback.xml"); + public LogbackLoggingSystem(ClassLoader classLoader, boolean fileOutput, boolean consoleOutput) { + super(classLoader, fileOutput, consoleOutput); + } + + @Override + protected String[] getLogFileName(boolean fileOutput, boolean consoleOutput) { + if (fileOutput && consoleOutput) { + return new String[] { "logback-test-file-console.groovy", "logback-test-file-console.xml", + "logback-file-console.groovy", "logback-file-console.xml" }; + } + else if (fileOutput) { + return new String[] { "logback-test-file.groovy", "logback-test-file.xml", "logback-file.groovy", + "logback-file.xml" }; + } + else if (consoleOutput) { + return new String[] { "logback-test-console.groovy", "logback-test-console.xml", "logback-console.groovy", + "logback-console.xml" }; + } + else { + return new String[] { "logback-test.groovy", "logback-test.xml", "logback.groovy", "logback.xml" }; + } } @Override diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/java/logging-console.properties b/spring-boot/src/main/resources/org/springframework/boot/logging/java/logging-console.properties new file mode 100644 index 00000000000..96fe6485034 --- /dev/null +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/java/logging-console.properties @@ -0,0 +1,13 @@ +handlers =java.util.logging.ConsoleHandler +.level = INFO + +java.util.logging.ConsoleHandler.formatter = org.springframework.boot.logging.java.SimpleFormatter +java.util.logging.ConsoleHandler.level = ALL + +org.hibernate.validator.internal.util.Version.level = WARNING +org.apache.coyote.http11.Http11NioProtocol.level = WARNING +org.crsh.plugin.level = WARNING +org.apache.tomcat.util.net.NioSelectorPool.level = WARNING +org.apache.catalina.startup.DigesterFactory.level = SEVERE +org.apache.catalina.util.LifecycleBase.level = SEVERE +org.eclipse.jetty.util.component.AbstractLifeCycle.level = SEVERE diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/java/logging-file-console.properties b/spring-boot/src/main/resources/org/springframework/boot/logging/java/logging-file-console.properties new file mode 100644 index 00000000000..0316feebabd --- /dev/null +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/java/logging-file-console.properties @@ -0,0 +1,20 @@ +handlers =java.util.logging.FileHandler,java.util.logging.ConsoleHandler +.level = INFO + +# File Logging +java.util.logging.FileHandler.pattern = %t/spring.log +java.util.logging.FileHandler.formatter = org.springframework.boot.logging.java.SimpleFormatter +java.util.logging.FileHandler.level = ALL +java.util.logging.FileHandler.limit = 10485760 +java.util.logging.FileHandler.count = 10 + +java.util.logging.ConsoleHandler.formatter = org.springframework.boot.logging.java.SimpleFormatter +java.util.logging.ConsoleHandler.level = ALL + +org.hibernate.validator.internal.util.Version.level = WARNING +org.apache.coyote.http11.Http11NioProtocol.level = WARNING +org.crsh.plugin.level = WARNING +org.apache.tomcat.util.net.NioSelectorPool.level = WARNING +org.apache.catalina.startup.DigesterFactory.level = SEVERE +org.apache.catalina.util.LifecycleBase.level = SEVERE +org.eclipse.jetty.util.component.AbstractLifeCycle.level = SEVERE diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/java/logging-file.properties b/spring-boot/src/main/resources/org/springframework/boot/logging/java/logging-file.properties new file mode 100644 index 00000000000..314d49eaf3d --- /dev/null +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/java/logging-file.properties @@ -0,0 +1,17 @@ +handlers =java.util.logging.FileHandler +.level = INFO + +# File Logging +java.util.logging.FileHandler.pattern = %t/spring.log +java.util.logging.FileHandler.formatter = org.springframework.boot.logging.java.SimpleFormatter +java.util.logging.FileHandler.level = ALL +java.util.logging.FileHandler.limit = 10485760 +java.util.logging.FileHandler.count = 10 + +org.hibernate.validator.internal.util.Version.level = WARNING +org.apache.coyote.http11.Http11NioProtocol.level = WARNING +org.crsh.plugin.level = WARNING +org.apache.tomcat.util.net.NioSelectorPool.level = WARNING +org.apache.catalina.startup.DigesterFactory.level = SEVERE +org.apache.catalina.util.LifecycleBase.level = SEVERE +org.eclipse.jetty.util.component.AbstractLifeCycle.level = SEVERE diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/java/logging.properties b/spring-boot/src/main/resources/org/springframework/boot/logging/java/logging.properties index a37a6fa0961..fa027f53ab8 100644 --- a/spring-boot/src/main/resources/org/springframework/boot/logging/java/logging.properties +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/java/logging.properties @@ -1,16 +1,6 @@ -handlers = java.util.logging.FileHandler, java.util.logging.ConsoleHandler +handlers = .level = INFO -# File Logging -java.util.logging.FileHandler.pattern = %t/spring.log -java.util.logging.FileHandler.formatter = org.springframework.boot.logging.java.SimpleFormatter -java.util.logging.FileHandler.level = ALL -java.util.logging.FileHandler.limit = 10485760 -java.util.logging.FileHandler.count = 10 - -java.util.logging.ConsoleHandler.formatter = org.springframework.boot.logging.java.SimpleFormatter -java.util.logging.ConsoleHandler.level = ALL - org.hibernate.validator.internal.util.Version.level = WARNING org.apache.coyote.http11.Http11NioProtocol.level = WARNING org.crsh.plugin.level = WARNING diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-console.properties b/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-console.properties new file mode 100644 index 00000000000..e0885761df1 --- /dev/null +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-console.properties @@ -0,0 +1,20 @@ +log4j.rootCategory=INFO, CONSOLE + +PID=???? +LOG_PATH=${java.io.tmpdir} +LOG_FILE=${LOG_PATH}/spring.log +LOG_PATTERN=[%d{yyyy-MM-dd HH:mm:ss.SSS}] boot%X{context} - ${PID} %5p [%t] --- %c{1}: %m%n + +# CONSOLE is set to be a ConsoleAppender using a PatternLayout. +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=${LOG_PATTERN} + + +log4j.category.org.hibernate.validator.internal.util.Version=WARN +log4j.category.org.apache.coyote.http11.Http11NioProtocol=WARN +log4j.category.org.crsh.plugin=WARN +log4j.category.org.apache.tomcat.util.net.NioSelectorPool=WARN +log4j.category.org.apache.catalina.startup.DigesterFactory=ERROR +log4j.category.org.apache.catalina.util.LifecycleBase=ERROR +log4j.category.org.eclipse.jetty.util.component.AbstractLifeCycle=ERROR diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-file-console.properties b/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-file-console.properties new file mode 100644 index 00000000000..58baefaced6 --- /dev/null +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-file-console.properties @@ -0,0 +1,25 @@ +log4j.rootCategory=INFO, CONSOLE, FILE + +PID=???? +LOG_PATH=${java.io.tmpdir} +LOG_FILE=${LOG_PATH}/spring.log +LOG_PATTERN=[%d{yyyy-MM-dd HH:mm:ss.SSS}] boot%X{context} - ${PID} %5p [%t] --- %c{1}: %m%n + +# CONSOLE is set to be a ConsoleAppender using a PatternLayout. +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=${LOG_PATTERN} + +log4j.appender.FILE=org.apache.log4j.RollingFileAppender +log4j.appender.FILE.File=${LOG_FILE} +log4j.appender.FILE.MaxFileSize=10MB +log4j.appender.FILE.layout = org.apache.log4j.PatternLayout +log4j.appender.FILE.layout.ConversionPattern=${LOG_PATTERN} + +log4j.category.org.hibernate.validator.internal.util.Version=WARN +log4j.category.org.apache.coyote.http11.Http11NioProtocol=WARN +log4j.category.org.crsh.plugin=WARN +log4j.category.org.apache.tomcat.util.net.NioSelectorPool=WARN +log4j.category.org.apache.catalina.startup.DigesterFactory=ERROR +log4j.category.org.apache.catalina.util.LifecycleBase=ERROR +log4j.category.org.eclipse.jetty.util.component.AbstractLifeCycle=ERROR diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-file.properties b/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-file.properties new file mode 100644 index 00000000000..949ec6de237 --- /dev/null +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j-file.properties @@ -0,0 +1,20 @@ +log4j.rootCategory=INFO,FILE + +PID=???? +LOG_PATH=${java.io.tmpdir} +LOG_FILE=${LOG_PATH}/spring.log +LOG_PATTERN=[%d{yyyy-MM-dd HH:mm:ss.SSS}] boot%X{context} - ${PID} %5p [%t] --- %c{1}: %m%n + +log4j.appender.FILE=org.apache.log4j.RollingFileAppender +log4j.appender.FILE.File=${LOG_FILE} +log4j.appender.FILE.MaxFileSize=10MB +log4j.appender.FILE.layout = org.apache.log4j.PatternLayout +log4j.appender.FILE.layout.ConversionPattern=${LOG_PATTERN} + +log4j.category.org.hibernate.validator.internal.util.Version=WARN +log4j.category.org.apache.coyote.http11.Http11NioProtocol=WARN +log4j.category.org.crsh.plugin=WARN +log4j.category.org.apache.tomcat.util.net.NioSelectorPool=WARN +log4j.category.org.apache.catalina.startup.DigesterFactory=ERROR +log4j.category.org.apache.catalina.util.LifecycleBase=ERROR +log4j.category.org.eclipse.jetty.util.component.AbstractLifeCycle=ERROR diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j.properties b/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j.properties index 58baefaced6..f8a630ca8de 100644 --- a/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j.properties +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/log4j/log4j.properties @@ -1,20 +1,10 @@ -log4j.rootCategory=INFO, CONSOLE, FILE +log4j.rootCategory=INFO PID=???? LOG_PATH=${java.io.tmpdir} LOG_FILE=${LOG_PATH}/spring.log LOG_PATTERN=[%d{yyyy-MM-dd HH:mm:ss.SSS}] boot%X{context} - ${PID} %5p [%t] --- %c{1}: %m%n -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=${LOG_PATTERN} - -log4j.appender.FILE=org.apache.log4j.RollingFileAppender -log4j.appender.FILE.File=${LOG_FILE} -log4j.appender.FILE.MaxFileSize=10MB -log4j.appender.FILE.layout = org.apache.log4j.PatternLayout -log4j.appender.FILE.layout.ConversionPattern=${LOG_PATTERN} log4j.category.org.hibernate.validator.internal.util.Version=WARN log4j.category.org.apache.coyote.http11.Http11NioProtocol=WARN diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/basic-log4j2.xml b/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/basic-log4j2.xml deleted file mode 100644 index fdac8fe9584..00000000000 --- a/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/basic-log4j2.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - ???? - [%d{yyyy-MM-dd HH:mm:ss.SSS}] boot%X{context} - ${sys:PID} %5p [%t] --- %c{1}: %m%n - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2.xml b/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2.xml deleted file mode 100644 index 4b89e3fc384..00000000000 --- a/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - ???? - /tmp - ${sys:LOG_PATH}/spring.log - [%d{yyyy-MM-dd HH:mm:ss.SSS}] boot%X{context} - ${sys:PID} %5p [%t] --- %c{1}: %m%n - - - - - - - - ${LOG_PATTERN} - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/base.xml b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/base.xml index 67958866ec1..04eb8955ebb 100644 --- a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/base.xml +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/base.xml @@ -3,27 +3,8 @@ - - - - - - ${FILE_LOG_PATTERN} - - ${LOG_FILE} - - ${LOG_FILE}.%i - - - 10MB - - - - diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic-console.xml b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic-console.xml new file mode 100644 index 00000000000..30dfc9be4f5 --- /dev/null +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic-console.xml @@ -0,0 +1,18 @@ + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + + diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic-file.xml b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic-file.xml new file mode 100644 index 00000000000..b05d3c740ef --- /dev/null +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic-file.xml @@ -0,0 +1,23 @@ + + + + + + + + ${FILE_LOG_PATTERN} + + ${LOG_FILE} + + ${LOG_FILE}.%i + + + 10MB + + + + + + diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic.xml b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic.xml index 17499b22672..f2823ffac66 100644 --- a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic.xml +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/basic.xml @@ -1,24 +1,10 @@ - - - - - - - - ${CONSOLE_LOG_PATTERN} - utf-8 - - org.springframework.boot - - - - + diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback-console.xml b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback-console.xml new file mode 100644 index 00000000000..69a57c719fa --- /dev/null +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback-console.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback-file-console.xml b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback-file-console.xml new file mode 100644 index 00000000000..a97dd6e69e5 --- /dev/null +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback-file-console.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback-file.xml b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback-file.xml new file mode 100644 index 00000000000..a58db2ef99d --- /dev/null +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback-file.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback.xml b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback.xml index 3eb676013ff..c4cce79ddc9 100644 --- a/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback.xml +++ b/spring-boot/src/main/resources/org/springframework/boot/logging/logback/logback.xml @@ -1,18 +1,4 @@ - + - - - - -