为 Google 应用程序引擎开发应用程序时访问本地主机(码头)上的 servlet 日志
我正在使用 Google 应用程序引擎对 java servlet 应用程序进行原型设计。在本地主机上测试时,有什么方法可以访问 log4j servlet 日志吗?例如,如果我使用 Logger
类实例,并在 HttpServlet::doGet()
方法中调用 log.info("Request comes");
我想在开发过程中使用tail+grep或其他工具来分析日志。这些日志是否保存到某个文件中?如果无法使用外部工具,我希望至少在 Eclipse 控制台 输出中查看日志。
当应用程序部署到 Google (http://appengine.google.com/) 云中时,我可以通过 Web 界面查看我的日志,但在开发过程中我需要访问本地主机。
I am prototyping an java servlet application using Google application engine. Is there any way how I can access the log4j servlet logs in when testing on localhost? E.g. if I use the Logger
class instance and I call log.info("Request comes");
in HttpServlet::doGet()
method I would like to use the tail+grep or other tools to analyze the logs during the development. Are those logs saved into some file? If using external tools is not possible I would like to see the logs at least into Eclipse console output.
When the application is deployed into Google (http://appengine.google.com/) cloud I can see my logs via web interface, but I need the access on localhost during the development.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Log4j 很容易配置,我想您知道需要将“log4j.properties”添加到您的类路径等中?换句话说,它有良好的文档,请参阅配置堵塞。
如果需要将日志放入文件中,只需添加:
where
/path/to/logfile.log
if log you can tail+grep将其放入 Eclipse 控制台(我猜测这只是一个控制台输出),您必须添加:
并且不要忘记将此附加程序添加到记录器中,例如添加到根记录器中:
Log4j is easily configurable, I guess you know that you need to add `log4j.properties' into your classpath, etc? Other way, it have good documentation, see Configuration block.
If you need to put log into file, just add:
where
/path/to/logfile.log
if log you can tail+grepTo put it into eclipse console (I guess it's just a console output), you have to add:
and don't forget about adding this appenders into an logger, for example into root logger: