我正在尝试使用log4j创建日志文件。请告诉我此文件出了什么问题
这是log4j.properties文件。
# Root logger option
log4j.rootLogger=INFO, file
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=servicesname.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
主班
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
PropertyConfigurator.configure("log4j.properties");
logger.info("Application is Started");
}
答案 0 :(得分:0)
日志文件未创建:log4j
我通过排除“ spring-boot-starter-logging”解决了这个问题。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
谢谢