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 ~]# 
相关推荐
我不听你讲话28 分钟前
关系型与非关系型数据库视角下的 MySQL:特性解析与 Linux 部署实践
linux·mysql·nosql
Fcy6481 小时前
Linux下 进程控制(一) —— 进程的创建、终止和等待
linux·运维·elasticsearch·进程控制·进程创建、终止、等待
万象.7 小时前
Linux传输层TCP,UDP相关内容
linux·tcp/ip·udp
耀耀_很无聊7 小时前
09_Jenkins安装JDK环境
java·运维·jenkins
MaximusCoder7 小时前
等保测评命令——Centos Linux
linux·运维·经验分享·python·安全·centos
万象.7 小时前
Linux数据链路层通信原理及报文格式
linux·网络·网络协议
卷Java7 小时前
Linux服务器Docker部署OpenClaw:腾讯云/阿里云/VPS安装避坑指南
linux·运维·服务器
原来是猿9 小时前
Linux-【动静态库】
linux·运维·服务器
深圳市恒讯科技10 小时前
云服务器怎么选?从CPU、内存到IOPS的零基础选型手册
运维·服务器
艾莉丝努力练剑11 小时前
【脉脉】AI创作者崛起:掌握核心工具,在AMA互动中共同成长
运维·服务器·c++·人工智能·安全·企业·脉脉