views:

451

answers:

2

I can't imagine that my question is so specific to my case, but I did not see any similar questions asked here so far.

I would like to be able to specify a log4g.properties file outside of my .ear packaging so that it is easier to alter the logging levels without repackaging the ear. Actually, the most pressing motivation for doing it like that is our group's already-established convention of having the log4j properties files outside of the ear, so getting around that constraint (by putting the log4j.properties file in the APP-INF/classes dir, or the root of the ear, etc.) is not applicable.

The ear contains a stateless EJB that delegates to a series of Spring POJOs to accomplish its behavior.

I've seen others in my group deploy a WAR file inside the EAR with its only responsibility to load the log4j properties file from a specified (external) path using a context listener. Although the path is "external" to the EAR, it's still on the classpath. For example, the folder /config is on the classpath, and the WAR uses a context listener to load the log4j.properties from /config/appname/log4j.properties.

To me, using a WAR whose sole purpose is to load a log4.properties file is a hack/overkill.

There HAS to be a better way, right?

A: 

Just add log4j.properties to the classpath of weblogic and remove the log4j.properties file in the war and ear.

You can do this in the console. Go to servername - configuration - Server Start

Now add the directory of log4j.properties to your classpath. Your application now will use the log4j.properties file which is outside your ear.

Edwin