2020年4月29日

syslogd: logging different device's log to different files on windows

Most of the syslog server (syslogd) on Widows cannot change the default listening port number (udp 514). 
If there are may devices remote syslog to a syslog server with dynamic ip address, without correct host name, it may not able to know which log belongs to which device. 





One simple way is to run multiple syslogd with different port number, and log to different log file. So each device has its own log file. 
I found that syslog4j already implement syslog server with configurable port number and log file name:

Usage:

SyslogServer [-h <host>] [-p <port>] [-o <file>] [-a] [-q] <protocol>

-h <host>    host or IP to bind
-p <port>    port to bind
-t <timeout> socket timeout (in milliseconds)
-o <file>    file to write entries (overwrites by default)

-a           append to file (instead of overwrite)
-q           do not write anything to standard out

protocol     Syslog4j protocol implementation (tcp, udp, ...)

Example:
Run sysylogd on port 514 and log to log1.txt
# java -cp syslog4j.jar org.productivity.java.syslog4j.server.SyslogServer -p 514 -o log1.txt -a -q udp
Run sysylogd on port 515 and log to log2.txt
# java -cp syslog4j.jar org.productivity.java.syslog4j.server.SyslogServer -p 515 -o log2.txt -a -q udp

You can run many syslogd as long as port number is different. 


沒有留言:

coap-client 4.3.0 Windows build

coap-client  is a  wget -like tool to generate simple requests for retrieval and modification of resources on a remote server.  Got the sour...