开发者

log select events into a separate file

Folks, I am working on analytics for my web application. The application runs on Tomcat 6. I would like to take log entries from a certain logger and put them into a log file of their own. These logs will later be picked up for Map/Reduce processing.

These are the steps I have taken so far:

  • In my Java code, I have cr开发者_如何学Ceated a logger specifically for analytics events: public static final Logger s_analyticsLogger = Logger.getLogger( "com.mm.analytics" );
  • I log analytics events using this logger: s_analyticsLogger.info( "This is an analytics log message" );
  • Following Tomcat 6 docs, I created a file myapp/WEB-INF/classes/logging.properties and added the following entries to it:

com.mm.analytics.handlers = org.apache.juli.FileHandler

org.apache.juli.FileHandler.level = FINE

org.apache.juli.FileHandler.directory = ${catalina.base}/logs/mm-analytics-logs

org.apache.juli.FileHandler.prefix = mm-analytics.

When I run with the above, I see no log file prefixed with mm-analytics created in the Tomcat logs folder. I have also tried moving the configuration entries to Tomcat/conf/logging.properties, but to no avail.

Does anyone know if this is a Tomcat documentation bug or am I doing something wrong?

Thanks.

-Raj


Does this subfolder which you've specified exist within logs?

 ${catalina.base}/logs/mm-analytics-logs

Update

I've replicated your problem, and the step I added to make it work for me was to add this

org.apache.juli.FileHandler to the existing handlers present in tomcat_home/conf/logging.properties . It is a comma-separated list, so just add it at the end.

Try this out and let me know. This creates an empty log file (0 Kb) when the app is started, and logs messages when the servlet is fired.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜