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 ~]# 
相关推荐
翼龙云_cloud3 分钟前
亚马逊云代理商:CloudWatch Agent 全解析 5 步实现服务器监控
运维·服务器·云计算·aws·云服务器
Cyber4K1 小时前
【Nginx专项】基础入门篇:状态页、微更新、内容替换、读取、压缩及防盗链
linux·运维·服务器·nginx·github
shining2 小时前
当拿到一个新服务器时所需准备工作
linux·程序员
门思科技2 小时前
LoRaWAN项目无需NS和平台?一体化网关如何简化部署与成本
服务器·网络·物联网
Bruce_Liuxiaowei2 小时前
顺藤摸瓜:一次从防火墙告警到设备实物的溯源实战
运维·网络·网络协议·安全
maosheng11462 小时前
linux的综合教程(搭建论坛教程)
linux
IpdataCloud2 小时前
效果广告中点击IP与转化IP不一致?用IP查询怎么做归因分析?
运维·服务器·网络
Deitymoon3 小时前
linux——TCPIP协议原理
linux·网络
独小乐3 小时前
018.使用I2C总线EEPROM|千篇笔记实现嵌入式全栈/裸机篇
linux·笔记·单片机·嵌入式硬件·arm·信息与通信
SPC的存折3 小时前
2、Docker命令与镜像、容器管理
linux·运维·服务器·docker·容器·eureka