Spring Boot default configuration logs

Spring Boot used in all internal logs Commons Logging, but the default configuration also provides support for common log, such as: Java Util Logging, Log4J, Log4J2 and Logback. Each Logger can use the console output log file or content through configuration.

Formatting log

The default log output is as follows:

2016-04-13 08:23:50.120  INFO 37397 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {4.3.11.Final}

Outputting content elements as follows:

  • Date Time: accurate millisecond
  • Log levels: ERROR, WARN, INFO, DEBUG or TRACE
  • Process ID
  • Delimiter: Start --- identify the actual log
  • Thread name: square brackets (console output may be truncated)
  • Logger name: commonly used source class name
  • Log content

Console output

In the default configuration in Spring Boot ERROR, WARN, and INFO-level log output to the console.

We can switch to DEBUG level in two ways:

  • After running the command added --debug flag, such as: $ java -jar myapp.jar --debug
  • When configuring debug = true in application.properties, this property is set to true, the core Logger (containing embedded container, hibernate, spring) output will be more, but the log of your own applications and does not output level to DEBUG

File Output

Spring Boot default configuration will only be output to the console, and will not be recorded to a file, but we often need to produce all documents recorded time environment.

To increase the output file, you need to configure logging.file or logging.path property in application.properties in.

  • logging.file, settings file, can be an absolute path, or a relative path. Such as: logging.file = my.log
  • logging.path, set the directory is created in the directory spring.log file and write the contents of the log, such as: logging.path = / var / log

Log files are truncated at 10Mb size when a new log file, the default level is: ERROR, WARN, INFO

Guess you like

Origin www.cnblogs.com/ruguomeiyouni/p/11590150.html