logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Brodhead <...@black-ice.org>
Subject Re: no logging when running multiple threads
Date Fri, 18 Jan 2002 17:35:24 GMT

> When that code executes some logging output does not appear in the
> log files and on the console.  However, this only happens if I have
> multiple callbacks coming quickly one after the other.

Does logging *always* fail when you have multiple threads and *always*
succeed with a single thread?  Or does the behavior vary?  It is worth
running your code several times each way to verify this.

My first guess is that you have some sort of race condition in your
code that is exercised when you have multiple threads.  Debugging
multithreaded code can be tricky, and things can interact in ways that
you do not expect.

Think very carefully about what initialization your program must
perform and what order that initialization must occur in.  How can you
guarantee that the initialization happens in the correct order?  How
can you guarantee that certain initializations only happen once?

Another possibility is that some resource (such has your Log4j
categories) is being stored in a class variable which is then being
accessed by multiple threads and thus clobbered by one thread before
another thread tries to access it. 

To some extent, both problems come down to thread safety.

Too bad the problem in this case is with your logging output, as some
well placed logging statements would be a big help to troubleshoot
your problem.  When I was in the initial statges of getting Log4j to
work with my app I resorted to the dreaded System.out to good effect.

Hope this helps.  Please let us know what you discover.


To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>

View raw message