zoukankan      html  css  js  c++  java
  • 使用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

  • 相关阅读:
    帧同步与状态同步
    撸个服务端出来系列(五)
    撸个服务端出来系列(四)
    撸个服务端出来系列(三)
    撸个服务端出来系列(二)
    新博客手机适配的问题
    撸个服务端出来系列(一)
    高性能事件分发器,lua 版
    cocos2dx lua UI栈
    cocos2dx3.x+cocostudio多屏幕分辨率适配解决方案(干货)
  • 原文地址:https://www.cnblogs.com/mydomain/p/3027649.html
Copyright © 2011-2022 走看看