java - What's the correct way to aggregate Jboss logs in a clustered environment? -
we using jboss 7.4.0 2 nodes each have own rolling file appenders. redirect these 2 outputs in unique file, "outside" both jboss nodes. tried use socketappenders, manually started log4j server, doesn't work...
<custom-handler name="socket" class="org.apache.log4j.net.socketappender" module="org.apache.log4j"> <level name="debug"/> <formatter> <pattern-formatter pattern="%d{hh:mm:ss,sss} %-5p %x{user} %x{app} [%c:%m:%l] (%t) %s%e%n"/> </formatter> <properties> <property name="port" value="4712"/> <property name="remotehost" value="127.0.0.1"/> </properties>
the things in log4j server :
[2015-04-01 10:31:24,969] [main] [listening on port 4712] [2015-04-01 10:31:24,981] [main] [waiting accept new client.]
i've read socketappender doens't exists anymore in jboss 7+, honest, jboss documentation incomplete, missing, or incorrect @ best.
so, what's correct (or best) way this, without reinventing wheel? should use asynchronous rolling file appenders? there other alternatives?
follow these steps use correctly might solve problem..
1> first create log4j-server.properties
log4j.rootlogger=debug, file log4j.appender.file=org.apache.log4j.rollingfileappender log4j.appender.file.file=logfile.log log4j.appender.file.maxfilesize=1mb log4j.appender.file.maxbackupindex=1 log4j.appender.file.layout=org.apache.log4j.patternlayout log4j.appender.file.layout.conversionpattern=[%d] [%t] [%m]%n
2> run following command @ reciever side
java -classpath log4j.jar org.apache.log4j.net.simplesocketserver 4712 log4j-server.properties
now listen port 4712
, store logs in logfile.log
have defined in log4j-server.properties
file
3>in log4j.xml file add following appender send logs server specified port.
<custom-handler name="socket" class="org.apache.log4j.net.socketappender" module="org.apache.log4j"> <level name="debug"/> <properties> <property name="port" value="4712"/> <property name="remotehost" value="127.0.0.1"/> </properties>
do not specify formatter in configurations. , not forget add socket
in root-logger
of log4j.xml
Comments
Post a Comment