I have an EAR composed of ejb.jar archives.
Where can / should I place my log4j.xml configuration file in my EAR in order to configure log4j for the different EJBs?
Here is my following structure:
myEar
|-- myEjb1.jar
|-- myEjb2.jar
|-- myEjb3.jar
|-- lib
| -- myLib1.jar
| -- myLib2.jar
Thanks in advance!
If log4j is used by different modules in the ear, it should be placed in a jar which is placed in the lib directory of the ear. But it is not very convenient since you will have to re-assemble your ear and redeploy it each time you change a log level.
Another option is to place the log4j config file in the folder and add that folder in the classpath of the ear. Most app server provides this feature (WebSphere for instance). It is less portable but more manageable: the config can be changed without redeploying the ear.
Let's straighten this out: there's only one log4j for your enterprise application, regardless of how many EJBs it consists of. Similarly, there's only one configuration file. If you need to configure it for different EJBs, your option is to use appropriately named loggers in EJB's code and manage them in one log4j.xml.
Laurent has some interesting advice on where to put it (+1).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With