logger Command

Purpose

Makes entries in the system log.

Syntax

logger [ -f File ] [ -i ] [-r [Count] ] [ -p Priority ] [ -t Tag ] [ Message ]

Description

The logger command provides an interface to the syslog subroutine, which writes entries to the system log. A Message variable can be specified on the command line, which is logged immediately, or a File variable is read and each line of the File variable is logged. If you specify no flags or variables, the logger command will wait for you to enter a message from standard input. The messages returned by the LOG_KERN facility cannot be logged by this command.

Flags

Item Description
-f File Logs the specified File variable. If the Message variable is specified, this flag is ignored.
-i Logs the process ID of the logger process with each line.
-p Priority Enters the message with the specified priority. The Priority parameter may be a number or a facility.level priority specifier.
-t Tag Marks every line in the log with the specified Tag parameter.
Message Indicates the message to log. If this variable is not specified, the logger command logs either standard input or the file specified with the -f File flag.
-r Count If the buffer resource is not available, retries logging the message for the specified number of times. If the number is not specified, retries logging the message until the message is logged. The number must be a positive integer ranging from 1 - 1000.

Examples

  1. To log a message indicating a system reboot, enter:
    logger System rebooted
  2. To log a message contained in the /tmp/msg1 file, enter:
    logger -f /tmp/msg1
  3. To log the daemon facility critical level messages, enter:
    logger -pdaemon.crit

Exit Status

This command returns the following exit values:

Item Description
0 Successful completion.
>0 An error occurred.

Files

Item Description
/usr/bin/logger Contains the logger command.