Record entries in log files with logger


Call me Mr. Obvious on this one, but I actually always need to check out the manpage for this…

If you want to record entries in logs file :

Example here in daemon.log

$ sudo logger -p daemon.warn "This is a test"

Where daemon is the facility, warn is the level

Hit Ctrl+C when done.

Result in /var/log/daemon.log : Aug 20 13:07:16 hostname user: "This is a test"

Check /etc/syslog.conf to know the facilities :

auth,authpriv.* /var/log/auth.log .;auth,authpriv.none -/var/log/syslog #cron.* /var/log/cron.log daemon.* -/var/log/daemon.log kern.* -/var/log/kern.log lpr.* -/var/log/lpr.log mail.* -/var/log/mail.log user.* -/var/log/user.log

This morning I was asked on launchpad to send the content of daemon.log after a reboot.. I used logger to mark when I was about to reboot, and when the machine was back up. It allowed me to cut the interesting snippet out of the whole log easily.

Thanks for reading this post!

Did you find an issue in this article?

- click on the following Github link
- log into Github with your account
- click on the line number containing the error
- click on the "..." button
- choose "Reference in new issue"
- add a title and your comment
- click "Submit new issue"

Your feedback is much appreciated! πŸ€œπŸΌπŸ€›πŸΌ

You can also drop me a line below!