将选择事件记录到单独的文件中 [英] log select events into a separate file

查看:88
本文介绍了将选择事件记录到单独的文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们, 我正在为我的Web应用程序进行分析.该应用程序在Tomcat 6上运行.我想从某个记录器中获取日志条目,并将其放入自己的日志文件中.这些日志稍后将被提取以进行Map/Reduce处理.

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:

  • 在我的Java代码中,我创建了一个专门用于分析事件的记录器:public static final Logger s_analyticsLogger = Logger.getLogger( "com.mm.analytics" );
  • 我使用以下记录器记录分析事件:s_analyticsLogger.info( "This is an analytics log message" );
  • 在Tomcat 6文档之后,我创建了一个文件myapp/WEB-INF/classes/logging.properties,并向其中添加了以下条目:
  • 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

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

org.apache.juli.FileHandler.level =精细

org.apache.juli.FileHandler.level = FINE

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

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

org.apache.juli.FileHandler.prefix =毫米分析.

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

使用上述命令运行时,没有看到在Tomcat日志文件夹中创建以mm-analytics为前缀的日志文件.我也曾尝试将配置条目移至Tomcat/conf/logging.properties,但无济于事.

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.

有人知道这是Tomcat文档错误还是我做错了事?

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

谢谢.

-Raj

推荐答案

您指定的此子文件夹在日志中是否存在?

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

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

更新

我已经复制了您的问题,为使它对我有用,我添加的步骤是添加此问题

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

org.apache.juli.FileHandlertomcat_home/conf/logging.properties中存在的现有handlers.这是一个逗号分隔的列表,因此只需将其添加在末尾即可.

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.

尝试一下,让我知道.启动应用程序时,这将创建一个空的日志文件(0 Kb),并在触发servlet时记录消息.

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.

这篇关于将选择事件记录到单独的文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆