DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40990>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40990

           Summary: Cannot bind port or ip address for outgoing UDP socket
                    when using SysLogAppender
           Product: Log4j
           Version: 1.2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Keywords: JDK1.5
          Severity: normal
          Priority: P2
         Component: Appender
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


I am currently using Log4J with SysLogAppender with the following 
configuration file:

The configuration file I used included the following:
----------------------------------------------------------
log4j.appender.syslog2=org.apache.log4j.net.SyslogAppender
log4j.appender.syslog2.SyslogHost=localhost
log4j.appender.syslog2.Facility=local2
log4j.appender.syslog2.layout=org.apache.log4j.PatternLayout
log4j.appender.syslog2.layout.ConversionPattern=%p  (%L) -%m%n
log4j.rootLogger=DEBUG, syslog2
----------------------------------------------------------

I noticed that a random UDP port is being opened by the Java application as 
shown:

---------------------------------------------------------------------------
linux:~ # netstat -lpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address   Foreign Address  State PID/Program name
udp        0      0 127.0.0.1:514   0.0.0.0:*              15994/syslog-ng
udp        0      0 :::21457        :::*                   1364/java
---------------------------------------------------------------------------

For security purposes, I would like to be able to bind this socket to a 
configurable port and ip address. 

I am currently using 1.2.14. Looking at the source code, I noticed that the 
SysLogWriter currently uses the default constructor DatagramSocket() which 
assigns a random port number and is bounded to a wildcard address.

SysLogWriter.java (line 100 - 107):

    try {
      this.ds = new DatagramSocket();
    }
    catch (SocketException e) {
      e.printStackTrace(); 
      LogLog.error("Could not instantiate DatagramSocket to " + host +
                         ". All logging will FAIL.", e);
    }

I suggest that a fix should be implemented to use a parameterized constructor 
instead such that users may set configurations such that the socket can be 
bounded to a user-defined port and/or local address.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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

Reply via email to