You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Rajnish Bansal <ra...@aplion.stpn.soft.net> on 2001/08/27 12:55:01 UTC

Newbie question: How to choose appenders dynamically?

Hi,

I want to we able to set log4j configuration externally (using
property file) such that if there is a problem in using a 
particular specified appender, an alternate appender is enabled 
automatically. I believe I might be able to do this programmatically 
using log4j APIs, but I am more interested in knowing whether 
some mechanism exists to achieve this thru a property file.

The scenario I have is that by default I want to send all 
my logs to a remote "SocketServer" based log4j server (using 
SocketAppender). However, if log4j server is not available, I 
want to be able to print my logs onto the local process's 
console. Please note that I want to do this only in a situation 
when remote log4j server is not reachable to SocketAppender. 
Obviously, if I were to configure both appenders (Console and 
Socket appender) in my property file in a normal fashion, I would
be always getting the messages on local process's console 
irrespective of whether or not messages are getting logged 
on remote log4j server.

Would appreciate ideas/suggestions.

Thanks,
Rajnish

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


SocketAppenders

Posted by Ganapathi Raman <ma...@yahoo.com>.
Hi...

I posted this Q last week but think it was lost...can
anyone please...


This is regarding socket appenders in general.

I am having an application that logs messages thru a
SocketAppender. I am using log4j's ServerSocket app as
a listener to receive the messages over the network
and log them. My question is that sometimes(only
sometimes and not all the time) i lose my
messages when at the server end (SocketServer) i get
error messages as :


20   [main] ERROR org.apache.log4j.net.SocketNode  -
Could not open ObjectInputStream to
Socket[addr=localhost/127.0.0.1,port=1638,localport=20200]
java.net.SocketException: Connection reset by peer:
JVM_recv in socket input stream read
        at
java.net.SocketInputStream.socketRead(Native Method)
        at
java.net.SocketInputStream.read(SocketInputStream.java:90)
        at
java.net.SocketInputStream.read(SocketInputStream.java:106)
        at
java.io.ObjectInputStream.read(ObjectInputStream.java:1387)
        at
java.io.DataInputStream.readShort(DataInputStream.java:268)
        at
java.io.ObjectInputStream.readShort(ObjectInputStream.java:1556)
        at
java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:724)
        at
java.io.ObjectInputStream.<init>(ObjectInputStream.java:165)
        at
org.apache.log4j.net.SocketNode.<init>(SocketNode.java:52)
        at
org.apache.log4j.net.SocketServer.main(SocketServer.java,
Compiled Code)
40   [Thread-0] ERROR org.apache.log4j.net.SocketNode 
- Unexpected exception. Closing conneciton.
java.lang.NullPointerException
        at
org.apache.log4j.net.SocketNode.run(SocketNode.java,
Compiled Code)
        at java.lang.Thread.run(Thread.java:479)



I tried several times and am not able to get a pattern
that generated the error. Is it an error in the
network or am i screwing something up?

Can anyone help me??

Regards,
Ganapathi.


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org