الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

logger

Write a message to the system log (journal and rsyslog) — from the command line or a script.

المستوى
امتحان RHCSA
المجموعة
السجلات
يحتاج root
لا
الحزمة
util-linux

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

logger MESSAGE sends a message with facility user and priority notice. With -p FACILITY.PRIORITY and -t TAG you control where it goes and how it is marked. Use it to test rsyslog rules and to log what your scripts do. It can also send to a remote syslog server.

طريقة الكتابة

logger [OPTION]... [MESSAGE]

الخيارات 24

الأكثر استخدامًا

-p, --priority FACILITY.LEVEL
Facility and priority, like local4.warning (default user.notice).
-t, --tag TAG
Mark the line with this tag (default: your user name).
-i
Add the PID of logger.
--id[=ID]
Add this ID (or the PID) to the line.
-f, --file FILE
Log the content of a file, line by line.
-e, --skip-empty
Skip empty lines.
-s, --stderr
Also print the message on the screen.
-n, --server SERVER
Send to this remote syslog server.
-P, --port PORT
Remote port (default 514).
-T, --tcp
Use TCP.
-d, --udp
Use UDP.
-u, --socket SOCKET
Write to this socket instead of the default.
--socket-errors[=MODE]
Report socket errors (on, off, auto).
--journald[=FILE]
Write directly to the journal, with your own fields from a file.
--msgid ID
RFC 5424 message ID.
--sd-id NAME, --sd-param NAME=VALUE
RFC 5424 structured data.
--rfc3164
Use the old BSD syslog format.
--rfc5424[=without]
Use the RFC 5424 format.
--octet-count
Use octet counting framing (RFC 6587).
--prio-prefix
Read the priority from a <N> prefix in each line.
-S, --size SIZE
Maximum message size.
--no-act
Do everything except write the message.
-h, --help
Show help.
-V, --version
Show the version.

أمثلة 10

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1Write a simple message

    logger "backup started"
    journalctl -n 1
    Oct 25 11:05:12 server1 student[4410]: backup started

    The tag is your user name.

  2. 2With a tag and priority

    logger -t backup -p user.err "backup failed: disk full"

    Easy to find with journalctl -t backup -p err.

  3. 3Test an rsyslog rule

    logger -p local4.warning "test for backup.log"
    tail -1 /var/log/backup.log

    Proves the rule works.

  4. 4Also show it on the screen

    logger -s -t deploy "version 2.4 deployed"
    <13>Oct 25 11:06:01 deploy: version 2.4 deployed

    -s prints to stderr too.

  5. 5Log a whole file

    logger -t import -f /var/tmp/import-report.txt

    One log line per file line.

  6. 6Log from a script

    logger -t myscript -p user.info "$(date +%F) cleaned $(find /var/tmp -mtime +7 | wc -l) files"

    Your script results in the central logs.

  7. 7Send to a remote syslog server

    logger -n logserver.example.com -T -P 514 -t test "remote test"

    Check that the log server receives messages.

  8. 8Log the result of a command

    dnf -y upgrade >/dev/null 2>&1 && logger -t patch "upgrade OK" || logger -t patch -p user.err "upgrade FAILED"

    Success or failure in the log.

  9. 9Pipe output into the log

    df -h / | logger -t diskcheck

    Every line becomes a log entry.

  10. 10Mark tests in security monitoring

    logger -t soc-test "SIEM detection test 2026-10-25"

    Test that your SIEM gets and alerts on messages.

رموز الخروج

0 :: Done. 1 :: Error.