Skip to content

Commit 89112d6

Browse files
authored
Update 73.1.1 Configure logback for file only output.md
1 parent f8fe745 commit 89112d6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1-
###73.1.1 Configure logback for file only output
1+
###73.1.1 配置logback只输出到文件
2+
3+
如果想禁用控制台日志记录,只将输出写入文件中,你需要一个只导入`file-appender.xml`而不是`console-appender.xml`的自定义`logback-spring.xml`
4+
```xml
5+
<?xml version="1.0" encoding="UTF-8"?>
6+
<configuration>
7+
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
8+
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/>
9+
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
10+
<root level="INFO">
11+
<appender-ref ref="FILE" />
12+
</root>
13+
</configuration>
14+
```
15+
你还需要将`logging.file`添加到`application.properties`
16+
```properties
17+
logging.file=myapplication.log
18+
```

0 commit comments

Comments
 (0)