This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
No. log4j is not reliable. It is a best-effort fail-stop logging system.
By fail-stop, we mean that log4j will not throw unexpected exceptions at run-time potentially causing your application to crash. If for any reason, log4j throws an uncaught exception, please send an email to the log4j-user@logging.apache.org mailing list. Uncaught exceptions are handled as serious bugs requiring immediate attention.
Moreover, log4j will not revert to System.out or System.err when its designated output stream is not opened, is not writable or becomes full. This avoids corrupting an otherwise working program by flooding the user's terminal because logging fails. However, log4j will output a single message to System.err indicating that logging can not be performed.
Cemil Ozdemir
Greenhorn
Joined: Nov 23, 2006
Posts: 11
posted
0
Hi Carol,
Thanks for the answer.
But even though log4j, is not meant for archiving, we have decided to use it any way(with the consequences in mind).
But i was looking for an answer for this:
Let us say i have two appenders, X and Y defined in my log4j properties file.
Then in my code i log to the file this way: private static final Logger log = Logger.getLogger(MyClass.class); ... log.debug("test");
Now how can i distinct in my code which appendar/file i am writing to ?
Maybe it is a silly question but i am not that familiar with log4j.
Best Regards Cemil �zdemir
Carol Enderlin
drifter
Ranch Hand
Joined: Oct 10, 2000
Posts: 1348
posted
0
Probably the easiest way is to associate the different appenders with different loggers.
If it is done in the same class then you'll need to create a second logger in that class with a different name. e.g., either something like "archive" or "archive." + class.getName() ; then associate the archive appender with the "archive" logger.
If they are not in the same class, then what part are you having trouble with? Show properties file and be specific about what help you need.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.