如何停止 Tomcat / rsyslog 记录到控制台?

如何停止 Tomcat / rsyslog 记录到控制台?

在我的工作中,有人曾将 Tomcat 设置为记录到 syslog。问题是这些消息也会发送到控制台。

系统是 RHEL6,这些是涉及的 RPM

rsyslog-5.8.10-10.el6_6.x86_64
tomcat-7.0.64-1.x86_64

我尝试使用这两个命令来静音控制台的消息:

dmesg -n 1
sysctl -w kernel.printk="1 4 1 3"

这些并没有什么不同,这些信息仍然不断涌来。Log4j似乎未在此系统上使用。在server.xmlTomcat 中,此部分用于日志记录:

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
       prefix="localhost_access_log." suffix=".txt" rotatable="false"
       pattern="%h %l %u %t &quot;%r&quot; %s %b" />

如果我停止,rsyslog它将停止这些消息。我不知道如何设置rsyslogTomcat 的日志记录,我不是 Tomcat 专家。Tomcat 是唯一向控制台发送消息的应用程序。其他内容被发送到控制台,rsyslog但除了 Tomcat 内容之外,没有任何东西被记录到控制台。

由于我尝试了命令,dmesg -n 1我怀疑 Tomcat 正在以最高级别发送消息,但我找不到任何可能导致该问题的代码。

控制台上的消息示例(请注意,它显示 tomcat-instance06,这是一个自制的 RPM,允许多个 Tomcat 实例)。我刚刚注意到它总是在控制台上显示 [FATAL] 消息,然后是第二条有关相同消息的消息:

Message from syslogd@localhost at Jun 22 16:52:12 ...
 [FATAL] some.portal-app: [model.website.PageService] RequestID already used - ...#012Detail: #012detail#012Tag context: #012/opt/tomcat-instance06/webapps/ROOT/model/WebserviceRequest.cfc, line 486#012/opt/tomcat-instance06/webapps/ROOT/model/WebserviceRequest.cfc, line 484#012/opt/tomcat-instance06/webapps/ROOT/model/WebserviceRequest.cfc, line 482#012/opt/tomcat-instance06/webapps/ROOT/model/WebserviceRequest.cfc, line 482#012/opt/tomcat-instance06/webapps/ROOT/model/WebserviceRequest.cfc, line 482#012/opt/tomcat-instance06/webapps/ROOT/model/WebserviceRequest.cfc, line 482#012/opt/tomcat-instance06/webapps/ROOT/model/WebserviceRequest.cfc, line 482#012/opt/tomcat-instance06/webapps/ROOT/model/WebserviceRequest.cfc, line 482#012/opt/tomcat-instance06/webapps/ROOT/model/WebserviceRequest.cfc, line 482#012/opt/tomcat-instance06/webapps/ROOT/model/WebserviceRequest.cfc, line 482#012/opt/tomcat-instance06/webapps/ROOT/model/WebserviceRequest.cfc, line 482#012/opt/tomcat-instance06/webapps/ROOT/model/WebserviceRequest.cfc, l...

Message from [email protected] at Jun 22 16:52:12 ...
 482#012/opt/tomcat-instance06/webapps/ROOT/model/WebserviceRequest.cfc, line 482#012/opt/tomcat-instance06/webapps/ROOT/model/WebserviceRequest.cfc, line 268#012/opt/tomcat-instance06/webapps/ROOT/model/website/PageService.cfc, line 194#012/opt/tomcat-instance06/webapps/ROOT/model/website/PageService.cfc, line 86#012/opt/tomcat-instance06/webapps/ROOT/model/RequestContextDecorator.cfc, line 16#012/opt/tomcat-instance06/webapps/ROOT/model/RequestContextDecorator.cfc, line 232#012/opt/tomcat-instance06/webapps/ROOT/handlers/General.cfc, line 596#012/opt/tomcat-instance06/webapps/ROOT/coldbox/system/web/Controller.cfc, line 764#012/opt/tomcat-instance06/webapps/ROOT/coldbox/system/web/Controller.cfc, line 648#012/opt/tomcat-instance06/webapps/ROOT/coldbox/system/web/services/ExceptionService.cfc, line 51#012/opt/tomcat-instance06/webapps/ROOT/coldbox/system/Coldbox.cfc, line 350#012/opt/tomcat-instance06/webapps/ROOT/coldbox/system/Coldbox.cfc, line 382#012/opt/tomcat-instance06/webapps/ROOT/Application.cfc, line 60

这是的内容/etc/rsyslog.conf

#
# Use traditional timestamp format
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

# Provides kernel logging support (previously done by rklogd)
$ModLoad imklog

# Provides --MARK-- message capability
$ModLoad immark

# Provides support for local system logging (e.g. via logger command)
$ModLoad  imuxsock

# set ratelimit interval
$SystemLogRateLimitInterval 2
$SystemLogRateLimitBurst 150

# Provides UDP syslog reception
$ModLoad  imudp

# Syslog server listen address
$UDPServerAddress 127.0.0.1

# Syslog server listen UDP port
$UDPServerRun 514

# 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;local0.none;local6.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/mail.log

# 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
local6.warning                                                    /var/log/audit_orcl.log
LOCAL6.WARNING                                                    /var/log/audit_orcl.log

# Save boot messages also to boot.log
local7.*                                                          /var/log/boot.log

# Log all messages to the following syslog servers
<I have removed this section containing ip's of syslogservers>

在 /etc/rsyslog.conf 中尝试注释掉 kern.*

#kern.*                                                  /dev/console

但重新启动 rsyslog 后,它仍然会将这些 tomcat 消息记录到控制台:(

知道去哪儿可以禁用这些消息吗?

答案1

找到了(呃)。

注释掉此内容可/etc/rsyslog.conf停止消息:

# Everybody gets emergency messages
*.emerg                        *

并且还发现,事实上,tomcat 是唯一一个持续向该页面记录日志的应用程序,这是由于应用程序编程不良,将每条消息都记录为致命消息,从而导致其进入控制台。

相关内容