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 @   船长博客  阅读(3774)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2021-06-30 Spark scala String Array转为String
2020-06-30 shell awk实现删除hdfs上某日期之前的文件
永远相信美好的事情即将发生!
点击右上角即可分享
微信分享提示