logger
file managementLinux/Unix
The logger command is one of the most frequently used commands in Linux/Unix-like operating systems. logger Add entries to the system log
Quick Reference
Command Name:
logger
Category:
file management
Platform:
Linux/Unix
Basic Usage:
logger [options] [arguments]
Common Use Cases
Syntax
logger [options] [message]
Options
Option | Description |
---|---|
-d, --udp |
Use UDP for remote logging (default) |
-e, --skip-empty |
Do not log empty lines |
-f, --file file |
Log the contents of the specified file |
-i, --id |
Log the process ID too |
--id=id |
Use the specified ID instead of process ID |
-n, --server host |
Write to the specified remote syslog server |
-P, --port port |
Use the specified UDP port |
-p, --priority priority |
Mark the message with the specified priority |
--prio-prefix |
Look for a priority in the message |
-s, --stderr |
Output message to standard error as well |
-t, --tag tag |
Mark every line with the specified tag |
-T, --tcp |
Use TCP for remote logging |
-u, --socket socket |
Write to the specified socket instead of built-in syslog |
--socket-errors |
Print connection errors when using Unix sockets |
--journald[=file] |
Write journald entry |
-h, --help |
Display help text and exit |
-V, --version |
Display version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the logger
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
logger "System backup completed successfully"