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 email@example.com 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.
Joined: Nov 23, 2006
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
Joined: Oct 10, 2000
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com