//排除默认的
<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