私は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
さて、これらのメッセージは私にとってあまり役に立たないように見えるので、私が正しければ、これを記録するのをやめたいと思います。
これらのメッセージがあまり役に立たないという私の推測が正しいかどうか、また正しい場合、これらのメッセージがログに記録されないようにするにはどうすればよいかを知りたいです。
私の設定ファイルコンテンツ:
# 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
私の syslog:
/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
。(レベルは、emerg、alert、crit、err、warning、notice、info、debugです)。デーモンを再起動する必要があります。
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
これも変更できます。このファイルを再度読み込むには再起動が必要になる場合があります。