log4j.xml加载不记录消息

时间:2015-03-11 11:07:24

标签: java spring tomcat log4j

Java版本jdk1.5.0_22
Tomcat 6
春天2.5

的log4j.xml

<appender name="console" class="org.apache.log4j.ConsoleAppender">
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d %5p [%c] %m%n" />
    </layout>
</appender>

C:\ ddd.log

2015-03-11 19:32:27,215 DEBUG [org.apache.log4j.joran.action.ConfigurationAction] - <Ignoring debug attribute.>
2015-03-11 19:32:27,215 DEBUG [org.apache.log4j.joran.action.AppenderAction] - <About to instantiate appender of type [org.apache.log4j.ConsoleAppender]>
2015-03-11 19:32:27,215 DEBUG [org.apache.log4j.joran.action.AppenderAction] - <Appender named as [console]>
2015-03-11 19:32:27,215 DEBUG [org.apache.log4j.joran.action.AppenderAction] - <Pushing appender on to the object stack.>
2015-03-11 19:32:27,215 DEBUG [org.apache.log4j.joran.action.LayoutAction] - <About to instantiate layout of type [org.apache.log4j.PatternLayout]>
2015-03-11 19:32:27,246 DEBUG [org.apache.log4j.joran.action.LayoutAction] - <Pushing layout on top of the object stack.>
2015-03-11 19:32:27,246 DEBUG [org.apache.log4j.joran.action.ParamAction] - <In ParamAction setting parameter [ConversionPattern] to value [%d %5p [%c] %m%n].>
2015-03-11 19:32:27,246 DEBUG [org.apache.log4j.joran.action.LayoutAction] - <Popping layout from the object stack>
2015-03-11 19:32:27,246 DEBUG [org.apache.log4j.joran.action.LayoutAction] - <About to set the layout of the containing appender.>
2015-03-11 19:32:27,246 DEBUG [org.apache.log4j.joran.action.AppenderAction] - <Popping appender named [console] from the object stack>
2015-03-11 19:32:27,246 DEBUG [org.apache.log4j.joran.action.AppenderAction] - <About to instantiate appender of type [org.apache.log4j.RollingFileAppender]>
2015-03-11 19:32:27,246 DEBUG [org.apache.log4j.joran.action.AppenderAction] - <Appender named as [rollingFile]>
2015-03-11 19:32:27,246 DEBUG [org.apache.log4j.joran.action.AppenderAction] - <Pushing appender on to the object stack.>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.ParamAction] - <In ParamAction setting parameter [File] to value [c:\ddd.log].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.ParamAction] - <In ParamAction setting parameter [Append] to value [false].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.ParamAction] - <In ParamAction setting parameter [MaxFileSize] to value [4096KB].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.ParamAction] - <In ParamAction setting parameter [MaxBackupIndex] to value [2].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LayoutAction] - <About to instantiate layout of type [org.apache.log4j.PatternLayout]>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LayoutAction] - <Pushing layout on top of the object stack.>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.ParamAction] - <In ParamAction setting parameter [ConversionPattern] to value [%d %p [%c] - <%m>%n].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LayoutAction] - <Popping layout from the object stack>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LayoutAction] - <About to set the layout of the containing appender.>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.rolling.RollingFileAppender] - <setFile called: c:\ddd.log, false>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.rolling.RollingFileAppender] - <setFile ended>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.AppenderAction] - <Popping appender named [rollingFile] from the object stack>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Logger name is [java.sql].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Retreiving an instance of org.apache.log4j.getLogger().>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Setting [java.sql] additivity to [false].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Pushing logger named [java.sql].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LevelAction] - <Encapsulating logger name is [java.sql], levelvalue is  [DEBUG].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LevelAction] - <java.sql level set to DEBUG>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.AppenderRefAction] - <Attaching appender named [rollingFile] to logger named [java.sql].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.AppenderRefAction] - <Attaching appender named [console] to logger named [java.sql].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <end() called.>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Removing logger from stack.>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Logger name is [egovframework].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Retreiving an instance of org.apache.log4j.getLogger().>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Setting [egovframework] additivity to [false].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Pushing logger named [egovframework].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LevelAction] - <Encapsulating logger name is [egovframework], levelvalue is  [DEBUG].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LevelAction] - <egovframework level set to DEBUG>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.AppenderRefAction] - <Attaching appender named [rollingFile] to logger named [egovframework].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.AppenderRefAction] - <Attaching appender named [console] to logger named [egovframework].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <end() called.>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Removing logger from stack.>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Logger name is [jdbc.sqltiming].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Retreiving an instance of org.apache.log4j.getLogger().>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Setting [jdbc.sqltiming] additivity to [false].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Pushing logger named [jdbc.sqltiming].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LevelAction] - <Encapsulating logger name is [jdbc.sqltiming], levelvalue is  [DEBUG].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LevelAction] - <jdbc.sqltiming level set to DEBUG>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.AppenderRefAction] - <Attaching appender named [rollingFile] to logger named [jdbc.sqltiming].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.AppenderRefAction] - <Attaching appender named [console] to logger named [jdbc.sqltiming].>
2015-03-11 19:32:27,262 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <end() called.>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Removing logger from stack.>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Logger name is [org.springframework].>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Retreiving an instance of org.apache.log4j.getLogger().>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Setting [org.springframework] additivity to [false].>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Pushing logger named [org.springframework].>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.LevelAction] - <Encapsulating logger name is [org.springframework], levelvalue is  [DEBUG].>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.LevelAction] - <org.springframework level set to DEBUG>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.AppenderRefAction] - <Attaching appender named [rollingFile] to logger named [org.springframework].>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.AppenderRefAction] - <Attaching appender named [console] to logger named [org.springframework].>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <end() called.>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.LoggerAction] - <Removing logger from stack.>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.RootLoggerAction] - <Pushing root logger on stack>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.LevelAction] - <Encapsulating logger name is [root], levelvalue is  [DEBUG].>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.LevelAction] - <root level set to DEBUG>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.AppenderRefAction] - <Attaching appender named [rollingFile] to logger named [root].>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.AppenderRefAction] - <Attaching appender named [console] to logger named [root].>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.action.RootLoggerAction] - <Removing root logger from top of stack.>
2015-03-11 19:32:27,277 DEBUG [org.apache.log4j.joran.JoranConfigurator] - <Finished parsing.>

它没有记录消息,为什么不呢?

1 个答案:

答案 0 :(得分:0)

如果log4j没有记录您的消息,而只记录log4j条消息,那么您可能还没有为您的软件包定义记录器。

尝试添加类似

的内容

&#13;
&#13;
<logger name="insert.your.package.here" additivity="false">
   <level value="debug" />
   <appender-ref ref="console" />
</logger>
&#13;
&#13;
&#13;

log4j.xml