Next: , Previous: , Up: Top   [Contents][Index]

5 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. For background information, see Syslog in The GNU C Library Reference Manual.


logger [option…] [message]

5.1 Command line options


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.

-f file

Log the content of the specified file. If file is ‘-’ then standard input is assumed.

-h host

Send messages to the given host or socket. The host argument can be either a local UNIX socket name (containing a slash ‘/’), or be of the form


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]).


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.

-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.


Log the message to standard error, as well as to the system log.

-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.

-t tag

Mark every line in the log with the specified tag.

-u socket

Send messages to the given local UNIX socket. The socket argument can be either an absolute path (starting with a slash ‘/’), or a relative path understood relative to the current working directory.

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.

5.2 Examples

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.err -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 warnings

Next: , Previous: , Up: Top   [Contents][Index]