1

我尝试使用axis1部署Web服务并在我的Web服务类log4j记录器中使用

private static final Logger logger = Logger.getLogger(MobileService.class
            .getName());

logger.debug("Count nodes" + nodes.getLength());

我的班级有默认包。我使用下一个 log4j.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

    <appender name="HTML-APPENDER" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="File" value="${catalina.home}/webapps/axis/WEB-INF/classes/log.html" />
        <param name="DatePattern" value="'.'yyyy-MM-dd-HH'.html'" />
        <layout class="org.apache.log4j.HTMLLayout" />
        <filter class="org.apache.log4j.varia.LevelRangeFilter">
            <param name="LevelMin" value="ALL"/>
            <param name="LevelMax" value="INFO"/>
        </filter>
    </appender>

</log4j:configuration>

我还添加了类路径以部署我的应用程序

set CATALINA_HOME=C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0
set PATH_TO_LOG4J=C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\webapps\axis\WEB-INF\classes\log4j.xml
java -Dlog4j.info -Dlog4j.configuration="file:C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\webapps\axis\WEB-INF\classes\log4j.xml" -cp "%CATALINA_HOME%\webapps\axis\WEB-INF\lib\axis.jar;%CATALINA_HOME%\webapps\axis\WEB-INF\lib\jaxrpc.jar;%CATALINA_HOME%\webapps\axis\WEB-INF\lib\commons-logging-1.0.4.jar;%CATALINA_HOME%\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar;%CATALINA_HOME%\webapps\axis\WEB-INF\lib\commons-discovery-0.2.jar;%CATALINA_HOME%\webapps\axis\WEB-INF\lib\saaj.jar;%CATALINA_HOME%\common\lib\activation.jar;%CATALINA_HOME%\common\lib\mail.jar;%CATALINA_HOME%\webapps\axis\log4j-1.2.8.jar" org.apache.axis.client.AdminClient -lhttp://localhost:8080/axis/services/AdminService MobileService.wsdd
pause

但甚至-Dlog4j.info -Dlog4j.configuration=对我没有帮助。我得到错误no appenders could be found for logger (org.apache.axis.i18n.projectresourcebundle)

你能帮助我吗?

4

1 回答 1

2

我想,你忘了配置记录器。例如,要配置根记录器,请将以下行放在 log4j.xml 文件的末尾(之前</log4j:configuration>):

<root> 
    <priority value ="debug" /> 
    <appender-ref ref="HTML-APPENDER" /> 
</root>
于 2012-10-23T08:16:40.417 回答