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 ~]# 
相关推荐
我没有开挂12 分钟前
旧 docker 版本通过 nvkind 搭建虚拟多节点 gpu 集群的坑
运维·docker·容器
qq_3392822313 分钟前
centos中libc.so.6No such file的解决方式
linux·运维·centos
leoufung18 分钟前
ECPF 简介
linux·网络·kernel
小鸡,啄米40 分钟前
centos9安装docker 配置docker代理
运维·docker·容器
水银嘻嘻1 小时前
12 web 自动化之基于关键字+数据驱动-反射自动化框架搭建
运维·前端·自动化
在肯德基吃麻辣烫1 小时前
Netdata在Ubuntu环境下的安装与配置:构建实时系统监控与性能分析平台
linux·运维·ubuntu
国际云,接待2 小时前
云服务器的运用自如
服务器·架构·云计算·腾讯云·量子计算
不念霉运2 小时前
Gitee DevOps:中国企业数字化转型的“本土化加速器“
运维·gitee·团队开发·代码规范·devops·代码复审
安迪小宝2 小时前
6 任务路由与负载均衡
运维·python·celery
遇见火星2 小时前
jenkins流水线常规配置教程!
运维·docker·jenkins