Provide a property to configure conversion word used to log exceptions

This commit adds a new property, logging.exception-conversion-word,
that can be used to configure the conversion word that is used when
logging exceptions. The default value, %rEx, will log exceptions
with the root cause first and include class packaging information in
the stack trace. The new property is supported when using either
Logback or Log4J2.

Closes gh-3684
This commit is contained in:
Andy Wilkinson
2015-08-06 11:34:45 +01:00
parent 67d29c13f5
commit 1a11ed20ba
11 changed files with 125 additions and 27 deletions

View File

@@ -56,10 +56,11 @@ content into your application; rather pick only the properties that you need.
spring.output.ansi.enabled=detect # Configure the ANSI output ("detect", "always", "never")
# LOGGING
logging.path=/var/log
logging.file=myapp.log
logging.config= # location of config file (default classpath:logback.xml for logback)
logging.exception-conversion-word=%rEx # conversion word used when logging exceptions
logging.file=myapp.log
logging.level.*= # levels for loggers, e.g. "logging.level.org.springframework=DEBUG" (TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF)
logging.path=/var/log
logging.pattern.console= # appender pattern for output to the console (only supported with the default logback setup)
logging.pattern.file= # appender pattern for output to the file (only supported with the default logback setup)

View File

@@ -1195,7 +1195,9 @@ These are:
* `${PID}` the current process ID.
* `${LOG_FILE}` if `logging.file` was set in Boot's external configuration.
* `${LOG_PATH}` if `logging.path` was set (representing a directory for
log files to live in).
log files to live in).
* `${LOG_EXCEPTION_CONVERSION_WORD}` if `logging.exception-conversion-word` was set in
Boot's external configuration.
Spring Boot also provides some nice ANSI colour terminal output on a console (but not in
a log file) using a custom Logback converter. See the default `base.xml` configuration

View File

@@ -1068,6 +1068,10 @@ To help with the customization some other properties are transferred from the Sp
|===
|Spring Environment |System Property |Comments
|`logging.exception-conversion-word`
|`LOG_EXCEPTION_CONVERSION_WORD`
|The conversion word that's used when logging exceptions.
|`logging.file`
|`LOG_FILE`
|Used in default log configuration if defined.