[英]How to disable tomcat server console log?
My log4j.proerties
我的log4j.proerties
log4j.rootLogger=DEBUG,R
log4j.appender.R = org.apache.log4j.RollingFileAppender
log4j.appender.R.File = logs/backup.log
log4j.appender.R.Append = true
log4j.appender.R.DatePattern = '.'yyy-MM-dd
log4j.appender.R.layout = org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n
log4j.additivity.info.release.scheduler=false
My Action
class is 我的Action
课是
private static final Logger logger = Logger.getLogger(LogAction.class);
if(getUname().equals("admin")&&getPwd().equals("123"))
{
logger.info("Success");
return "su";
}
else
{
addActionMessage("user name and password incorrectly!");
logger.info("Failure");
return "fa";
}
My backup.log
file contain the following logs. 我的backup.log
文件包含以下日志。 These logs are coming from tomcat server 这些日志来自tomcat服务器
a2013-05-24 15:06:44 XmlConfigurationProvider [DEBUG] Loading action configurations
from: struts-default.xml
2013-05-24 15:06:44 XmlConfigurationProvider [DEBUG] Loaded action configuration
from: struts-default.xml
2013-05-24 15:06:44 XmlConfigurationProvider [INFO] Parsing configuration file
[struts-default.xml]
2013-05-24 15:06:44 XmlConfigurationProvider [DEBUG] Loaded type:
name:xwork impl:com.opensymphony.xwork2.ObjectFactory
2013-05-24 15:06:44 XmlConfigurationProvider [DEBUG]
Loaded type:com.opensymphony.xwork2.ObjectFactory name:struts
but I want the following format only 但我只想要以下格式
2013-05-24 15:06:44 Login successfull.
2013-05-24 15:06:44 Login failure.
and my question is how to avoid unwanted logs write into the log file? 我的问题是如何避免将不需要的日志写入日志文件? And I am using Struts2 and log4j properties. 我正在使用Struts2和log4j属性。
To turn off unwanted log using log4j configuration properties file via specifying the level for the logger based on the logger instantiated for the given class. 通过基于给定类实例化的记录器指定记录器的级别,使用log4j配置属性文件关闭不需要的日志。 For example 例如
log4j.logger.org.apache=OFF,R
log4j.logger.com.opensymphony.xwork2=OFF,R
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.