将log4j包含在Eclipse 4(RCP / SWT / OSGi)应用程序中的正确方法 [英] Proper way to include log4j in an Eclipse 4 (RCP/SWT/OSGi) application

查看:106
本文介绍了将log4j包含在Eclipse 4(RCP / SWT / OSGi)应用程序中的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个后续行动(不知何故,我的 OSGi应用程序的第三方依赖关系)在哪里建议使用某些库log4j已经可用作为捆绑包。

在Eclipse Indigo中,我找不到可用于 Import Package 的log4j软件包作为零件我的安装,所以我从JAR存档创建了一个插件项目来捆绑log4j和一个功能项目来捆绑 log4j.xml 配置以下 post

This is a follow-up (somehow of my Third-party dependencies to an OSGi application) where it was suggested that some libraries e.g. log4j are already available as bundles.
In Eclipse Indigo I could not find a log4j bundle available to Import Package as part of my installation and so I created a Plugin Project from JAR archive to bundle log4j and also a Feature Project to bundle the log4j.xml configuration following this post.

说实话,我不明白为什么需要这个片段项目,但是这个过程是有效的。

所以我现在的问题是:

由于 log4j.xml 在导出中作为功能jar的一部分提供,因此需要一些努力才能找到它并更新调试级别,所以我想知道这是否是正确的过程?

我记得最终导出的产品将在一个易于找到的位置提供log4j配置,但现在(尽管日志记录工作)我是关心我是做什么,确实是正确的。

To be honest I don't understand why the fragment project is needed but this process works.
So my question now is:
Since the log4j.xml is delivered in the export as part of the feature jar, it requires some "effort" for someone to find it and update the debug levels, so I was wondering is this indeed the correct process?
I had in mind that the final exported product would deliver the log4j configuration in an easy to find location, but now (although the logging works) I am concerned whether what I do, is indeed correct.

在这里有任何帮助?

推荐答案

如果你真的需要公开该文件,您可以把它放在任何你想要的地方,然后确保您的程序在启动时调用这些方法之一:

If you really need to expose the file, you could put it anywhere you want, and then make sure your program calls one of these methods at startup:

  • org.apache.log4j.xml.DOMConfigurator.configure(String filename)
  • org.apache.log4j.PropertyConfigurator.configure(String configFilename)

如果您想在不重新启动应用程序的情况下更改配置,请使用configureAndWatch变量。

Or use the "configureAndWatch"-variants if you would like to make changes to the config without restarting your application.

编辑:我写如果真的需要,因为我经历过我从来不需要打开调试在部署后记录,因为它始终打开!对于响应时间和吞吐量的正常(但不是极端)要求的应用程序,这是可行的。登录到UDP-appender是快速的(不填满磁盘)。或使用滚动文件appender是相当安全的,足够快我的使用。始终提供调试日志是一个救命员,当这些难以重现的错误。

Edit: I write "If you really need to", because I have experienced that I never need to turn on debug-logging after deployment, because it is always turned on! This is OK for applications where I have normal (but not extreme) requirements on response-time and throughput. Logging to an UDP-appender is fast (and does not fill up the disk). Or using rolling file appender is quite safe, and fast enough for my use. Always having the debug-log available is a life-saver when nailing down those hard-to-reproduce bugs.

这篇关于将log4j包含在Eclipse 4(RCP / SWT / OSGi)应用程序中的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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