码迷,mamicode.com
首页 > 编程语言 > 详细

Springboot: log4j集成,配合lombok

时间:2019-05-30 21:50:09      阅读:916      评论:0      收藏:0      [点我收藏+]

标签:out   org   class   info   article   artifact   mapping   roo   log   

        //排除默认的
     <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j</artifactId> <version>1.3.8.RELEASE</version> </dependency>

      <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
      </dependency>

log4j.properties文件

log4j.rootLogger=INFO,Console,File
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%c] - %m%n
log4j.appender.File=org.apache.log4j.RollingFileAppender
log4j.appender.File.File=logs/ssm.log
log4j.appender.File.MaxFileSize=10MB
log4j.appender.File.Threshold=ALL
log4j.appender.File.layout=org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern=[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%c]%m%n

使用

@RestController
@RequestMapping("/demo")
@Slf4j
public class DemoController {
    @RequestMapping(value = "/test", method = {RequestMethod.GET, RequestMethod.POST})
    public String test() {
        log.info("测试方法");
        return "hello,this is zhngxian‘s demo";
    }
}

 

https://blog.csdn.net/IT_hejinrong/article/details/89148860

 

Springboot: log4j集成,配合lombok

标签:out   org   class   info   article   artifact   mapping   roo   log   

原文地址:https://www.cnblogs.com/gaomanito/p/10952211.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!