• 使用Shell向syslog日志文件写入信息


    使用Shellsyslog日志文件写入信息

    应用程序使用syslog协议发送信息给Linux系统的日志文件(位于/var/log目录)sysklogd提供两个系统工具一个是系统日志记录另一个是内核信息捕获。通常大多程序都使用C语言或者syslog应用程序或库来发送syslog消息。

    1、logger命令是一个Shell命令(接口)。可以通过该接口使用syslog的系统日志模块,直接向系统日志文件写入一行信息。

    2、示例

    比如,记录硬盘升级后的系统重启信息:

    $ logger System rebooted for hard disk upgrade

    logger -f /var/log/myapp.log  //将文件中内容记录系统日志

    logger -s "Hard disk full"  //把消息发送到屏幕(标准错误)

    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.

    原文

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

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

    [3]对/etc/syslog.conf,/etc/logrotate.conf进行了详细的讲解

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

  • 相关阅读:
    校招 存储相关研发工程师 收人要求
    Ubuntu配置
    个人感想
    Linux入门 文本编辑器
    linux入门 一些常见命令
    linux入门 配置网络
    面试逻辑题 5L和3L的杯子 8L的水 倒出4L
    Java并发编程的艺术读后总结
    URL重写
    常见的四种排名函数的用法----转载
  • 原文地址:https://www.cnblogs.com/mydomain/p/3027649.html
Copyright © 2020-2023  润新知