0

After discussion here I still cannot configure my program/chainsaw

When I start ChainSaw I choose

  • let me use a simple Receiver on port 4445

And in my program i set configuration:

PropertyConfigurator.configure("log4j.properties");

And finally run program, and click Simple Receiver in Chainsaw

log4j.properties version1

log4j.rootLogger=DEBUG, server

log4j.appender.server=org.apache.log4j.net.SocketAppender
log4j.appender.server.Port=4445
log4j.appender.server.RemoteHost=localhost
log4j.appender.server.ReconnectionDelay=10000

log4j.properties version2

log4j.rootCategory=DEBUG, zeroconf, chainsaw
# Socket Appender
log4j.appender.chainsaw=org.apache.log4j.net.SocketAppender
log4j.appender.chainsaw.remoteHost=localhost
log4j.appender.chainsaw.port=4445
log4j.appender.chainsaw.locationInfo=true

none of them work. What should I do?

Community
  • 1
  • 1
alicjasalamon
  • 4,171
  • 15
  • 41
  • 65

2 Answers2

1

try:

log4j.threshold=ALL
log4j.debug = true
log4j.rootLogger=DEBUG, chainsaw
# Socket Appender
log4j.appender.chainsaw=org.apache.log4j.net.SocketAppender
log4j.appender.chainsaw.RemoteHost=localhost
log4j.appender.chainsaw.Port=4445
log4j.appender.chainsaw.LocationInfo=true

This is good example of chainsaw configuration which is also required:

http://magnus-k-karlsson.blogspot.com/2010/02/viewingmonitoring-your-log4j-generated.html

Edmon
  • 4,752
  • 4
  • 32
  • 42
  • Unfortunately I got `log4j:ERROR Could not find value for key log4j.appender.zeroconf log4j:ERROR Could not instantiate appender named "zeroconf".` – alicjasalamon Aug 03 '12 at 12:51
  • Take it out. It is not configured. – Edmon Aug 03 '12 at 12:51
  • What does log4j debug tells you, if anything? – Edmon Aug 03 '12 at 12:59
  • I have no idea how to check it. But if I have ChainSaw opened, a new tab should appear in it? I don't have anything like this. maybe the reason is that [Socket Receiver is inactive](http://stackoverflow.com/questions/11796027/why-is-socket-receiver-inactive-in-chainsaw)? – alicjasalamon Aug 03 '12 at 13:05
  • Did you, btw, configure chainsaw for Log4J ingest. – Edmon Aug 03 '12 at 13:05
  • Check that blog post I added to my answer. It is pretty recent. – Edmon Aug 03 '12 at 13:11
0

As of version 2.4, Log4j now supports configuration via properties files. Note that the property syntax is NOT the same as the syntax used in Log4j 1.

appender.server.type=Socket
appender.server.name=server
appender.server.port=4445
appender.server.host=localhost
appender.server.reconnectDelayMillis=10000

...

rootLogger.appenderRef.server.ref = server

You might have a problem with reconnectionDelayMillis. In logging-log4j-dev mailing list archives I found out that:

The documentation (https://logging.apache.org/log4j/2.x/manual/appenders.html#SyslogAppender) still has the parameter listed as "reconnectionDelayMillis" but the code is now obviously looking for "reconnectDelayMillis". I'm going to change my config to use the new name, but I thought I'd point out the disconnect as it had me confused for a bit. Thanks - Sam

This might be fixed/unified already, but I haven't checked that in the newer versions of log4j. If you encounter any problem try using reconnectDelayMillis.

More detailed example can be found under Configuration with Properties.

radzak
  • 2,986
  • 1
  • 18
  • 27