Next: , Previous: , Up: GNU Inetutils   [Contents][Index]


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

Synopsis:

logger [option…] [message]

6.1 Command line options

-4
--ipv4

Use IPv4 as transport when logging to a host. The default behaviour is to use whatever IP version that matches the host.

-6
--ipv6

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
--file=file

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

-h host
--host=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

host[:port]

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

-i[pid]
--id=[pid]

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
--priority=priority

Enter the message with the specified priority. The priority may be specified numerically or as a ‘facility.level’ pair. For example, -p local3.info 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.

-s
--stderr

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

-S addr
--source=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
--tag=tag

Mark every line in the log with the specified tag.

-u socket
--unix=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.

6.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 ‘logger.runasimi.org’, using the source IP ‘10.10.10.1’:
    logger -p daemon.warn -h logger.runasimi.org -S 10.10.10.1  \
           --file warnings
    

Next: ping: Packets to network hosts, Previous: ifconfig: Configure network interfaces, Up: GNU Inetutils   [Contents][Index]