简体   繁体   中英

Spring MVC + Log4j2 defining log4j2.properties file in none class path location not identified

I'm trying to configure Spring (non boot) MVC project with log4j2 logging capabilities. Currently I've placed all *.properties files in a location that is not in the class path. I've used @PropertySource annotation for this configuration. I'm getting below message

ERROR StatusLogger No Log4j 2 configuration file found.
Using default configuration (logging only errors to the console), or user programmatically provided configurations.
Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging.
See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2

Any clue on how and where I've done wrong? if there are good references to check please do share.

Add log4j2-web package into project, and then add listener on web.xml:

<listener>
    <listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>
</listener>

and you can set configure path here:

<context-param>
    <param-name>log4jConfiguration</param-name>
    <param-value>file:///D:/conf/myLogging.xml</param-value>
</context-param>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM