0

We are using log4j for application logging and maven for application packaging. As we have 3-4 application being deployed as a part of an EAR the size of the EAR is large. We were trying to go with the 'Skinny War's' approach but faced a problem with log4j. We used to log application logs in different file for each application but with Skinny WAR's as the classes of log4j are being loaded only once, only one log file is being created and log of each application is being appended to the same log file.

We thought of the famous solution of packaging log4j.jar in each WAR but then we'll have to move every jar file which needs the log4j in WAR ex. spring jar's this essentially will increase the EAR size.

Is there any alternate solution to this problem ? Any suggestion would be a great help.

Thanks.

user765635
  • 568
  • 4
  • 11

2 Answers2

0

see if log4j 1.3 / log4j2 helps you fix the init - google ContextJNDISelector

http://logging.apache.org/log4j/2.x/manual/webapp.html

To compare

logback - JoranConfigurator it does exactly that, custom context based config

http://logback.qos.ch/manual/configuration.html

Kalpesh Soni
  • 6,879
  • 2
  • 56
  • 59
  • We can not use the said version of log4j as few applications we have integrated with are dependent of older version of the lib., Thanks anyways ! – user765635 May 12 '14 at 10:20
  • if you load log4j at ear level, basically there is only one classloader loading log4j classes, if it finds log4j.xml in classpath it will init only once, if thats not something you like, you could init it more than once - configureandwatch api comes to mind, also see http://www.certpal.com/blogs/2010/05/how-to-configure-log4j-for-a-web-app/ - challenge would be to keep the appenders and handlers separate in memory for different wars, if you are using same class(say some kind of framework) in different web apps, may have to create category in unique way, something more than package and class – Kalpesh Soni May 12 '14 at 16:47
0

Resolved the issue with RepositorySelectors. Check this

user765635
  • 568
  • 4
  • 11