Springboot如何在服务器重启时轮换日志文件。
我有以下条目
# LOGGING
logging.level.org.springframework.web=WARN
logging.level.org.hibernate=WARN
logging.file=/var/log/apps/myapp.log
我在这里找不到任何详细信息:
最佳答案
根据 application.properties 中有关日志文件的以下链接,以下是配置。
https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
logging.file.max-history=0 # Maximum of archive log files to keep. Only supported with the default logback setup.
logging.file.max-size=10MB # Maximum log file size. Only supported with the default logback setup.
除上述之外,您还可以根据服务器配置检查以下配置。
server.tomcat.accesslog.rotate=true # Whether to enable access log rotation.
server.undertow.accesslog.rotate=true # Whether to enable access log rotation.
我建议将 Slf4j 与 logback 一起使用。您需要配置logback.xml,并且可以配置滚动文件appender。
关于java - Spring Boot如何在服务器重启时轮换日志文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57312048/