How should log4j.properties look like?
-
24-06-2021 - |
Domanda
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?
Soluzione
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
Altri suggerimenti
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.