http://stackoverflow.com/questions/15381559/easiest-way-to-send-files-to-a-server/15382152#15382152
In your server you can just start server with the following parameters:
java -cp log4j.jar org.apache.log4j.net.SimpleSocketServer 4712
Here is sample
log4j.properties
for the server:
log4j.rootLogger=debug, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
Here is sample
log4j.properties
for the client:
log4j.appender.SERVER=org.apache.log4j.net.SocketAppender log4j.appender.SERVER.Port=4712 log4j.appender.SERVER.RemoteHost=loghost log4j.appender.SERVER.ReconnectionDelay=10000
2. Using Linux / Ubuntu rsyslog
http://www.rsyslog.com/doc/master/configuration/modules/imudp.html
Step 1 vi /etc/rsyslog.conf
= = = = = = = Enable UDP (Tested not working) = = = = = = =
# specific ruleset for remote messages
$Ruleset udpremote
*.* /var/log/updremote.log
# switch back to default ruleset
$Ruleset RSYSLOG_DefaultRuleset
# provides UDP syslog reception
$ModLoad imudp
$InputUDPServerBindRuleset udpremote
$UDPServerRun 514
= = = = = = = Enable TCP = = = = = = =
# specific ruleset for remote messages
$Ruleset tcpremote
*.* /var/log/tcpremote.log
# switch back to default ruleset
$Ruleset RSYSLOG_DefaultRuleset
# provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerBindRuleset tcpremote
$InputTCPServerRun 10514
Step 2 service rsyslog restart
Here is sample
log4j.properties
for the client:
log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender log4j.appender.SYSLOG.SyslogHost=localhost log4j.appender.SYSLOG.Facility=Local2 log4j.appender.SYSLOG.Header=true log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout log4j.appender.SYSLOG.layout.ConversionPattern=[%X{ref}] %-5p %C{1}:%L %m%n
No comments:
Post a Comment