I want to forward logs from a local machine to a distant server. Thanks to an SSH tunnel, the distant server is reachable through localhost:5514. I wrote the following conf:
# Filters
filter f_local0 { facility(local0); };
filter f_worker { program("^worker."); };
# Destinations
destination d_log01_local { file("/home/myuser/logs/worker/$YEAR$MONTH$DAY/$PROGRAM.$YEAR$MONTH$DAY" template("$HOST $MSG\n") create_dirs(yes) dir_group("adm") group("adm") dir_perm(0770) perm(0644) ); };
destination d_log01_remote { network("localhost" transport(tcp) port(5514) persist-name("remote_worker") disk-buffer( reliable(yes) disk-buf-size(50000000) )); };
# Logs
log { source(s_src); filter(f_local0); filter(f_worker); destination(d_log01_local); };
log { source(s_src); filter(f_local0); filter(f_worker); destination(d_log01_remote); };
The local destination works perfectly but the remote one does not: I do not receive any logs on the server located at localhost:5514.
When I tail -f /var/log/syslog
, syslog logs these lines:
Oct 22 11:25:05 esad-10076 syslog-ng[17319]: Syslog connection established; fd='35', server='AF_INET(127.0.0.1:5514)', local='AF_INET(0.0.0.0:0)'
Oct 22 11:25:05 esad-10076 syslog-ng[17319]: EOF occurred while idle; fd='35'
Oct 22 11:25:05 esad-10076 syslog-ng[17319]: Syslog connection broken; fd='35', server='AF_INET(127.0.0.1:5514)', time_reopen='60'
I don't understand the error nor do I know how to fix it.
I should specify that before writing this conf, I had another conf that used syslog
instead of network
and this conf works perfectly. I just need to use network now to use the power of reliable
in order to not lose any logs in case of network outage.
# Filters
filter f_local0 { facility(local0); };
filter f_worker { program("^worker."); };
# Destinations
destination d_log01_local { file("/home/myuser/logs/worker/$YEAR$MONTH$DAY/$PROGRAM.$YEAR$MONTH$DAY" template("$HOST $MSG\n") create_dirs(yes) dir_group("adm") group("adm") dir_perm(0770) perm(0644) ); };
destination d_log01_remote { syslog("localhost" transport(tcp) port(5514) persist-name("remote_worker")); };
# Logs
log { source(s_src); filter(f_local0); filter(f_worker); destination(d_log01_local); };
log { source(s_src); filter(f_local0); filter(f_worker); destination(d_log01_remote); };