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 ~]# 
相关推荐
饼瑶6 小时前
Isaac Sim 5.1.0 部署指南(实验室服务器)
服务器·仿真·具身智能
Agent产品评测局6 小时前
图片生成智能体哪家好?2026年企业级视觉创作与自动化选型全景横评
运维·人工智能·ai·自动化
fetasty6 小时前
chroot的Linux服务配置-当云服务器真正用起来
android·linux·服务器
猫头虎-人工智能6 小时前
ToDesk ToClaw AI自动化实测:零门槛玩转日常自动化,告别折腾与硬件损耗
运维·人工智能·架构·开源·自动化·aigc·ai编程
实在智能RPA6 小时前
Agent 能做流程的自动化监控吗?——深度拆解2026年AI智能体在企业级闭环监控中的技术实践
运维·人工智能·ai·自动化
翱翔-蓝天6 小时前
WSL + Docker + GPU 安装 video-subtitle-remover 完整文档
运维·docker·容器
云飞云共享云桌面6 小时前
研发部门使用SolidWorks和ug,cad,设计共享云桌面应该怎么选?
运维·服务器·网络·人工智能·3d
麦聪聊数据6 小时前
数据库安全与运维管控(五):基于AST的SQL拦截与动态审批
运维·数据库·sql
BullSmall6 小时前
linux 系统下模拟网络丢失和ping延迟,可以怎么来模拟
linux·网络·php
brahmsjiang6 小时前
理解Android AOT编译与内存映射:从Zygote启动到页表权限隔离
android·linux·zygote