+1 

Scott

-----Original Message-----
From: Paul Smith [mailto:[EMAIL PROTECTED]
Sent: Mon 11/5/2007 4:55 PM
To: Log4J Developers List
Subject: [PROPOSAL] SocketHubAppender change - allow auto port choice
 
I'd like to propose a change to SocketHubAppender code to allow it  
automatically choose a free port on the local host if the Port  
property is configured with 0.

This will allow the Zeroconf module to be more useful, and allow  
simpler configuration for multiple applications on the same host.  We  
have an open feature request (see [1]) to allow this, and the only  
simple way I can get this to work is to change SocketHubAppender (see  
attached patch).

In summary, I've moved the ServerSocket initialisation from the  
ServerMonitor.run() method to the ServerMonitor constructor, and when  
Port=0, check what port is actually configured, and modify the parent  
SocketHubAppender instance port variable so that getPort() exposes the  
real port in use.

Sub-classes can then inspect that property after the call to  
super.activateOptions().  This allows ZeroconfSocketHubAppender to  
broadcast the correct port in use (it would have broadcast 0 without  
this change; not very useful).

This doesn't appear to break any of the log4j unit tests, and I've  
added unit tests to the Zeroconf module (see second patch) that  
confirm behaviour.  I've also made the Zeroconf module aware of the  
fact that it might not be using an appropriate log4j version, given  
that this feature would/might only be present in log4j 1.2.16.  Prior  
versions of log4j will work fine still, but the automatic port  
configuration won't work (it throws an UnsupportedOperationException  
if it detects this).

cheers,

Paul

[1] http://issues.apache.org/bugzilla/show_bug.cgi?id=43295




<<winmail.dat>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to