在Tomcat下使用Log4J/GWT时日志文件丢失
我已经创建了一个全新的GWT2.6.0项目在Tomcat下使用Log4J/GWT时日志文件丢失,tomcat,gwt,log4j,Tomcat,Gwt,Log4j,我已经创建了一个全新的GWT2.6.0项目 webappcreator -out TestLog4J com.example.testlog4j 我使用importexistingproject将其导入Eclipse 我将log4j-api-2.0.1.jar和log4j-core-2.0.1.jar复制到TestLog4J/war/WEB-INF/lib目录中,并将它们添加到构建路径中 然后在WEB-INF/lib中创建log4j2.xml,对吗 <?xml version="1.0"
webappcreator -out TestLog4J com.example.testlog4j
我使用importexistingproject将其导入Eclipse
我将log4j-api-2.0.1.jar和log4j-core-2.0.1.jar复制到TestLog4J/war/WEB-INF/lib目录中,并将它们添加到构建路径中
然后在WEB-INF/lib中创建log4j2.xml,对吗
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="trace" monitorInterval="30">
<Appenders>
<File name="Test" fileName="test.log">
<PatternLayout>
<Pattern>%d %p %c{1} [%t] %m%n</Pattern>
</PatternLayout>
</File>
</Appenders>
<Loggers>
<Root level="trace">
<AppenderRef ref="Test" />
</Root>
</Loggers>
</Configuration>
在课堂上
Logger logger = LogManager.getLogger(getClass());
在方法greetServer中
logger.info("xxxxxxx TEST MESSAGE xxxxxxxx);");
我使用
ant war
我使用localhost:8080上的网页将WAR文件加载并部署到Tomcat中
现在我运行应用程序,但是test.log文件在哪里???我哪儿都找不到
上面的代码有什么问题吗?检查log4j2.xml的路径,即检查该路径中的日志文件或web应用的根目录。它位于/Library/Tomcat/webapps/testlog4j/web-INF/lib/log4j2.xml中。我猜它放错地方了,但我不知道放在哪里?那么你找到了你的日志文件了吗?让我们看看。
ant war