Next: , Previous: hostname invocation, Up: Top

4 logger: Send messages to system log

logger is a program to send entries to system log. It provides a shell command interface similar to the system log module. See Syslog, for details.

     logger [option...] [message]
Use IPv4 as transport when logging to a host. The default behaviour is to use whatever IP version that matches the host.
Use IPv6 as transport when logging to a host. The option is present also on systems without support for IPv6, but will then issue a warning and then fall back to IPv4 when delivering the message.

Both options are most influencial when the target host is named using a symbolic name, but numerical addresses for host or source must also match if either of --ipv4 or --ipv6 is stated.

Add process ID to each message. If pid is not supplied, use the process ID of the logger process with each line. Notice, that pid is an optional argument. When supplied to the -i option, it must follow the ‘i’ letter immediately, without any separating whitespace. When supplied to the --id form, it must be separated from it by exactly one equals sign.
-h host
Send messages to the given host or socket. The host argument can be either a local UNIX socket name (starting with a dash ‘/’), or:

where host is the remote host name or IP address, and the optional port is a decimal port number or symbolic service name from /etc/services. If port is not specified, the port number corresponding to the ‘syslog’ service is used. If a numerical IPv6 address is given without a port specification, then the address must be enclosed within brackets (like [::1]).

-S addr
Supply the source IP address for INET connections. This option is useful in conjunction with --host (see above). The kind of address specified here (IPv4 or IPv6) will propagate to influence the resolution of the host address, if it is a symbolic name.
Log the message to standard error, as well as the system log.
-f file
Log the content of the specified file. If file is ‘-’ the standard input is assumed.
-p priority
Enter the message with the specified priority. The priority may be specified numerically or as a ‘facility.level’ pair. For example, -p logs the message at the informational level in the ‘local3’ facility. The default is ‘user.notice’.

The actual list of supported facilities and levels is system specific.

-t tag
Mark every line in the log with the specified tag.

The options are followed by the message which should be written to the log. If not specified, and the -f flag is not provided, standard input is logged.

The logger utility exits 0 on success, and >0 if an error occurs.

The following examples illustrate the usage of the logger command:

  1. Log the message ‘System rebooted’ to the local syslog. Use default facility and priority:
              logger System rebooted
  2. Run command and send its error output to the channel ‘local0.err’. Mark each message with tag ‘cmd’:
              command 2>&1 | logger -p local0.notice -t cmd
  3. Log each line from file warnings to channel ‘daemon.warn’ on host ‘’, using the source IP ‘’:
              logger -p daemon.warn -h -S --file