java - Springboot如何在服务器重启时轮换日志文件
问题描述
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 并且可以配置滚动文件附加程序。
推荐阅读
- firebase - Firebase 身份验证仅将 Facebook 和电子邮件身份验证转换为 Google 身份验证,反之则不然
- c# - 特定记录器名称的 Nlog 规则不起作用
- haskell - 从 Signal Int 到 Haskell 中的 Int
- reactjs - 为什么我不断收到 Delete 'cr' [prettier/prettier]?
- javascript - 在 React 日历中编辑表单
- typo3 - 如何在 TYPO3 v9 (2018) 中创建 Fluid Extension Provider
- java - 检查参数化谓词之间的相等性
- python - 如何使用python根据特定条件删除父+子节点
- python - Python中的数据分布
- c# - 检测客户端或服务器模式