1. 程式人生 > >Spring boot 官網學習筆記 - logging

Spring boot 官網學習筆記 - logging

  1. 調整日誌級別
    1. Log Level: ERROR, WARN, INFO, DEBUG, or TRACE.
    2. Logback does not have a FATAL level. It is mapped to ERROR.
    3. The default log configuration echoes messages to the console as they are written. By default, ERROR-level, WARN-level, and INFO-level messages are logged. You can also enable a “debug” mode by starting your application with a --debug
      flag.
    4. $ java -jar myapp.jar --debug
    5. Alternatively, you can enable a “trace” mode by starting your application with a --trace flag (or trace=true in your application.properties).
  2. 日誌檔案
    1. By default, Spring Boot logs only to the console and does not write log files. If you want to write log files in addition to the console output, you need to set a logging.file
      or logging.path property (for example, in your application.properties).
    2. Log files rotate when they reach 10 MB and, as with console output, ERROR-level, WARN-level, and INFO-level messages are logged by default. Size limits can be changed using the logging.file.max-size property. Previously rotated files are archived indefinitely unless the logging.file.max-history
      property has been set.
    3. Logging properties are independent of the actual logging infrastructure. As a result, specific configuration keys (such as logback.configurationFile for Logback) are not managed by spring Boot.