log4j即使已经定义了logger,也无法找到记录器的appender

时间:2017-12-18 15:19:16

标签: log4j

我的Log4j.xml文件(log4j 1.2.15)

$('.someclass').css('width', function() {
  var $parent = $(this).parent();
  return Math.round(($parent.width() / $parent.height()) * $parent.parent().width())
});

记录器级别:

<appender name="Append1" class="org.apache.log4j.FileAppender"> 
   <param name="File" value="tomcat/log.out"/>
   <param name="Append" value="true"/> 
   <param name="Threshold" value="DEBUG"/>
   <layout class="org.apache.log4j.PatternLayout"> 
       <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
   </layout>
</appender>

登录catalina文件:

<logger name="xx.yy.zzzz.Controller" additivity="false">
     <level value="DEBUG"/>
     <appender-ref ref="Append1"/>
</logger>

我们收到此警告消息,但我们没有跟踪

  log4j: Setting property [file] to [/log.out].
  log4j: Setting property [append] to [true].
  log4j: Setting property [threshold] to [DEBUG].
  log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
  log4j: Setting property [conversionPattern] to [%d %-5p [%c] (%t) %m%n].
  log4j: setFile called: log.out, true
  log4j: setFile ended
  log4j: Retreiving an instance of org.apache.log4j.Logger.
  log4j: Setting [xx.yy.zzzz.Controller] additivity to [false].
  log4j: Level value for xx.yy.zzzz.Controller is [DEBUG].
  log4j: **xx.yy.zzzz.Controller level set to DEBUG**
  log4j: Adding appender named [Append1] to category [xx.yy.zzzz.Controller].

收率

java Class:

  log4j:WARN No appenders could be found for logger (xx.yy.zzzz.Controller).
  log4j:WARN Please initialize the log4j system properl

1 个答案:

答案 0 :(得分:0)

似乎你刚刚拼错了记录器名称的情况 试试

<logger name="xx.yy.zzzz.Controller" additivity="false">
 ...
</logger>

“控制器”是大写