我被要求在我们的 RCP 应用程序上实现 PAX 日志记录。基本上我都是按照这个tutorial .
正如您可能注意到的,它表示“当您运行 RCP 应用程序时,您应该看到 Pax ConfMan 将输出记录到控制台”。请注意:可以找到配置文件夹,但这不是问题。
当我运行我的应用程序时,我得到以下控制台输出:
[Framework Event Dispatcher] DEBUG org.ops4j.pax.logging.pax-logging-service - BundleEvent STARTED
[Start Level Event Dispatcher] DEBUG org.apache.felix.fileinstall - ServiceEvent REGISTERED
[Start Level Event Dispatcher] DEBUG org.apache.felix.fileinstall - ServiceEvent REGISTERED
[Framework Event Dispatcher] DEBUG org.apache.felix.fileinstall - BundleEvent STARTED
[Start Level Event Dispatcher] DEBUG org.eclipse.equinox.cm - ServiceEvent REGISTERED
[Start Level Event Dispatcher] DEBUG org.eclipse.equinox.cm - ServiceEvent REGISTERED
[Start Level Event Dispatcher] DEBUG org.apache.felix.fileinstall - ServiceEvent REGISTERED
[Framework Event Dispatcher] DEBUG org.eclipse.equinox.cm - BundleEvent STARTED
[org.ops4j.pax.configmanager.internal.Activator] : Starting [org.ops4j.pax.configmanager]...
[Start Level Event Dispatcher] DEBUG org.ops4j.pax.configmanager - ServiceEvent REGISTERED
[org.ops4j.pax.configmanager.internal.ConfigurationAdminFacade] : Using configuration from [configurations]
[org.ops4j.pax.configmanager.internal.ConfigurationAdminFacade] : Using configuration from [configurations]
[org.ops4j.pax.configmanager.internal.ConfigurationAdminFacade] : Register configuration [org.ops4j.pax.logging]
我的问题是:如何摆脱这个控制台输出?
编辑 1 提出这个问题的原因是,理想情况下,我们不应该在启动时在控制台中看到任何内容,除非存在真正的问题,或者我们特别要求额外的日志记录。
编辑2 我注意到我们有一个 apache commons 日志依赖项。我认为它会引起某种冲突,所以我删除了它,但输出没有改变。
编辑3 问题仍然存在,目前等待任何反馈。
提前感谢您,如果我在问题格式上犯了任何错误,请道歉。
最佳答案
根据:https://ops4j1.jira.com/wiki/display/paxlogging/Configuration
您可以使用以下系统属性设置默认级别:
org.ops4j.pax.logging.DefaultServiceLog.level
所以像启动应用程序一样:
-Dorg.ops4j.pax.logging.DefaultServiceLog.level=WARN
可能就是您所需要的。
关于logging - 使用 PAX 日志记录时如何消除控制台中的日志记录启动消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24610095/