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.

Advertisements

2 thoughts on “Short Tip: Write to syslog”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s