Discussion:
Log4j in Weblogic
(too old to reply)
s***@gmail.com
2006-07-27 00:26:30 UTC
Permalink
I stuck with a problem here. I have an ear and log4j implemenataion in
this application. I have a log4j.props file placed in the EAR ann this
works fine. Now my problem here is, i need to redeploy the ear
everytime i need to change my logging levels. Is there anything that is
possible so that i need not to stop the application and redeploy it
just to change the logging level. Please help me with this. Where do i
need to put my log4j.props file so that the application picks up the
same and i can change the logging level without to redeploy the
application.
s***@gmail.com
2006-08-04 15:53:10 UTC
Permalink
Post by s***@gmail.com
I stuck with a problem here. I have an ear and log4j implemenataion in
this application. I have a log4j.props file placed in the EAR ann this
works fine. Now my problem here is, i need to redeploy the ear
everytime i need to change my logging levels. Is there anything that is
possible so that i need not to stop the application and redeploy it
just to change the logging level. Please help me with this. Where do i
need to put my log4j.props file so that the application picks up the
same and i can change the logging level without to redeploy the
application.
I'm pleased you're putting the log4j lib in the .ear - does not bind
all applications on the server to the same log4j version level...

Possible solutions my friend...

1) Don't put the log4j.properties in the .ear - but put it somewhere in
the weblogic server classpath (maybe the weblogic startup directory).
Restart the server and you're off at changed debug level.

2) if you specify a refresh interval for log4j in its configuration
(never really used it - but read about it), it might be able to pick on
changes itself...

3) Another - better - solution, dynamically initialize your log4j
logger inside your code... Every time you redeploy the code or
otherwise activates the dynamic log4j initializing code, you should be
running at appropriate debug level.

...but... remember to tidy up things before production... :)

An example of dynamically init of log4j could be...

import org.apache.log4j.Category;
import org.apache.log4j.PropertyConfigurator;
...
private void initializeLogger()
{
Properties logProperties = new Properties();

try
{
logProperties.load(new
FileInputStream("c:\development\applicationdir\log4j.properties"));
PropertyConfigurator.configure(logProperties);
log.info("Logging initialized...");
}
catch(IOException e) { e.printStackTrace(); }
}


I'm sure other people can suggest even better alternatives. But this
should give you a few thoughts. Hope it helps...

/www.seniorconsultant.co.uk

Loading...