Use shell to write information to syslog log files

Source: Internet
Author: User
Tags syslog

Use shellSYslog log file write information

ApplicationProgramUse S The log file (in the/var/log directory) That yslog sends messages to the Linux system ). S Ysklogd provides two System Tools : One is System Log Record , The other is kernel information capture. Most programs usually use the C language or S Yslog application or library to send S Yslog message.

1. the logger command is a shell command (interface ). You can use the syslog System Log Module to directly write a line of information to the system log file.

2. Example

For example, record the system restart information after the hard disk upgrade:

$ Logger system rebooted for hard disk upgrade

Logger-F/var/log/MyApp. Log // record the content in the file to the System Log

Logger-s "Hard Disk Full" // send the message to the screen (standard error)

Logger-I-t my_test.sh-P local3.notice "my_test.sh find some error in... "

-I log the process ID of the logger process with each line

-S log the message to standard error, as well as the system log.

-F File log the specified file.

-T tag mark every line in the log with the specified tag.

Original

[1] http://hi.baidu.com/jackbillow/item/02341e426b6952e3bdf451cf

[2] http://www.chenqing.org/2012/08/use-logger-logrotate-manage-your-logs.html

[3] detailed descriptions of/etc/syslog. conf,/etc/logrotate. conf

Http://www.187299.com/archives/1784

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.