DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15599>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15599 SocketAppender ignores ReconnectionDelay of 0 (with fix) Summary: SocketAppender ignores ReconnectionDelay of 0 (with fix) Product: Log4j Version: 1.2 Platform: All OS/Version: All Status: NEW Severity: Normal Priority: Other Component: Appender AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] If you set the ReconnectionDelay of a SocketAppender to zero, it is supposed to not retry when it fails to connect. If it successfully connects the first time, it honors the zero setting (with a test in SocketAppender.java append(LoggingEvent event)). However, if it fails to connect the first time, it will try to connect an infinite number of times, with no delay between tries. The reason is that there's no test for a zero setting in SocketAppender.java connect() before calling fireConnector(). I have a proposed fix for this bug, and it includes two minor enhancements: 1) If ReconnectionDelay is zero, the message won't say that it "will try again later'. 2) If ReconnectionDelay is zero, it does not output the lengthy exception that you get if it can't connect. The rationale for this second improvement is that we use ReconnectionDelay of zero when we are testing on our development machines. If we are running chainsaw, we want to see the logging info in chainsaw. However, if chainsaw isn't running, we'd like it to fail with a brief message instead of the lengthy exception to the console. Setting ReconnectionDelay of zero strongly implies that "it's not that important" if it gets a connection, or tries to bring it back up, so I don't think I'm creating too much controversy with that change. Further, there are probably not too many people setting it to zero because nobody reported this bug yet. :) Here's my proposed replacement: void connect(InetAddress address, int port) { if(this.address == null) return; try { // First, close the previous connection if any. cleanUp(); oos = new ObjectOutputStream(new Socket(address, port).getOutputStream()); } catch(IOException e) { String msg = "Could not connect to remote log4j server at [" +address.getHostName()+"]."; if(reconnectionDelay > 0) { msg += " We will try again later."; LogLog.error(msg, e); } else { LogLog.error(msg); } if(reconnectionDelay > 0) { fireConnector(); } } } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
