Highly appreciate one can help to answer my below questions.
1) if i deploy log4j lib at system classpath of app server, seemingly, i can only have a log4j configuration file and one log file for all apps deployed on the same app server, right ?
2) If i package the log4j in individual ear files. All ejb apps (ear) should have their own its instance of "Logger". Also, all apps can have its own separate log4j configuration file and log file, am i correct ? If so, where should i place the configuration file ? Should it be packaged in its own ear file ? Please tell me the solution !
For 2: you can package the log4j.properties file in a seperate jar file and keep the jar file as same level as your ejb and make a classpath entry in your ejb's manifest file for the properties jar file. Package jar's and war in ear file. Now both your ejb and web can access the same properties file.
Hope this helps,
thank u a lot for yr reply. How about Q1, do u have any feedback on my Q1 ? Once again, thank u for yr answer.
For 1, I think yes, but I am not 100% sure. I think having the log4j in app level may not be a good idea. This might help you: http://www.onjava.com/pub/a/onjava/2003/04/02/log4j_ejb.html
For question 1, of course not.
put log4j.jar on system class path only means that your app classloader can find log4j classes, which has nothing to do with log4j configuration.
of course, every app can have their own log4j configuration file, they can have different loggers and different appenders.
For Q2, put the configuration file(log4j.xml) in log4j.jar. and you may have a lib directory to put log4j.jar in it.
In this situation, the log4j.jar is loaded by app classloader and it can alse find log4j.xml.
thank u very much for yr reply on my Q1. But i am a bit unsure about yr answer. Because as log4j lib is put at system classpath, it will be loaded once by system class loader and shared by all app deployed on the app server. Also, log4j Logger is singleton as far as i know. Hence, for the whole JVM, any distinct Logger will be singleton shared among all app deployed on app servers which are loaded by app classs loader. Hence, i wonder the log4j will only be initialized once and only one log4j configuration file will be loaded.
log4j with classloader in wiki.ear not working (without classloader log4j is working)
with classloader i am getting one linkage error.
My application i sworking fine in both cases with or without classloader.
since many wiki sites have same class structure i used class loader.
But log4j which was working earlier suddenly got disabled.
even in server.log i am not getting simple logs for this wiki site what can be the reason.
please let me know.