ยง2024-05-30
This is mine /etc/syslog-ng/syslog-ng.conf
@version: 4.6
@include "scl.conf"
options {
keep-hostname(yes);
};
# Sources
source s_mongo_log {
file("/opt/package/mongoDB/log/mongod.log" flags(no-parse));
};
# Destination
destination d_mongoDB {
syslog("hc4Jammy.yushei.net" transport("udp") port(514));
};
# Log Statements
log {
source(s_mongo_log);
# parser {
# json-parser(prefix("json."));
# };
destination(d_mongoDB);
};
How to enable the syslog-ng service
- /usr/lib/systemd/system/syslog-ng\@.service
[Unit] Description=System Logger Daemon "%i" instance Documentation=man:syslog-ng(8) Conflicts=emergency.service emergency.target Wants=network.target network-online.target After=network.target network-online.target
[Service] Type=notify EnvironmentFile=-/etc/default/syslog-ng@%i EnvironmentFile=-/etc/sysconfig/syslog-ng@%i ExecStart=/usr/bin/syslog-ng -F $OTHER_OPTIONS --cfgfile $CONFIG_FILE --control $CONTROL_FILE --persist-file $PERSIST_FILE --pidfile $PID_FILE ExecReload=/usr/bin/kill -HUP $MAINPID StandardOutput=journal StandardError=journal Restart=on-failure
[Install] DefaultInstance=default WantedBy=multi-user.target