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 ~]# 
相关推荐
开开心心就好7 小时前
能把网页藏在Word里的实用摸鱼工具
linux·运维·服务器·windows·随机森林·逻辑回归·excel
Bruce_Liuxiaowei7 小时前
技嘉Aorus主板Win10引导故障深度修复:从网络重置到注册表移植
服务器·网络·windows·microsoft
Lucis__7 小时前
Linux网络:基于协议栈原理实现UDP通信
linux·网络·udp
老绿光7 小时前
Python 字典完全指南:从入门到实战
linux·服务器·python
tryCbest8 小时前
Nginx常用操作命令-Linux和Windows系统
linux·windows·nginx
搜狐技术产品小编20238 小时前
智能代码审查基于大语言模型的自动化代码质量保障平台设计与实践
运维·人工智能·语言模型·自然语言处理·自动化
何中应8 小时前
如何给虚拟机系统扩容
linux·运维·服务器
缘友一世8 小时前
tmux 共享终端:AI 模型执行命令的实时审计方案
linux·llm·tmux·agent终端交互审计
沐雪轻挽萤8 小时前
无人系统:Ubuntu 操作系统全景架构与实战工程指南
linux·运维·ubuntu
白緢9 小时前
嵌入式 Linux + 内核开发高频问题及排查
java·linux·运维