2017-12-08 52 views
1

어떻게 든이 작업을 수행 할 수 없어 도움이 필요합니다.rsyslog가 별도의 로그 파일에 메시지 필터링 안 함

systemd 서비스에서 작성한 syslog의 로그를 별도의 로그 파일로 필터링하려고합니다. 현재 Debian을 사용하고 있습니다. 여기 내 위해 rsyslog의 설정은 내용과 /etc/rsyslog.d/19-test.conf에 위치한

:msg,contains,"[frontend]" -/var/log/frontend_app.log 

systemd 유닛 파일의 내용 : 이제

[Service] 
    ExecStart=/opt/test/current/venv/bin/python -m api.tasks.frontend_app 
    StandardOutput=syslog 
    WorkingDirectory=/opt/test/frontend/current 
    StandardError=syslog 
    User=coco 
    ProtectSystem=full 
    SyslogIdentifier=[frontend] 

, 나는 로그가 아닌 /var/log/frontend_app.log로하지만 때 syslog에 삽입 된 서비스를 실행할 때 이것을 시도하십시오 :

logger -p local1.info "[frontend] test message" 

메시지가 삽입되었습니다. /var/log/frontend_app.log에 정상적으로 입력하십시오.

/etc/rsyslog.conf 내용 :

# /etc/rsyslog.conf Configuration file for rsyslog. 
# 
#   For more information see 
#   /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html 


################# 
#### MODULES #### 
################# 

module(load="imuxsock") # provides support for local system logging 
module(load="imklog") # provides kernel logging support 
#module(load="immark") # provides --MARK-- message capability 

# provides UDP syslog reception 
#module(load="imudp") 
#input(type="imudp" port="514") 

# provides TCP syslog reception 
#module(load="imtcp") 
#input(type="imtcp" port="514") 


########################### 
#### GLOBAL DIRECTIVES #### 
########################### 

# 
# Use traditional timestamp format. 
# To enable high precision timestamps, comment out the following line. 
# 
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat 

# 
# Set the default permissions for all log files. 
# 
$FileOwner root 
$FileGroup adm 
$FileCreateMode 0640 
$DirCreateMode 0755 
$Umask 0022 

# 
# Where to place spool and state files 
# 
$WorkDirectory /var/spool/rsyslog 

# 
# Include all config files in /etc/rsyslog.d/ 
# 
$IncludeConfig /etc/rsyslog.d/*.conf 


############### 
#### RULES #### 
############### 

# 
# First some standard log files. Log by facility. 
# 
auth,authpriv.*   /var/log/auth.log 
*.*;auth,authpriv.none  -/var/log/syslog 
#cron.*    /var/log/cron.log 
daemon.*   -/var/log/daemon.log 
kern.*    -/var/log/kern.log 
lpr.*    -/var/log/lpr.log 
mail.*    -/var/log/mail.log 
user.*    -/var/log/user.log 

# 
# Logging for the mail system. Split it up so that 
# it is easy to write scripts to parse these files. 
# 
mail.info   -/var/log/mail.info 
mail.warn   -/var/log/mail.warn 
mail.err   /var/log/mail.err 

# 
# Some "catch-all" log files. 
# 
*.=debug;\ 
    auth,authpriv.none;\ 
    news.none;mail.none -/var/log/debug 
*.=info;*.=notice;*.=warn;\ 
    auth,authpriv.none;\ 
    cron,daemon.none;\ 
    mail,news.none  -/var/log/messages 

# 
# Emergencies are sent to everybody logged in. 
# 
*.emerg    :omusrmsg:* 

내가 할 수는 없습니다가이처럼 행동하고 이에 대한 해결책 어떤 이유를 찾을 것으로 보인다.

Thx!

+0

사용자 정의 rsyslog 구성을 제거하면 로그가'/ var/log/syslog'에 나타납니다. 이 질문은 문제가 systemd -> rsyslog 또는 rsyslog 필터링에서 로그를 가져 오는지 여부를 확인하는 데 도움이됩니다. –

+0

로그가 syslog에 나타납니다. 사실 나는': msg' 대신': rawmsg'를 사용하여 문제를 해결할 수 있습니다. ': msg'는'SyslogIdentifier'가없는 메시지 만 포함하고': rawmsg'는 메시지를 포함합니다. – chirgeo

답변

1

OK, 나는

:rawmsg,contains,"[frontend]" -/var/log/frontend_app.log 

:rawmsg 타임 스탬프로 전체 메시지가 포함되어 있지 않습니다 동안 :msg MSG가 (있는 경우 SyslogIdentifier를 포함에만 로그 메시지하지 않는 것 같다, 대신 이렇게 :msg:rawmsg를 사용하여 그것을 해결하기 위해 관리 사용 가능) 및 SyslogIdentifier.

여기 더 정보는 http://www.rsyslog.com/doc/master/configuration/properties.html#message-properties입니다.