其他分享
首页 > 其他分享> > OpenWrt 使用logger命令输出日志

OpenWrt 使用logger命令输出日志

作者:互联网

logger "this is a test log."
logger -t test "this is a test log."
logger -t test -s "this is a test log."

对应输出:
Jun 30 15:28:59 (none) user.notice root: this is a test log.
Jun 30 15:28:59 (none) user.notice test: this is a test log.
Jun 30 15:29:00 (none) user.notice test: this is a test log.

logger -t 指定标签,默认是用户名
logger -s hello 输出到stderr和系统日志
logger -p 1 指定优先级

root@OpenWrt:~# logger --help
BusyBox v1.30.1 () multi-call binary.
Usage: logger [OPTIONS] [MESSAGE]
Write MESSAGE (or stdin) to syslog
        -s      Log to stderr as well as the system log
        -t TAG  Log using the specified tag (defaults to user name)
        -p PRIO Priority (numeric or facility.level pair)

# 查看syslogd使用的配置文件    
root@OpenWrt:~# ps | grep syslogd
 1615 root      1380 S    /sbin/syslogd -f/etc/syslog.conf

# 查看日志输出路径
root@OpenWrt:~# cat /etc/syslog.conf
*.* /var/log/syslog

# 持续查看日志文件
tail -f /var/log/syslog | grep test

标签:log,syslog,test,logger,root,日志,OpenWrt
来源: https://www.cnblogs.com/v5captain/p/16428068.html