我查看了網絡,無法找到一個易於遵循的指南,爲Google App Engine啓用Log4j2。作爲新功能..我發現可能相關的3個主要文件。在Google App Engine中配置Log4j2
1)應用服務引擎-web.xml中 2)的Log4j.properties 3)log4j2.xml
我Log4j.properties如下所示:(這已被包含在WEB-INF)
log4j.appender.toFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.toFile.File=./log/logfile.log
log4j.appender.toFile.DatePattern='.'
log4j.appender.toFile.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=% %-5p [%t] - %c.%M - %m%n
我說雖然runng Java應用程序下面的AppEngine上-web.xml中
<!-- Configure apache Log4J Logging -->
<system-properties>
<property name="org.apache.logging.log4j.config.file" value="WEB- INF/log4j.properties"/>
</system-properties>
,我得到的錯誤。
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
我的意圖是將條目記錄到文件中。任何指向我可以在其中找到專門針對Google App Engine的示例的指針。
獨立於您的log4j2配置的位置,您無法登錄到App Engine上的文件。請參閱:http://stackoverflow.com/questions/2693081/does-google-app-engine-allow-creation-of-files-and-folders-on-the-server。我讓我的答案反映了這一點,並建議你使用一個日誌門面的可重用性(如果這是你的問題)。可悲的是我對此感到低落。 – konqi