简体   繁体   English

从 rsyslog 客户端将日志发送到 rsyslog 服务器中的特定文件

[英]send logs to a specific file in rsyslog server from rsyslog client

I am using rsyslog client to send freeradius logs to rsyslog server.我正在使用 rsyslog 客户端将 freeradius 日志发送到 rsyslog 服务器。 Freeradius logs are stored in /var/log/radius.log in rsyslog client PC. Freeradius 日志存储在 rsyslog 客户端 PC 的 /var/log/radius.log 中。 I want to send it to rsyslog server PC.我想将它发送到 rsyslog 服务器 PC。 I am using the following setting that is created in a separate freeradius.conf file(manually created) which is present in /etc/rsyslog.d/freeradius.conf folder.我正在使用在 /etc/rsyslog.d/freeradius.conf 文件夹中存在的单独 freeradius.conf 文件(手动创建)中创建的以下设置。 The default log file where all logs are sent to server is /var/log/syslog but I want to save log in a separate file.所有日志都发送到服务器的默认日志文件是 /var/log/syslog 但我想将日志保存在一个单独的文件中。 Please help me in saving these logs in /var/log/"CLIENT_IP"/remote_freeradius.log.请帮助我将这些日志保存在 /var/log/"CLIENT_IP"/remote_freeradius.log 中。 You can see the content of /etc/rsyslog.d/freeradius.conf file below:您可以在下面看到 /etc/rsyslog.d/freeradius.conf 文件的内容:

$ModLoad imfile     

$InputFilePollInterval 10 

$InputFileName  /var/log/radius.log 

$InputFileTag freeradius-access: 

$InputFileStateFile stat-freeradius-access 

$InputFileSeverity Info  

$InputRunFileMonitor  


$template freeradius_log, " %msg% "  


if $programname == 'freeradius-access' then @192.168.10.207:514;freeradius_log 

if $programname == 'freeradius-access' then stop

Yes, it's possible to modify the file name when forwarding them.是的,转发时可以修改文件名。

I don't know if you can achieve the following with legacy syntax - as far as i know, it's not possible.我不知道您是否可以使用遗留语法实现以下目标——据我所知,这是不可能的。 But you can combine legacy and advanced syntax, so it shouldn't be a problem.但是您可以结合传统语法和高级语法,所以这应该不是问题。


1st - Create a template: 1st - 创建一个模板:

template (name="ForwardRadiusLogs" type="string"
    string="<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% %syslogtag% %CLIENT_IP% %msg%")

2nd - Assign the template to the action which forwards the logs第二- 将模板分配给转发日志的操作

action(type="omfwd" Target="10.100.100.1" Port="20514" Template="ForwardRadiusLogs")

This is the equivalent (in advanced syntax) to the following line in your config:这相当于(在高级语法中)配置中的以下行:

@192.168.10.207:514;freeradius_log 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM