首页 > 其他分享 >spring boot——spring boot的基本配置——日志配置——内置的LogBack

spring boot——spring boot的基本配置——日志配置——内置的LogBack

时间:2023-01-01 22:56:27浏览次数:39  
标签:logging log level spring boot org 日志 LogBack

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

===========================================================================

 

 

 

 

 

 

 

 

 

 

配置文件:

spring.main.banner-mode = off
test.environment = read config by environment
obj.sname=chenheng
obj.sage=88

#设定日志的默认级别为info
logging.level.root=info

##设定org包下的日志级别为warn
#logging.level.org=warn

##设定com.ch.ch4_1包下的日志级别为debug
#logging.level.com.ch.ch4_1=debug

logging.file=c:/log/my.log
logging.pattern.console=%level %date{yyyy-MM-dd HH:mm:ss:SSS} %logger{50}.%M %L :%m%n
logging.pattern.file=%level %date{ISO8601} %logger{50}.%M %L :%m%n

 

 

 

 

 

package org.example.controller;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LogTestController
{

    private Log log = LogFactory.getLog(LogTestController.class);


    @RequestMapping("/testLog")
    public String testLog()
    {

        log.info("测试日志");
        return "测试日志1" ;

    }
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

===================================================================================

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

标签:logging,log,level,spring,boot,org,日志,LogBack
From: https://www.cnblogs.com/xiaobaibailongma/p/17019197.html

相关文章