当前位置:网站首页>Rsyslog配置及使用教程
Rsyslog配置及使用教程
2022-07-04 12:34:00 【星哥玩云】
1.Rsyslog介绍 Rsyslog is Rocket-fast System for Log processing.Rsyslog是CentOS6系列默认的日志处理软件。Rsyslog基于模块化设计,提供高性能,安全的日志处理系统。Rsyslog是多线程的,支持TCP,UDP,TLS,RELP.Rsyslog实际上syslog的一个增强版本。
2.安装Rsyslog
CentOS下默认已经安装了rsyslog 查看rsyslog运行状态
$service rsyslog status rsyslogd (pid 7542) is running...
$ ps -ef|grep rsyslog|grep -v grep root 1014 1 0 2014 ? 00:15:09 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
这里-c 5 是在/etc/sysconfig/rsyslog中定义的 $ cat /etc/sysconfig/rsyslog # Options for rsyslogd # Syslogd options are deprecated since rsyslog v3. # If you want to use them, switch to compatibility mode 2 by "-c 2" # See rsyslogd(8) for more details SYSLOGD_OPTIONS="-c 5"
3.配置rsyslog
rsyslog的配置文件/etc/rsyslog.conf # rsyslog v5 configuration file # For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html # If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html #### MODULES #### $ModLoad imuxsock # provides support for local system logging (e.g. via logger command) $ModLoad imklog # provides kernel logging support (previously done by rklogd) #$ModLoad immark # provides --MARK-- message capability # Provides UDP syslog reception #$ModLoad imudp #$UDPServerRun 514 # Provides TCP syslog reception #$ModLoad imtcp #$InputTCPServerRun 514 #### GLOBAL DIRECTIVES #### # Use default timestamp format $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat # File syncing capability is disabled by default. This feature is usually not required, # not useful and an extreme performance hit #$ActionFileEnableSync on # Include all config files in /etc/rsyslog.d/ $IncludeConfig /etc/rsyslog.d/*.conf #### RULES #### # Log all kernel messages to the console. # Logging much else clutters up the screen. #kern.* /dev/console # Log anything (except mail) of level info or higher. # Don't log private authentication messages! *.info;mail.none;authpriv.none;cron.none /var/log/messages # The authpriv file has restricted access. authpriv.* /var/log/secure # Log all the mail messages in one place. mail.* -/var/log/maillog # Log cron stuff cron.* /var/log/cron # Everybody gets emergency messages *.emerg * # Save news errors of level crit and higher in a special file. uucp,news.crit /var/log/spooler # Save boot messages also to boot.log local7.* /var/log/boot.log # ### begin forwarding rule ### # The statement between the begin ... end define a SINGLE forwarding # rule. They belong together, do NOT split them. If you create multiple # forwarding rules, duplicate the whole block! # Remote Logging (we use TCP for reliable delivery) # # An on-disk queue is created for this action. If the remote host is # down, messages are spooled to disk and sent when it is up again. #$WorkDirectory /var/lib/rsyslog # where to place spool files #$ActionQueueFileName fwdRule1 # unique name prefix for spool files #$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible) #$ActionQueueSaveOnShutdown on # save messages to disk on shutdown #$ActionQueueType LinkedList # run asynchronously #$ActionResumeRetryCount -1 # infinite retries if host is down # remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional #*.* @@remote-host:514 # ### end of the forwarding rule ###
$ cat /etc/rsyslog.conf|grep -v -E "^#|^$" $ModLoad imuxsock # provides support for local system logging (e.g. via logger command) $ModLoad imklog # provides kernel logging support (previously done by rklogd) $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat $IncludeConfig /etc/rsyslog.d/*.conf *.info;mail.none;authpriv.none;cron.none /var/log/messages authpriv.* /var/log/secure mail.* -/var/log/maillog cron.* /var/log/cron *.emerg * uucp,news.crit /var/log/spooler local7.* /var/log/boot.log
配置格式如下:
日志类型.日志级别 日志处理方式
日志类型 | 说明 |
---|---|
auth | pam模块产生的日志 |
authpriv | ssh,sftp等的登录验证信息 |
cron | 定时任务相关日志 |
kernel |
边栏推荐
- 昨天的事情想说一下
- 面试官:Redis 过期删除策略和内存淘汰策略有什么区别?
- Cadence physical library lef file syntax learning [continuous update]
- Is the main thread the same as the UI thread- Is main thread the same as UI thread?
- ArcGis利用栅格处理工具进行影像裁剪
- Show recent errors only command /bin/sh failed with exit code 1
- Agile development / agile testing experience
- 敏捷开发/敏捷测试感受
- Jetson TX2配置Tensorflow、Pytorch等常用库
- 阿里云有奖体验:用PolarDB-X搭建一个高可用系统
猜你喜欢
CVPR 2022 | TransFusion:用Transformer进行3D目标检测的激光雷达-相机融合
When synchronized encounters this thing, there is a big hole, pay attention!
17. Memory partition and paging
DC-5靶机
Argminer: a pytorch package for processing, enhancing, training, and reasoning argument mining datasets
强化学习-学习笔记1 | 基础概念
从0到1建设智能灰度数据体系:以vivo游戏中心为例
ArcGis利用栅格处理工具进行影像裁剪
8个扩展子包!RecBole推出2.0!
Fastlane one click package / release app - usage record and stepping on pit
随机推荐
《天天数学》连载57:二月二十六日
AbstractDispatcherServletInitializer 的实现类为什么可以在初始化Web容器的时候被调用
CVPR 2022 | TransFusion:用Transformer进行3D目标检测的激光雷达-相机融合
【Android Kotlin】lambda的返回语句和匿名函数
How to realize the function of Sub Ledger of applet?
C language: find the palindrome number whose 100-999 is a multiple of 7
jsonp
Global and Chinese markets for environmental disinfection robots 2022-2028: Research Report on technology, participants, trends, market size and share
C language: the sorting problem of circle number reporting
七、软件包管理
Etcd 存储,Watch 以及过期机制
asp. Core is compatible with both JWT authentication and cookies authentication
17. Memory partition and paging
Sort merge sort
「小技巧」给Seurat对象瘦瘦身
Jetson TX2配置Tensorflow、Pytorch等常用库
runc hang 导致 Kubernetes 节点 NotReady
记一次 Showing Recent Errors Only Command /bin/sh failed with exit code 1 问题
PostgreSQL 9.1 飞升之路
众昂矿业:为保障萤石足量供应,开源节流势在必行