logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amit Oberoi" <aobe...@TechMahindra.com>
Subject RE: Error with SocketHubAppender
Date Tue, 29 Mar 2011 05:37:46 GMT
Scott,

 

Many thanks for your prompt response.

 

I tired setting the activateOptions however the problem still persists.

 

I agree that the best way to configure Log4J is to have configuration
file however I have requirement to capture logs on per class basis. Is
there anyway we can set the FileAppender log file name programmatically
where-in putting the remaining configurations in the configuration file.

 

Thanks

 

Amit Oberoi

 

 

-----Original Message-----
From: Scott Deboy [mailto:scott.deboy@gmail.com] 
Sent: Monday, March 28, 2011 7:15 PM
To: Log4J Users List
Cc: <log4j-user@logging.apache.org>
Subject: Re: Error with SocketHubAppender

 

If you must configure log4j programmatically, I believe you need to  

call activateOptions in each appender.

 

Can you configure log4j using a config file instead?

 

Scott

 

 

 

On Mar 28, 2011, at 5:56 AM, "Amit Oberoi" <aoberoi@TechMahindra.com>  

wrote:

 

> 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.techmahind
ra.com/Disclaimer.html 

> </a> internally within Tech  

> Mahindra. 

> === 

> === 

> === 

> === 

> === 

> === 

> === 

> === 

> === 

> === 

> === 

> === 

> === 

> === 

> === 

> === 

> === 

> === 

> ======================================================================

 

---------------------------------------------------------------------

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org

For additional commands, e-mail: log4j-user-help@logging.apache.org

 


============================================================================================================================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