我有一个带有许多子框架的 Spring Boot 应用程序。当我启动应用程序时,我默认登录
/opt/engine.log
。有没有办法全局禁用此日志记录?
是的,您可以通过不同的方式重定向日志。
logging.file=/path/to/your/logfile.log
或者在 yaml 文件中添加
logging: file: /path/to/your/logfile.log
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<property name="LOG_FILE" value="/path/to/your/logfile.log"/>
<include resource="org/springframework/boot/logging/logback/file-appender.xml"/>
<root level="OFF">
<appender-ref ref="FILE"/>
</root>
</configuration>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
<File name="File" fileName="/path/to/your/logfile.log">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</File>
</Appenders>
<Loggers>
<Root level="OFF">
<AppenderRef ref="File"/>
</Root>
</Loggers>
</Configuration>