Log4j configuration in EAR

I have an EAR consisting of ejb.jar archives.

Where can I / place the log4j.xml configuration file in my EAR to configure log4j for different EJBs?

Here is my following structure:

myEar |-- myEjb1.jar |-- myEjb2.jar |-- myEjb3.jar |-- lib | -- myLib1.jar | -- myLib2.jar 

Thanks in advance!

+6
source share
2 answers

If log4j is used by various modules in the ear, it should be placed in a jar, which is placed in the ear lib directory. But this is not very convenient, since you will have to collect the ear and relocate it every time you change the level of the journal.

Another option is to put the log4j configuration file in a folder and add this folder to the ear class path. Most application servers provide this feature (for example, WebSphere). It is less portable, but more manageable: the configuration can be changed without reinstalling the ear.

+8
source

Align this: there is only one log4j for your enterprise application, no matter how much EJB it consists of. Similarly, there is only one configuration file. If you need to configure it for different EJBs, then you can use the appropriate log names in the EJB code and manage them in a single log4j.xml file.

Laurent has some interesting tips on where to put him (+1).

+5
source

Source: https://habr.com/ru/post/898526/


All Articles