0
我有運行在播放框架1.2.5上的java應用程序。使用播放框架記錄多個文件
我想以這樣一種方式進行日誌記錄,即每個模塊都有自己的日誌文件,並且相應的模塊日誌記錄將在其自己的文件中。
這可能使用播放日誌?或者還有其他方法可以做到嗎? 任何幫助將不勝感激。
我有運行在播放框架1.2.5上的java應用程序。使用播放框架記錄多個文件
我想以這樣一種方式進行日誌記錄,即每個模塊都有自己的日誌文件,並且相應的模塊日誌記錄將在其自己的文件中。
這可能使用播放日誌?或者還有其他方法可以做到嗎? 任何幫助將不勝感激。
當然,這是可能的。您可以使用高級記錄器設置,使用apache log4j。默認情況下,Play!Framework使用apache log4j進行日誌記錄,請參閱this documentation。
# More logging configuration - config file located at the same level on this file
application.log.path=/log4j.properties
application.log.system.out=off
假設你有位於com.mymodule
和com.othermodule
包兩個模塊:
必須使用入門像啓用此先進的設置上application.conf
文件。所以如果你想使這些模塊記錄在不同的文件,你的log4j.properties
文件應該是這樣的:
# Define logging file appender for mymodule package
log4j.appender.mymodule=org.apache.log4j.FileAppender
log4j.appender.mymodule.File=mymodule.log
log4j.appender.mymodule.layout=org.apache.log4j.PatternLayout
# Define logging file appender for othermodule package
log4j.appender.othermodule=org.apache.log4j.FileAppender
log4j.appender.othermodule.File=othermodule.log
log4j.appender.othermodule.layout=org.apache.log4j.PatternLayout
log4j.logger.com.mymodule=INFO, package1
log4j.logger.com.othermodule=INFO, package2
更多參考,請嘗試從以下鏈接瞭解:
謝謝他LP! – user1630693 2013-04-11 17:08:31
如果答案對您有用。請接受這個答案作爲你的解決方案.. :) – 2013-04-12 01:33:58