Monitoring and logs
logger
Writes a line to the system log, with a tag, facility and severity of your choice.
logger does by hand what daemons do: it hands one line to the local syslog daemon (through /dev/log),
which files it and forwards it wherever its rules say. Use it to test a logging setup end to end: log a line on the
device, look for it on the collector. -p facility.severity sets the PRI, -t the tag.
logger command usage
logger [-t TAG] [-p FACILITY.SEVERITY] MESSAGE
Options
-
-t app - the tag: the program name shown before the message
-
-p local0.err - facility and severity (default user.notice)
-
-s - also print the line on standard error
logger examples
-
logger -t app 'order 1001 paid' - Logs one line tagged app, as user.notice.
-
logger -p auth.warning -t sshd 'Failed password for root' - Logs a line as facility auth, severity warning.
-
for level in debug info warning err; do logger -p daemon.$level "test $level"; done - Logs one line at each of four severities, to test a filter.
Pitfalls
- BusyBox's logger only writes to the local daemon: to reach a collector, that daemon must forward.
- The line is filed under the local host name; a collector shows it in that host's file.