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 ~]# 
相关推荐
lwx91485216 小时前
Linux-特殊权限SUID,SGID,SBIT
linux·运维·服务器
皮卡狮17 小时前
Linux权限的概念
linux
炘爚18 小时前
深入解析printf缓冲区与fork进程复制机制
linux·运维·算法
workflower18 小时前
注塑机行业目前自动化现状分析
运维·人工智能·语言模型·自动化·集成测试·软件工程·软件需求
小义_18 小时前
随笔 3(Linux)
linux·运维·服务器·云原生·红帽
#六脉神剑19 小时前
MySQL参数调优:十个关键参数助力数据库性能数倍提升
运维·mysql
cccccc语言我来了19 小时前
Linux(10)进程概念
linux·运维·服务器
伐尘19 小时前
【linux】查看空间(内存、磁盘、文件目录、分区)的几个命令
linux·运维·网络
Deitymoon19 小时前
linux——PV操作
linux
倔强的胖蚂蚁20 小时前
x2openEuler 辅助机完整部署教程
运维·云原生