multiple applications with multiple log4j.xml in w

2019-05-10 16:18发布

问题:

I deploy multiple applications (ear) in one domain on a Weblogic-Server. Each application uses log4j. My wish is to configure each applications with its own log4j.xml. Is this possible? The log4j.xml should be outside of the ear, so that I can edit it without rebuilding the ear.

I'm used to put the log4j.xml in the serverclasspath, then it is read on server startup. But then I don't have the possibility to use different log4j.xml for each application.

I think it is a classpath issue, because log4j search for the log4j.xml in the classpath. But I don't know, how to uses different classpath for different applications.

回答1:

I don't think its possible to have different log4j.xml files for different applications deployed on the same WebLogic server unless the log4j.xml files are packaged with ear itself.

So, may be you can have different loggers for different applications? That way same log4j.xml can be used by different applications but the logger definitions the applications use can differ.



回答2:

Um, sure it is possible, if you configure the log4j by yourself from different files (such as log4j-app1.xml and log4j-app2.xml). You could have a configuring servlet per app. See details in this other post I made.

However, having them all in a one file, like already proposed here, is something I would also recommend.