Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Log4J LogManager

Reply
Thread Tools

Log4J LogManager

 
 
WJ
Guest
Posts: n/a
 
      05-19-2004
I can't find a group that's more dedicated to log4j. If there's one, I'd
appreciate the name.

Our app server has several web apps running on it. We'd like to deploy
log4j in all of them. However, we're running into an issue.

We put the log4j jar file in the common lib dir that all apps access.

Each app can add loggers and appenders dynamically and set the threshold.
This is done by reading values dynamically out of a
database. When a "refresh" method is called, it iterates through the
loggers, removes existing appenders and re-creates them.

I did this because I typically have the level set to error and fatal for the
console and rolling file. But if there's an issue, I'll drop
the level down to debug for a certain package only. Also, I only want that
to go into a rolling file, not the console.

I iterate through the loggers like this:

for(Enumeration
enum=Logger.getRoot().getLoggerRepository().getCur rentLoggers();
enum.hasMoreElements()

Then I iterate through each appender on that logger and remove the appender.
Everything works great.

Except:

The LogManager seems to span applications. So if App A and App B both use
this technique, they are resetting each other's loggers.

I've done a lot of reading and two work arounds seem to be in place.

1. I put the log4j.jar in the local lib for each app. I really don't want
to do this, but it may be the only answer thus far.

2. I create a ContextualLoggerRepository and set it like
LogManager.setRepositorySelector(new ContextualLoggerRepository(), guard);

where the guard is just a simple obj. The problem with this is if App A
runs this, and App B tries to reset it's loggers, I get an error saying
App B tried to reset the loggers without possessing the guard.

Is there a way that will force a "local" LogManager for each application?
Is there a site that has some write ups on this? I've read most of the
returns from google.

Thanks in advance.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with using org.apache.log4j pakages (LogManager) spiderboy Java 2 06-29-2007 10:43 PM
Using log4j with Tomcat 4.1.30 problems with log4j.properties Rodolfo Java 0 07-12-2004 08:56 AM
log4j: locating log4j.proprties in same folder as jar Alex Hunsley Java 2 05-28-2004 09:57 PM
Newbie ... can't find Java.util.logging.LogManager addGlobalHandler Colin Foulkes Java 2 01-29-2004 02:42 PM
eclipse, junit, log4j, & finding log4j.xml Alexandra Stehman Java 0 01-19-2004 03:25 PM



Advertisments