log select events into a separate file

半世苍凉 提交于 2019-12-25 03:19:27

问题


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 created 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


回答1:


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.



来源:https://stackoverflow.com/questions/4241689/log-select-events-into-a-separate-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!