在resources里的配置文件: logback-spring.xml
%d - %msg%n ERROR DENY ACCEPT %d - %msg%n D:\\logger\\info.%d.log ERROR %msg%n D:\\logger\\error.%d.log
SpringBoot启动类,测试日志打印
package com.st;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublic class SpringbApplication { private static final Logger logger = LoggerFactory.getLogger(SpringbApplication.class); public static void main(String[] args) { SpringApplication.run(SpringbApplication.class, args); String msg = "习惯日志记录"; logger.info("打印日志...{}",msg); }}
启动后,控制台输出如下:
保存的日志文件