0

Does anyone know what the proper way is to create a systemd service and read from syslog write the logs out to the network?

I had this in a service:

tail -f /var/log/syslog | send_logs_to_elasticsearch

but it the stdio from the send_logs_to_elasticsearch would be written to syslog, so it would have a horrible feedback loop. So I did this as a quick fix:

tail -f /var/log/syslog | send_logs_to_elasticsearch &> /dev/null

but in any case, does anyone have something that works as far as a process that can continuously read from syslog?

The service I have looks like:

[Unit]
Description=ES log capture
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=root
ExecStart=/home/ubuntu/repos/elastic-search-app/syslog-exec.sh

[Install]
WantedBy=multi-user.target

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.