Bug 57002 - SocketAppender freezes for about 15 seconds if the server is not available
Summary: SocketAppender freezes for about 15 seconds if the server is not available
Status: NEW
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Appender (show other bugs)
Version: 1.2.17
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: log4j-dev
URL:
Keywords:
Depends on:
Blocks: 57062
  Show dependency tree
 
Reported: 2014-09-22 14:04 UTC by Aurelio Matsui
Modified: 2015-09-03 10:29 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aurelio Matsui 2014-09-22 14:04:00 UTC
I am using the SocketAppender to log the execution of scripts (short-lived Java applications that fire some actions and die a few seconds later). I log the activity of those scripts in files but I also want to send logs to Chainsaw, if there is a Chainsaw running.

The problem is that if there is no Chainsaw running, the SocketAppender takes some 15 seconds in the connect() method. The result is that my script takes 15 seconds waiting for a Chainsaw that does not exist and then some 4 seconds to actually run.

Debug showed that the SocketAppender is taking 10 seconds on address.getHostName(), in the following line:

http://grepcode.com/file/repo1.maven.org/maven2/log4j/log4j/1.2.17/org/apache/log4j/net/SocketAppender.java#230

This is just an error log and in this case I do not care about such error, since logs are already going to a FileAppender.

So my suggestion is that the SocketAppender should have a new property to turn off those error messages if they are not needed, as they may hurt performance.