外部log4j2配置文件问题

时间:2019-06-16 21:09:49

标签: eclipse spring-boot log4j2

我想从外部位置(C:\ log \ log4j2.propertiesEXT)使用log4j2.properties文件。

现在我的类路径中有一个log4j2.properties文件。

我试图将-Dlog4j.configurationFile = C:\ log \ log4j2.propertiesEXT添加到eclipse中的默认VM参数。它正在工作,并且消息记录也在d控制台中完成。

但是,现在当我尝试删除classpath中的log4j2.priperties文件时,也无法访问外部位置的log4j2.propertiesEXT文件。

所以我的疑问是,当类路径中没有log4j2文件时,为什么不能从外部位置访问log4j2.properties文件?

[注意:在引用外部日志文件时,控制台中的消息日志记录以不同的格式完成,如log4j2.propertiesEXT中所述。类路径中的log4j2.properties文件具有不同的日志记录格式。

通过执行此操作,我确保成功访问了log4j2.propertiesEXT。

谢谢

控制台中的状态记录:

2019-06-17 14:03:26.722  INFO 19864 --- [           main] c.e.r.RedisTemplateDemoApplication       : Starting RedisTemplateDemoApplication on ojs128390 with PID 19864(D:\redisTemplateDemo1\redisTemplateDemo\bin\main started by David in D:\redisTemplateDemo1\redisTemplateDemo)


2019-06-17 14:03:26.734  INFO 19864 --- [           main] c.e.r.RedisTemplateDemoApplication       : No active profile set, falling back to default profiles: default


SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".


SLF4J: Defaulting to no-operation (NOP) logger implementation


SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.


2019-06-17 14:03:30.097  INFO 19864 --- [           main] o.s.b.w.e.t.TomcatWebServer              : Tomcat initialized with port(s): 8082 (http)
Jun 17, 2019 2:03:30 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8082"]


Jun 17, 2019 2:03:30 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Tomcat]


Jun 17, 2019 2:03:30 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet engine: [Apache Tomcat/9.0.19]


Jun 17, 2019 2:03:30 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring embedded WebApplicationContext
2019-06-17 14:03:30.496  INFO 19864 --- [           main] o.s.w.c.ContextLoader                    : Root WebApplicationContext: initialization completed in 3642 ms


2019-06-17 14:03:31.228  INFO 19864 --- [           main] o.s.s.c.ThreadPoolTaskExecutor           : Initializing ExecutorService 'applicationTaskExecutor'
Jun 17, 2019 2:03:31 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8082"]


2019-06-17 14:03:31.898  INFO 19864 --- [           main] o.s.b.w.e.t.TomcatWebServer              : Tomcat started on port(s): 8082 (http) with context path ''


2019-06-17 14:03:31.906  INFO 19864 --- [           main] c.e.r.RedisTemplateDemoApplication       : Started RedisTemplateDemoApplication in 6.21 seconds (JVM running for 8.455)

0 个答案:

没有答案
相关问题