Log4j multiple WAR files in single EAR configuration
Log4j multiple WAR files in single EAR configuration
Problem:
When you have multiple WAR files under the same EAR with multiple log4j config files in each of the war files, the logging API will pickup the first available config file and ignores the list. i.e, only a single log4j config file applies to entire EAR.
Consider the below app
app.ear
|__admin.war
|__WEB-INF/classes/log4.xml
|__web.war
|__WEB-INF/classes/log4j.xml
When you deploy this app to the server all logs of two war files admin.war and web.war will go to admin.war' log. The log4j.xml in web.war has no effect here.
There are some complex solutions for this like adding a logback, specifying package level log files in log4j configuration etc.
Solution
In your web.xml add the following context param will send the log4j config locations specific to the contexts and fixes this issue.
web.war/WEB-INF/classes/log4j.xml
<context-param> <param-name>log4jContextName</param-name> <param-value>web</param-value> <!-- here web is the context root for web.war --> </context-param>
The complete log4j configuration in web.xml for web.war will look something like below.
<!-- here spring listener is used, anything specific to frameworks in your app holds good --> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>classpath:/main/resources/log4j.xml</param-value> </context-param> <context-param> <param-name>log4jContextName</param-name> <param-value>web</param-value> </context-param>
It didnt work. After adding above solution all logging starts going inside web.war log file - Naveen
ReplyDeleteFantastic to read this blog. Thanks you so much for sharing this kind of article.
ReplyDeletePython Classes in Chennai
Python Classes Near Me
Best Python Training in Bangalore
This post is so interactive and informative.keep updating more information...
ReplyDeleteETL tools
Python
valuable blog,Informative content...thanks for sharing, Waiting for the next update…
ReplyDeleteHow Does Flutter Work
What is google flutter?
valuable blog,Informative content...thanks for sharing, Waiting for the next update...
ReplyDeleteDifferent Types of Protocols
Different types of network protocols
Useful blog, keep sharing with us.
ReplyDeleteHow Does Google Flutter Work
Why Google Flutter
mmorpg oyunlar
ReplyDeleteinstagram takipçi satın al
tiktok jeton hilesi
tiktok jeton hilesi
saç ekimi antalya
İnstagram Takipci Satın Al
İnstagram Takipçi Satın Al
metin2 pvp serverlar
instagram takipçi satın al
Thanks for this content, it is very informative.
ReplyDeleteAndroid App Development Using Flutter
Flutter for Mobile App Development
smm panel
ReplyDeletesmm panel
iş ilanları
instagram takipçi satın al
hirdavatciburada.com
beyazesyateknikservisi.com.tr
Servis
JETON HİLE İNDİR
sultangazi
ReplyDeleteordu
mardin
bodrum
sincan
3BCK
yurtdışı kargo
ReplyDeleteresimli magnet
instagram takipçi satın al
yurtdışı kargo
sms onay
dijital kartvizit
dijital kartvizit
https://nobetci-eczane.org/
1GCN
salt likit
ReplyDeletesalt likit
dr mood likit
big boss likit
dl likit
dark likit
LEQNG