log4j2 logging happening in the wrong path

Viewed 1499

I have an ear deployed in weblogic with the log4j2.xml logPath set as

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

and a logger defined as

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

Inside this ear/lib there is a jar containing a log4j2.xml and the logPath property is defined as

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

and a logger with a very similar packaging structure

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

Both log4j2.xml's are configured to have a different log file name as well. But the logs for both are coming in the path some_path_2 and with the file name defined in that jar

How to ensure both logging outputs happens 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 added the following in the containing war's web.xml but it did not help

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

Edit2: I also tried this and found that this is working intermittently

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
4 Answers
Related