设为首页 收藏本站
查看: 992|回复: 0

[经验分享] linux 命令之logger

[复制链接]

尚未签到

发表于 2018-5-21 12:31:22 | 显示全部楼层 |阅读模式
  1、logger命令介绍

  a shell command interface to the syslog(3) system log module
  用于往系统中写入日志,他提供一个shell命令接口到syslog系统模块
  2、logger参数详解
    -d, --udp
              Use datagram (UDP) instead of the default stream connection (TCP).
             使用udp链接而不是tcp链接
     -i, --id
              Log the process ID of the logger process with each line.
              逐行记录每一次logger的进程ID
     -f, --file file
              Log the contents of the specified file.  This option cannot be combined with a command-line message.
              记录特殊文件的内容,这个参数不能够包含了命令行的信息。
     -h, --help
              Display a help text and exit.
              展示帮助信息
     -n, --server server
              Write to the specified remote syslog server using UDP instead of to the builtin syslog routines.
              使用udp而不是内置惯例的syslog写的如到特定的远端的syslog服务器
     -P, --port port
              Use the specified UDP port.  The default port number is 514.
              使用特定的UDP端口,默认的端口是514
     -p, --priority priority
              Enter the message into the log with the specified priority.  The priority may be specified numerically or as a facil‐ity.level pair.  For example, -p local3.info logs the message as informational in the local3 facility.  The default is user.notice.
              指定输入消息的优先级,优先级可以是数字或者指定为 " facility.level" 的格式。比如:" -p local3.info " local3 这个设备的消息级别为 info。默认级别是 "user.notice"
     -s, --stderr
              Output the message to standard error as well as to the system log.
              输出错误到系统日志
     -t, --tag tag
              Mark every line to be logged with the specified tag.
              对每行记录最特殊的标记
     -u, --socket socket
              Write to the specified socket instead of to the builtin syslog routines.         写到特定的socket而不是内置惯例的syslog。
     -V, --version
              Display version information and exit.
              显示版本信息
     **messages:**写入log文件的内容消息时,可以使用-f参数。
       logger 以0退出时代表成功,大于0代表失败。  3、logger的用途和日志级别
  Valid facility names are: auth, authpriv (for security information of a sensitive nature), cron, daemon, ftp, kern (can't be gener‐ated from user process), lpr, mail, news, security (deprecated synonym for auth), syslog, user, uucp, and local0 to local7, inclu‐sive.
  Valid level names are: alert, crit, debug, emerg, err, error (deprecated synonym for err), info, notice, panic (deprecated synonym for emerg), warning, warn (deprecated synonym for warning).  For the priority order and intended purposes of these levels, see syslog(3).
  
auth:             用户授权
    authpriv:     授权和安全
    cron:         计划任务
    daemon:       系统守护进程
    kern:         与内核有关的信息
    lpr            与打印服务有关的信息
    mail           与电子邮件有关的信息
    news           来自新闻服务器的信息
    syslog         由syslog生成的信息
    user           用户的程序生成的信息,默认
    uucp           由uucp生成的信息
    local0~7       用来定义本地策略

level:
    alert          需要立即采取动作
    crit           临界状态
    debug          调试
    emerg          系统不可用
    err            错误状态
    error          错误状态
    info           正常消息
    notice         正常但是要注意
4、 EXAMPLES
     logger System rebooted
     logger -p local0.notice -t HOSTIDM -f /dev/idmc
     logger -n loghost.example.com System rebooted5、Others

  SEE ALSO
  syslog(3), syslogd(8)
  STANDARDS
  The logger command is expected to be IEEE Std 1003.2 (“POSIX.2”) compatible.
  AVAILABILITY
  The logger command is part of the util-linux package and is available from           ftp://ftp.kernel.org/pub/linux/utils/util-linux/.





  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-478657-1-1.html 上篇帖子: 查看linux文件的命令 下篇帖子: linux中的sed命令
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表