2 know5978 know5978 于 2014.12.11 15:33 提问

启动时log4j报错,log4j应该怎么配置






<appender name="avatarAppender" class="org.apache.log4j.DailyRollingFileAppender">
    <param name="File" value="/data/applogs/tpfun-dealDuplicateCheck-job/logs/avatar.log" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="[tpfun-dealDuplicateCheck-job]%d %-5p [%c] %m%n" />
    </layout>
</appender>

<appender name="appAppender" class="org.apache.log4j.DailyRollingFileAppender">
    <param name="File" value="/data/applogs/tpfun-dealDuplicateCheck-job/logs/app.log" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="[tpfun-dealDuplicateCheck-job]%d %-5p [%c] %m%n" />
    </layout>
</appender>

<appender name="ibatisAppender" class="org.apache.log4j.DailyRollingFileAppender">
    <param name="File" value="/data/applogs/tpfun-dealDuplicateCheck-job/logs/ibatis.log" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="[tpfun-dealDuplicateCheck-job]%d %-5p [%c] %m%n" />
    </layout>
</appender>

<logger name="com.dianping.avatar" additivity="false">
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="avatarAppender" />
</logger>

<logger name="com.ibatis" additivity="false">
    <level value="WARN" />
    <appender-ref ref="ibatisAppender" />
</logger>

<logger name="java.sql">
    <level value="WARN" />
</logger>

<logger name="org.springframework.jms">
    <level value="ERROR" />
</logger>

<logger name="org.springframework.context">
    <level value="INFO" />
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="appAppender" />
</logger>

<root>
    <level value="INFO" />
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="appAppender" />
</root>

这是我的配置文件,报错为
log4j:WARN Fatal parsing error 2 and column 72
log4j:WARN 在 publicId 和 systemId 之间需要有空格。
log4j:ERROR Could not parse url [file:/D:/workspace/tpfun-job/tpfun-dealDuplicateCheck-job/target/classes/log4j.xml].
org.xml.sax.SAXParseException; systemId: file:/D:/workspace/tpfun-job/tpfun-dealDuplicateCheck-job/target/classes/log4j.xml; lineNumber: 2; columnNumber: 72; 在 publicId 和 systemId 之间需要有空格。
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:177)
at org.apache.log4j.xml.DOMConfigurator$2.parse(DOMConfigurator.java:612)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:711)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:618)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:470)
at org.apache.log4j.LogManager.(LogManager.java:122)
at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)
at com.dianping.avatar.log.slf4j.Slf4jLogger.(Slf4jLogger.java:38)
at com.dianping.avatar.log.slf4j.Slf4jLoggerBuilder.buildLogger(Slf4jLoggerBuilder.java:60)
at com.dianping.avatar.log.AvatarLoggerFactory.getLogger(AvatarLoggerFactory.java:90)
at com.dianping.tpfun.job.dealDuplicateCheck.App.(App.java:11)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:116)
log4j:WARN No appenders could be found for logger (com.dianping.tpfun.job.dealDuplicate.App).
log4j:WARN Please initialize the log4j system properly.

2个回答

shenlan0322
shenlan0322   2014.12.13 18:36

你贴的这个配置文件 没有publicId 和 systemId ,怎么就报log4j:WARN 在 publicId 和 systemId 之间需要有空格,让人怎么解决

huabiao5175
huabiao5175   2017.03.27 15:07
  • >




Csdn user default icon
上传中...
上传图片
插入图片