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
posted @ 2022-06-30 18:48  船长博客  阅读(3432)  评论(0编辑  收藏  举报
永远相信美好的事情即将发生!