spring-boot - How to add default logback.xml to spring boot project?
问题描述
I have created a new spring boot project using spring initializer with spring-boot-starter-web
as a starter project.I am able to use logback for logging but am unable to find default logback.xml in the project.I tried to search out but could not find reference to default file on logback documentation as well. I am looking to customize the logback file to use custom appender.
解决方案
您可以使用您的 application.yml 进行自定义,如下所示:
logging:
level:
root: WARN
org.springframework.security: DEBUG
org.springframework.web.servlet: INFO
org.springframework.jmx: INFO
org.springframework.cloud.config.client: INFO
org.springframework.cloud.context: INFO
org.hibernate: INFO
org.hibernate.sql: DEBUG
pattern:
console: '%date{HH:mm:ss.SSS} [%-5level] %-65logger - %msg%n'
file: '%date{HH:mm:ss.SSS} [%-5level] %-65logger - %msg%n'
file: D:/logs/my-log.log
并为每个配置文件定义
推荐阅读
- reactjs - 我们可以在 Gatsby.js 应用程序上实现 AMP-HTML 吗?
- c# - .NET 框架中是否有不适用于 LINQ 的内置扩展方法?
- javascript - Event toggle listener
- python - Set last day of month in date
- java - 当我退出我的设置菜单并重新输入时,OnPreferenceChangedListener 停止工作
- ajax - 如何连接到我的 Heroku postgreSQL 数据库以验证用户身份?
- java - Java 8 Base64 JWT 令牌转换为 JSON
- python - shutil.which() 在不附加文件扩展名的情况下找不到程序
- sql - 不使用列表的设施计数
- excel - 从excel中的数据生成word文档的宏