Java – log4j2 logging occurs on the wrong path

I deployed an ear in Weblogic and put log4j2 XML logpath set to

<Property name="logPath">some_path_1<Property>

And recorders are defined as

<Logger name="a.b.c.d" level="INFO" />

The ear / lib contains a log4j2 The jar and logpath properties of XML are defined as

<Property name="logPath">some_path_2<Property>

A recorder very similar to a packaging structure

<Logger name="a.b.c" level="INFO" />

log4j2. XML is configured to have different log file names But both logs are in the path some_ path_ 2, and the file name is defined in the jar

How to ensure that two log record outputs are performed separately as defined?

My ear structure is like

ear
|--lib
|--|--abc.jar
|--|--|--log4j2.xml //the one thats getting loaded
|--xyz.war
|--|--WEB-INF
|--|--|--classes
|--|--|--|--log4j2.xml // the one I want

Edit1: I'm on the web. Com that contains war The following has been added to the XML, but it does not help

<context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/classes/log4j2.xml</param-value>
    </context-param>

Editor 2: I also tried this and found it intermittent

ear
|--lib
|--|--abc.jar
|--|--|--log4j2.xml //the one thats getting loaded
|--|--xyz.jar
|--|--|--log4j2.xml //the one I want.. works but not always.Does classloader loads the jars alphabetically?
|--xyz.war
|--|--WEB-INF
|--|--|--classes
|--|--|--|--log4j2.xml // the one I want

Solution

Log4j is initialized only once with the configuration file first found by the log4j bootstrap All other (possible) profiles will not be considered Learn more about log4j automatic priority configuration in the corresponding tutorials

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>