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 con开发者_C百科sidered that to be the only thing about log4j that is worse than other logging alternatives.
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.
精彩评论