问题描述
我遇到了以下错误:
它列出以下内容:
此错误仅在日志级别时发生 对于org.apache.axiom进行了调试,所以 解决方法是设置日志级别> 调试.
我的问题是我该怎么做?我一直在搜寻属性文件或其他内容的目录,并且一直在寻找是否可以在代码中设置某些内容,但我真的不知道自己在做什么.我现在正在台式机上运行控制台应用程序,同时试图使其工作.
更新1:我注意到我的axis2目录在其根部有其自己的log4j.properties文件.这是安全忽略的还是解决方案的一部分(或问题的一部分)?
更新2:根级log4j.properties文件未正确设置.现在看起来像这样:
log4j.rootLogger=DEBUG, R log4j.logger.org.apache.axiom=WARN log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.MaxFileSize=10MB log4j.appender.R.MaxBackupIndex=10 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
,但这显然是错误的,因为此代码返回"日志级别为null":
System.out.println("Log level is " + logger.getLevel());
目前,我正在使用
在代码中设置日志级别Logger logger = Logger.getLogger("org.apache.axiom"); logger.setLevel(Level.WARN);
推荐答案
您正在使用哪个应用程序服务器?每个人都将其记录配置放在不同的位置,尽管如今大多数使用Commons-Logging用作Log4j或Java.util.logging的包装器.
以tomcat为例,此文档使用任何一个选项配置日志记录.无论哪种情况,您都需要查找或创建一个为每个软件包定义日志级别的配置文件,并且每个位置日志系统将输出日志信息(通常是控制台,文件或DB).
在log4j的情况下,这将是log4j.properties文件,如果您遵循文件上方的链接中的说明,则会开始看起来像:
log4j.rootLogger=DEBUG, R log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=${catalina.home}/logs/tomcat.log log4j.appender.R.MaxFileSize=10MB log4j.appender.R.MaxBackupIndex=10 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
最简单的是更改行:
log4j.rootLogger=DEBUG, R
类似:
log4j.rootLogger=WARN, R
但是,如果您仍然希望自己的类调试级别输出,则添加了一行,上面写着:
log4j.category.com.mypackage=DEBUG
在 log4j 和 commons-logging 将帮助您理解所有这些.
其他推荐答案
我今天遇到了完全相同的问题,瑞安.
在我的 src (或您的根)目录中,我的 log4j.properties 文件现在具有以下添加
# https://issues.apache.org/jira/browse/AXIS2-4363 log4j.category.org.apache.axiom=WARN
感谢您如何做到这一点,本杰明.
其他推荐答案
这项为我的工作:
log4j.logger.org.hibernate.type=trace
也可以尝试:
log4j.category.org.hibernate.type=trace
问题描述
I've encountered the following bug:
http://issues.apache.org/jira/browse/AXIS2-4363
It states the following:
This error only occurs when log level for org.apache.axiom is DEBUG so a workaround is to set log level > DEBUG.
My question is HOW do I go about doing that? I've been scouring my directories for a properties file or something and I've been looking to see if there was something I could set in code, but I really have no idea what I'm doing. I'm running a console app on my desktop right now while trying to get this to work.
Update 1: I noticed that my Axis2 directory has its own log4j.properties file in its root. Is this safely ignored or is it part of the solution (or part of the problem)?
Update 2: The root level log4j.properties file is apprently not set correctly. Right now it looks like this:
log4j.rootLogger=DEBUG, R log4j.logger.org.apache.axiom=WARN log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.MaxFileSize=10MB log4j.appender.R.MaxBackupIndex=10 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
but that is apparently wrong as this code returns "Log level is null":
System.out.println("Log level is " + logger.getLevel());
For now I am setting the log level in code using
Logger logger = Logger.getLogger("org.apache.axiom"); logger.setLevel(Level.WARN);
推荐答案
Which app server are you using? Each one puts its logging config in a different place, though most nowadays use Commons-Logging as a wrapper around either Log4J or java.util.logging.
Using Tomcat as an example, this document explains your options for configuring logging using either option. In either case you need to find or create a config file that defines the log level for each package and each place the logging system will output log info (typically console, file, or db).
In the case of log4j this would be the log4j.properties file, and if you follow the directions in the link above your file will start out looking like:
log4j.rootLogger=DEBUG, R log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=${catalina.home}/logs/tomcat.log log4j.appender.R.MaxFileSize=10MB log4j.appender.R.MaxBackupIndex=10 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
Simplest would be to change the line:
log4j.rootLogger=DEBUG, R
To something like:
log4j.rootLogger=WARN, R
But if you still want your own DEBUG level output from your own classes add a line that says:
log4j.category.com.mypackage=DEBUG
Reading up a bit on Log4J and Commons-Logging will help you understand all this.
其他推荐答案
I encountered the exact same problem today, Ryan.
In my src (or your root) directory, my log4j.properties file now has the following addition
# https://issues.apache.org/jira/browse/AXIS2-4363 log4j.category.org.apache.axiom=WARN
Thanks for the heads up as to how to do this, Benjamin.
其他推荐答案
This work for my:
log4j.logger.org.hibernate.type=trace
Also can try:
log4j.category.org.hibernate.type=trace