Short Tip: Write to syslog

shell.png
If you need to write something to syslog, Linux’ system logfile, you can do this by using logger:

logger Ready for xyz test

To check the result, run cat /var/log/messages:

Sep 17 17:14:48 localhost liquidat: Ready for xyz test

As you see the date, time and username are also included. In case you do this as root, the username will become logger.

Among the possible options of logger there are these two: -f will take a file as input instead of a message. The file content is parsed to the syslog entirely, so be easy on big files. The other one is -s: with that option the message will not only be posted to syslog but also to standard error.

2 thoughts on “Short Tip: Write to syslog”

Comments are closed.