GNU/Linux >> Belajar Linux >  >> Linux

Contoh Perintah logger di Linux

perintah logger digunakan untuk mencatat pesan di log sistem atau syslog. Anda dapat mencatat string pesan pada baris perintah atau memberikan file sebagai input yang dapat berisi pesan yang akan dicatat.

Untuk melihat sakelar yang tersedia untuk perintah pencatat:

# 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

contoh perintah logger

1. Untuk mencatat pesan ke kesalahan standar dan log sistem

# logger -s "This is a test message" 

2. Untuk masuk ke pesan ke file yang ditentukan

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

3. Untuk mencatat pesan dengan prioritas tertentu

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

4. Untuk menandai setiap baris dengan tag tertentu

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

5. Untuk mengizinkan pesan dimulai dengan tanda hubung

# logger -- "This is a test message"


Linux
  1. 7 Contoh Perintah Linux df

  2. Contoh Perintah rm di Linux

  3. Contoh Perintah ps di Linux

  1. sa Contoh Perintah di Linux

  2. w Contoh Perintah di Linux

  3. Contoh Perintah ac di Linux

  1. 8 Contoh Perintah Linux TR

  2. Contoh Perintah df di Linux

  3. du Contoh Perintah di Linux