• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

logger Command Examples in Linux

by admin

logger command is used to log messages in the system log or syslog. You can log a messages string on the command line or provide a file as input that can contain the message to be logged.

To view the available switches for the logger command:

# logger --help

Usage:
 logger [options] [message]

Options:
 -T, --tcp             use TCP only
 -d, --udp             use UDP only
 -i, --id              log the process ID too
 -f, --file [file]     log the contents of this file
 -h, --help            display this help text and exit
 -S, --size [num]      maximum size for a single message (default 1024)
 -n, --server [name]   write to this remote syslog server
 -P, --port [port]     use this port for UDP or TCP connection
 -p, --priority [prio] mark given message with this priority
 -s, --stderr          output message to standard error as well
 -t, --tag [tag]       mark every line with this tag
 -u, --socket [socket] write to this Unix socket
 -V, --version         output version information and exit

logger command examples

1. To log the message to standard error and system logs

# logger -s "This is a test message" 

2. To log to message to the specified file

# logger -f file "This is a test message"

3. To log the message with specified priority

# logger -p 1 "This is a test message"

4. To mark every line with specified tag

# logger -t TAG "This is a test message"

5. To allow the message to start with a hyphen

# logger -- "This is a test message"

Filed Under: Linux

Some more articles you might also be interested in …

  1. e2image: command not found
  2. notify-send: command not found
  3. aa-enforce: command not found
  4. kscreen-console Command Examples in Linux
  5. macchanger Command Examples in Linux
  6. flock: command not found
  7. fwupdmgr Command Examples in Linux
  8. Comparing NET-TOOLS V/s IPROUTE Package Commands (ip Vs ifconfig command comparison)
  9. CentOS / RHEL : How to block incoming and outgoing ports using iptables
  10. grub-mkconfig Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright