我有 Linux 服务器,我在其上使用我的axis2 webservice 运行tomcat。
我对 Log4j 使用以下内容:xml 配置文件,它与我的 webservice java 文件位于同一目录中。
XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//LOGGER" "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Appenders -->
<appender name="roll" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="file" value="~//..//tmp//CookTalesLog.log" />
<param name="append" value="true" />
<param name="encoding" value="UTF-8" />
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<!-- The file to roll to, this is a fairly intelligent parameter, if the file
ends in .gz, it gzips it, based on the date stamp it rolls at that time,
default is yyyy-MM-dd, (rolls at midnight)
See: http://logging.apache.org/log4j/companions/extras/apidocs/org/apache/log4j/rolling/TimeBasedRollingPolicy.html -->
<param name="FileNamePattern" value="CookTalesLog.%d.log.gz" />
</rollingPolicy>
<layout class="org.apache.log4j.PatternLayout">
<!-- The log message pattern -->
<param name="ConversionPattern" value="%5p %d{ISO8601} [%t][%x] %c - %m%n" />
</layout>
</appender>
<root>
<priority value="debug" />
<appender-ref ref="roll" />
</root>
</log4j:configuration>
在 java 代码中:我尝试使用以下每一行
private static final Logger sLogObj = Logger.getLogger( ICDBWebService.class );
private static final Log sLogObj = LogFactory.getLog(ICDBWebService.class);
也用过:
static
{
DOMConfigurator.configure( "log4j.xml" );
}
对于日志记录:
sLogObj.debug( "Login: email=" + email + " pwd= " + password );
未创建日志文件....
任何想法我做错了什么?