OS Centos 7이 설치된 서버가 있고 메시지 로그 파일과 같은 로그 파일을 보고 있습니다.("/var/log/메시지")기본적으로 다음과 같은 항목으로 채워져 있는 것을 볼 수 있습니다.
Aug 29 12:46:01 localhost systemd: Created slice user-48.slice.
Aug 29 12:46:01 localhost systemd: Starting user-48.slice.
Aug 29 12:46:01 localhost systemd: Started Session 984866 of user apache.
Aug 29 12:46:01 localhost systemd: Starting Session 984866 of user apache.
Aug 29 12:46:01 localhost systemd: Started Session 984868 of user apache.
Aug 29 12:46:01 localhost systemd: Starting Session 984868 of user apache.
Aug 29 12:46:01 localhost systemd: Started Session 984867 of user apache.
Aug 29 12:46:01 localhost systemd: Starting Session 984867 of user apache.
Aug 29 12:46:01 localhost systemd: Started Session 984869 of user apache.
Aug 29 12:46:01 localhost systemd: Starting Session 984869 of user apache.
Aug 29 12:46:02 localhost systemd: Removed slice user-48.slice.
Aug 29 12:46:02 localhost systemd: Stopping user-48.slice.
Aug 29 12:47:01 localhost kernel: audit_printk_skb: 51 callbacks suppressed
Aug 29 12:47:01 localhost kernel: type=1101 audit(1535543221.712:13161497): pid=45989 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:crond_t:s0-s0:c0.c1023 msg='op=PAM:accounting grantors=pam_access,pam_unix,pam_localuser acct="apache" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success'
Aug 29 12:47:01 localhost kernel: type=1101 audit(1535543221.712:13161499): pid=45992 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:crond_t:s0-s0:c0.c1023 msg='op=PAM:accounting grantors=pam_access,pam_unix,pam_localuser acct="apache" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success'
Aug 29 12:47:01 localhost kernel: type=1101 audit(1535543221.743:13161500): pid=45991 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:crond_t:s0-s0:c0.c1023 msg='op=PAM:accounting grantors=pam_access,pam_unix,pam_localuser acct="apache" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success'
Aug 29 12:47:01 localhost kernel: type=1103 audit(1535543221.749:13161502): pid=45989 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:crond_t:s0-s0:c0.c1023 msg='op=PAM:setcred grantors=pam_env,pam_unix acct="apache" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success'
Aug 29 12:47:01 localhost kernel: audit: audit_lost=6572998 audit_rate_limit=0 audit_backlog_limit=320
Aug 29 12:47:01 localhost kernel: audit: printk limit exceeded
이제 이러한 메시지는 나에게는 별로 유용해 보이지 않으므로 내가 옳다면 이 메시지 기록을 중단하고 싶습니다.
이러한 메시지가 유용하지 않다는 내 가정이 올바른지 알고 싶습니다. 그렇다면 이러한 메시지가 기록되지 않도록 하려면 어떻게 해야 합니까?
나의/etc/rsyslog.conf내용물:
# rsyslog 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 ####
# The imjournal module bellow is now used as a message source instead of imuxsock.
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imjournal # provides access to the systemd journal
#$ModLoad imklog # reads kernel messages (the same are read from journald)
#$ModLoad immark # provides --MARK-- message capability
# Provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514
# Provides TCP syslog reception
#$ModLoad imtcp
#$InputTCPServerRun 514
#### GLOBAL DIRECTIVES ####
# Where to place auxiliary files
$WorkDirectory /var/lib/rsyslog
# 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
# Turn off message reception via local log socket;
# local messages are retrieved through imjournal now.
$OmitLocalLogging on
# File to store the position in the journal
$IMJournalStateFile imjournal.state
#### 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 :omusrmsg:*
# 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
내 시스템로그:
/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
missingok
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}
답변1
CentOS 를 사용하지 않지만 아마도 systemd
및 journald
. rsyslog
이들 각각은 로깅을 위해 구성될 수 있지만 최종 파일에 가장 가까운 파일은 /var/log/messages
아마도 /etc/rsyslog.conf
. 여기에는 다음과 같은 줄이 있을 수 있습니다.
*.info;mail.none;authpriv.none;cron.none /var/log/messages
*.info
등의 다른 레벨로 대체할 수 있습니다 *.warning
. (레벨은 다음과 같습니다: 비상 경고 심각 오류 경고 알림 정보 디버그). 다음을 사용하여 데몬을 다시 시작해야 합니다.
sudo systemctl status rsyslogd
이것이 변경해야 할 전부이지만, 완전성을 위해 일반적으로 변경되지 않는 다른 2가지 구성이 여기에 있습니다.
systemd를 사용하면 아마도 /var/log/journal/
. 이는 다음 줄을 추가하기 위해 편집할 수 있는 파일 /etc/systemd/journald.conf
(및 기타 항목 참조 ) 로 구성됩니다 .man journald.conf
MaxLevelSyslog=warning
debug
위에서 설명한 대로 모든 메시지가 필터링되는 syslog로 전송되도록 허용하는 기본값에서 수준을 낮추는 것입니다 . sudo systemctl restart systemd-journald
이 파일을 변경하는 경우 아마도 필요할 것입니다 .
파일 /etc/systemd/system.conf
( 참조 man systemd-system.conf
)에는 기본적으로 systemd에서 기록된 메시지에 대한 줄도 있습니다.
LogLevel=info
그것도 변경할 수 있습니다. 이 파일을 다시 읽으려면 재부팅해야 할 수도 있습니다.