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 ~]# 
相关推荐
东城绝神1 分钟前
《Linux运维实战:使用脚本模拟服务器CPU内存磁盘使用率》
linux·运维·服务器
染翰3 分钟前
Linux root用户安装配置Git
linux·git·后端
xingyuzhisuan3 分钟前
企业级GPU算力远程部署:标准化访问配置与性能调优手册
服务器·运维开发·远程工作·gpu算力
吃胖点儿3 分钟前
RAG系统优化完整路径:从30%到90%准确率的工程实践
服务器·数据库·windows
Cat_Rocky3 分钟前
k8s-Prometheus的manifests 清单部署
linux·kubernetes·prometheus
剑傲娇6 分钟前
【计算机组成原理】 C与汇编的「对话」
服务器·开发语言·缓存
生活爱好者!7 分钟前
用NAS进行漫画创作!一键部署Open WebUI
java·服务器·开发语言·安全·docker
Realdagongzai9 分钟前
Linux 6.19.10 内核调度器算法详解
linux·学习·算法·spring·kernel
|_⊙12 分钟前
进程间通信(管道)
linux·运维·服务器
hweiyu0017 分钟前
Linux命令:iftop
linux·运维·服务器