SpringBoot 官方文档示例(88):配置logback把日志写到文件

时间:2023-02-18 13:54:09


一、配置日志文件名

logging.file.name=myapplication.log

二、在resources下创建logback-spring.xml配置文件

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-
${java.io.tmpdir:-/tmp}}/}spring.log}"/>
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<root level="INFO">
<appender-ref ref="FILE" />
</root>
</configuration>