I have long wondered why log4j defaults to outputting an error message when there is no log4j.properties. A reasonable default to stdout or stderr would make more sense. Is there a FAQ or a discussion about this somewhere that indicates the reasoning behind this decision? I have always considered that to be the only thing about log4j that is worse than other logging alternatives.
views:
45answers:
1
A:
Let's say that you use log4j in a program where fds 0, 1, and 2 are either closed (which would cause write(2) to fail with EBADF) or redirected to /dev/null. Then log4j tries to output a log message. What would happen in this situation? You'd have a silent failure, which is something you'd want to avoid having happen in a logging library at all costs.
Jesse Kempf
2010-01-21 01:15:47
That's certainly a valid concern, but isn't the "No appenders" message output to stderr? It would be silent regardless of whether the no appenders message or the actual error was sent to stderr.
HappyEngineer
2010-01-21 19:55:19