logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amit Oberoi" <aobe...@TechMahindra.com>
Subject Error with SocketHubAppender
Date Mon, 28 Mar 2011 12:56:50 GMT
Hi,

 

I am new to Log4J and trying to configure my Unit tests with a
SocketHubAppender. My problem is that while executing my tests though I
am able to receive logs on Chainsaw I am getting below errors for each
test case. Can anyone suggest how to avoid this.

 

log4j:ERROR exception setting timeout, shutting down server socket.

java.net.SocketException: Unrecognized Windows Sockets error: 0:
JVM_Bind

        at java.net.PlainSocketImpl.socketBind(Native Method)

        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)

        at java.net.ServerSocket.bind(ServerSocket.java:319)

        at java.net.ServerSocket.<init>(ServerSocket.java:185)

        at java.net.ServerSocket.<init>(ServerSocket.java:97)

        at
org.apache.log4j.net.SocketHubAppender$ServerMonitor.run(SocketHubAppend
er.java:324)

        at java.lang.Thread.run(Thread.java:619)

log4j:ERROR exception setting timeout, shutting down server socket.

java.net.SocketException: Unrecognized Windows Sockets error: 0:
JVM_Bind

        at java.net.PlainSocketImpl.socketBind(Native Method)

        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)

        at java.net.ServerSocket.bind(ServerSocket.java:319)

        at java.net.ServerSocket.<init>(ServerSocket.java:185)

        at java.net.ServerSocket.<init>(ServerSocket.java:97)

        at
org.apache.log4j.net.SocketHubAppender$ServerMonitor.run(SocketHubAppend
er.java:324)

        at java.lang.Thread.run(Thread.java:619)

log4j:ERROR exception setting timeout, shutting down server socket.

java.net.SocketException: Unrecognized Windows Sockets error: 0:
JVM_Bind

        at java.net.PlainSocketImpl.socketBind(Native Method)

        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)

        at java.net.ServerSocket.bind(ServerSocket.java:319)

        at java.net.ServerSocket.<init>(ServerSocket.java:185)

        at java.net.ServerSocket.<init>(ServerSocket.java:97)

        at
org.apache.log4j.net.SocketHubAppender$ServerMonitor.run(SocketHubAppend
er.java:324)

        at java.lang.Thread.run(Thread.java:619)

log4j:ERROR exception setting timeout, shutting down server socket.

java.net.SocketException: Unrecognized Windows Sockets error: 0:
JVM_Bind

        at java.net.PlainSocketImpl.socketBind(Native Method)

        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)

        at java.net.ServerSocket.bind(ServerSocket.java:319)

        at java.net.ServerSocket.<init>(ServerSocket.java:185)

        at java.net.ServerSocket.<init>(ServerSocket.java:97)

        at
org.apache.log4j.net.SocketHubAppender$ServerMonitor.run(SocketHubAppend
er.java:324)

        at java.lang.Thread.run(Thread.java:619)

log4j:ERROR exception setting timeout, shutting down server socket.

java.net.SocketException: Unrecognized Windows Sockets error: 0:
JVM_Bind

        at java.net.PlainSocketImpl.socketBind(Native Method)

        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)

        at java.net.ServerSocket.bind(ServerSocket.java:319)

        at java.net.ServerSocket.<init>(ServerSocket.java:185)

        at java.net.ServerSocket.<init>(ServerSocket.java:97)

        at
org.apache.log4j.net.SocketHubAppender$ServerMonitor.run(SocketHubAppend
er.java:324)

        at java.lang.Thread.run(Thread.java:619)

log4j:WARN No appenders could be found for logger (com.btw).

log4j:WARN Please initialize the log4j system properly.

log4j:ERROR exception setting timeout, shutting down server socket.

java.net.SocketException: Unrecognized Windows Sockets error: 0:
JVM_Bind

        at java.net.PlainSocketImpl.socketBind(Native Method)

        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)

        at java.net.ServerSocket.bind(ServerSocket.java:319)

        at java.net.ServerSocket.<init>(ServerSocket.java:185)

        at java.net.ServerSocket.<init>(ServerSocket.java:97)

        at
org.apache.log4j.net.SocketHubAppender$ServerMonitor.run(SocketHubAppend
er.java:324)

        at java.lang.Thread.run(Thread.java:619)

 

 

I am using the below code to instantiate the logger.

 

public class TestLogger {

 

    private Logger log;

    private FileAppender appender;

    private ConsoleAppender console;

    private SocketHubAppender socket;

    private HTMLLayout layout;

    private PatternLayout pat;

 

 

    public TestLogger(Class clazz) {

        

        String pattern = "%d{dd MMM yyy HH:mm:ss, SSS} - %m%n";

 

        try {

            Logger.getRootLogger().setLevel(Level.OFF);

            Logger.getLogger("com.btw").setLevel(Level.INFO);

            

 

            log = Logger.getLogger(clazz);

            log.setAdditivity(false);

 

            layout = new HTMLLayout();

            layout.setTitle("Log for " + clazz.getSimpleName());

            appender = new FileAppender(layout,
System.getProperty("user.dir") + "\\" + clazz.getSimpleName() +
".html");

            log.addAppender(appender);

 

            

            pat = new PatternLayout(pattern);

            console = new ConsoleAppender(pat);

            log.addAppender(console);

 

            socket = new SocketHubAppender(4555);

            socket.setLocationInfo(true);

            log.addAppender(socket);

        }

        catch(Exception e) {

            e.printStackTrace();

        }

    }

 

    public Logger getLogger() {

        return log;

    }

}

 

 

 

Regards

 

Amit Oberoi

 


============================================================================================================================Disclaimer:
 This message and the information contained herein is proprietary and confidential and subject
to the Tech Mahindra policy statement, you may review the policy at <a href="http://www.techmahindra.com/Disclaimer.html">http://www.techmahindra.com/Disclaimer.html</a>
externally and <a href="http://tim.techmahindra.com/Disclaimer.html">http://tim.techmahindra.com/Disclaimer.html</a>
internally within Tech Mahindra.============================================================================================================================

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message