我想将所有内部Springboot日志消息定向到log4j,以便消息遵循我的log4j属性,但它是无效的。
<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>logging.config =文件:/data/log/report-log4j.properties
启动springboot,它输出
log4j:WARN记录器(org.springframework.web.context.support.StandardServletEnvironment)找不到appender。 log4j:WARN请正确初始化log4j系统
但是,classpath中的report-log4j.properties,它是成功的。
I would like to have all the internal Springboot log messages directed to log4j so that the messages follow my log4j properties,but it is invalid.
<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>logging.config=file:/data/log/report-log4j.properties
start up springboot,it outputs
log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment). log4j:WARN Please initialize the log4j system properly
but,report-log4j.properties in classpath,it is success。
最满意答案
这不是无效的,你只是忘了在资源目录中添加一个log4j.properties文件。
它通常有以下内容:
# Root logger option log4j.rootLogger=INFO, stdout # Redirect log messages to console log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%nI solved it . because spring-boot version1.4 not support log4j
更多推荐
发布评论