26.3 File output
By default, Spring Boot will only log to the console and will 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
).
The following table shows how the logging.*
properties can be used together:
Table 26.1. Logging properties
logging.file |
logging.path |
Example | Description |
---|---|---|---|
(none) | (none) | Console only logging. | |
Specific file | (none) | my.log |
Writes to the specified log file. Names can be an exact location or relative to the current directory. |
(none) | Specific directory | /var/log |
Writes spring.log to the specified directory. Names can be an exact location or relative to the current directory. |
Log files will rotate when they reach 10 Mb and as with console output, ERROR
, WARN
and INFO
level messages are logged by default.
Note | |
---|---|
The logging system is initialized early in the application lifecycle and as such logging properties will not be found in property files loaded via @PropertySource annotations. |
Tip | |
---|---|
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. |