首页 > 解决方案 > 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.

标签: spring-bootlogbackspring-logback

解决方案


您可以使用您的 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

并为每个配置文件定义


推荐阅读