You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by bu...@apache.org on 2006/11/17 09:35:08 UTC

DO NOT REPLY [Bug 40990] New: - Cannot bind port or ip address for outgoing UDP socket when using SysLogAppender

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: log4j-dev@logging.apache.org
        ReportedBy: cn.monkey.1125@gmail.com


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: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


DO NOT REPLY [Bug 40990] - Cannot bind port or ip address for outgoing UDP socket when using SysLogAppender

Posted by bu...@apache.org.
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


genman@noderunner.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED




------- Additional Comments From genman@noderunner.net  2007-01-28 04:29 -------
Agree this is important, especially with multi-homed machines.

-- 
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: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org