springboot日志记录配置无效(springboot logging config invalid)

编程入门 行业动态 更新时间:2024-10-14 08:30:14
springboot日志记录配置无效(springboot logging config invalid)

我想将所有内部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%n

I solved it . because spring-boot version1.4 not support log4j

更多推荐

本文发布于:2023-08-06 20:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1455070.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日志   springboot   logging   invalid   config

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!