# 78.1.1 配置logback只输出到文件

如果想禁用控制台日志记录，只将输出写入文件中，你需要一个只导入`file-appender.xml`而不是`console-appender.xml`的自定义`logback-spring.xml`：

```markup
<?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>
```

你还需要将`logging.file`添加到`application.properties`：

```
logging.file=myapplication.log
```
