Linux命令(116)之logger

linux命令之logger

1.logger介绍

linux命令logger是一个shell命令接口,通过该接口使用rsyslog的系统日志模块可以向系统日志文件(自定义日志文件)写入一行信息

2.logger用法

logger [参数] [message]

|----|--------------------|
| 参数 | 说明 |
| -i | 记录进程ID |
| -t | 在日志中的每一行添加一个标签 |
| -p | 指定自定义的日志设备和对应的日志级别 |
| -V | 查看版本信息 |
[logger参数]

3.实例

3.1.查看版本信息

命令:

logger -V

复制代码
[root@rhel77 ~]# logger -V
logger from util-linux 2.23.2
[root@rhel77 ~]# 

3.2.查看帮助信息

命令:

logger --help

复制代码
[root@rhel77 ~]# logger --help

Usage:
 logger [options] [message]

Options:
 -T, --tcp             use TCP only
 -d, --udp             use UDP only
 -i, --id              log the process ID too
 -f, --file <file>     log the contents of this file
 -h, --help            display this help text and exit
 -S, --size <num>      maximum size for a single message (default 1024)
 -n, --server <name>   write to this remote syslog server
 -P, --port <port>     use this port for UDP or TCP connection
 -p, --priority <prio> mark given message with this priority
 -s, --stderr          output message to standard error as well
 -t, --tag <tag>       mark every line with this tag
 -u, --socket <socket> write to this Unix socket
 -V, --version         output version information and exit

[root@rhel77 ~]# 

3.3.模式系统日志

命令:

logger -it error -p local5.crit "hello world"

复制代码
[root@rhel77 ~]# logger -it error -p local5.crit "hello world"
[root@rhel77 ~]# tail -n 1 /var/log/ztj.log       #/var/log/ztj.log为自定义日志文件
127.0.0.1 error 2 hello-world hello world
[root@rhel77 ~]# 
相关推荐
wanhengidc3 小时前
在线服务器的应用场景都有哪些?
运维·服务器·科技·游戏·智能手机·云计算
炼丹精神小伙3 小时前
ssh通过多跳板机连服务器
运维·服务器·ssh
吕了了4 小时前
116Dism++备份系统,如何选择性的备份文件?
运维·windows·电脑·系统
清平乐的技术专栏4 小时前
电脑核心参数一次讲透
运维
云qq4 小时前
x86操作系统19——键盘驱动
linux·c语言·汇编
测试人社区—小叶子4 小时前
低代码平台测试秘籍:OutSystems组件校验法则
运维·网络·人工智能·测试工具·低代码·自动化
路溪非溪4 小时前
关于蓝牙技术的再补充
linux
翼龙云_cloud4 小时前
阿里云渠道商:轻量应用服务器连接常见问题与解决指南
服务器·阿里云·云计算
互联网哪些事情4 小时前
服务器防御 SQL 注入
运维·服务器·sql·sql注入主机
小尧嵌入式5 小时前
QT软件开发知识点流程及记事本开发
服务器·开发语言·数据库·c++·qt