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 ~]# 
相关推荐
tg_xianheyun4 小时前
CDN节点分布如何影响网页加载速度和用户体验
服务器·cdn加速·全球访问优化
lsh曙光4 小时前
延时at指令和定时cron指令
linux·服务器·网络
圆山猫5 小时前
[Virtualization](四):Linux KVM/RISC-V 的 vCPU 运行路径
java·linux·risc-v
布鲁飞丝5 小时前
vivo Pulsar 万亿级消息处理实践()-Ansible运维部署
运维·ansible
XR1234567885 小时前
企业全光网络架构选型技术白皮书:从物理层到运维层的全链路分析
运维·网络·架构
似的8355 小时前
一步一步学习使用FireMonkey动画() 使用TAnimator类创建动画
linux·学习·nginx
HiDev_5 小时前
【非标自动化】2、认识元器件(直线模组)
运维·自动化
夏殇之殁6 小时前
包中创建自定义列表项。 . 使用自定义列表项进行数据绑定 . 将天气预报数据保存到本地内存表,通过LiveBindings进行显示。 ...
服务器·前端·javascript
龙仔7256 小时前
人大金仓 KingbaseES V8 只读账号创建完整运维笔记
运维·笔记·sql·人大金仓
我不管我就要叫小猪7 小时前
嵌入式Linux----网络通信
linux·运维·服务器