如何在 Eclipse 插件中配置 java.util.logging?
我是创建插件的新手,有很多我不明白的地方。这些谜团之一就是伐木。
我有遗留代码,我希望能够在插件和旧的独立代码中使用它们。此代码使用 java.util.logging。
我通过使用 JVM 选项 -Djava.util.logging.config.file=/completelySpecifiedPath/logging.properties
启动新工作台来调试插件。 logging.properties 文件似乎已被读取,因为正在写入 java.util.logging.FileHandler.pattern 指定的文件。不幸的是,我通过 java.util.logging.FileHandler.formatter 指定的自定义格式化程序似乎没有被调用;文件中的输出看起来像是默认的 XML 格式。日志记录在遗留代码中工作正常,即使用我的自定义格式化程序。
我想知道的一件事是插件如何处理日志依赖项。我是否需要在 MANIFEST.MF 中显式输入一些日志依赖项?我不明白 Eclipse 如何为我计算依赖关系,因为依赖关系不在代码中,而是在logging.properties 文件中。此外,是否有可能或值得说 java.util.logging 取决于我的类?
任何帮助和/或想法将不胜感激。
干杯, 基思
I am new to creating plug-ins, and there's much that I don't understand. One of these mysteries is logging.
I have legacy code that I want to be able to use both within the plug-in and in the old standalone code. This code uses java.util.logging.
I debug my plug-in by starting up a new workbench using a JVM option -Djava.util.logging.config.file=/completelySpecifiedPath/logging.properties
. The logging.properties file appears to be read, because the file specified by java.util.logging.FileHandler.pattern
is being written. Unfortunately, the custom formatter that I specified via java.util.logging.FileHandler.formatter
does not seem to get called; the output in the file is in what looks to be a default XML format. The logging works okay in the legacy code, i.e., my custom formatter gets used.
One thing I am wondering about is how the plug-in handles the logging dependencies. Is it possible that I need to explicitly enter some logging dependencies in MANIFEST.MF? I don't see how Eclipse could calculate the dependency for me, because the dependency isn't in code, rather it's in the logging.properties file. Furthermore, is it possible or desirable to say that java.util.logging depends on my class?
Any help and/or ideas would be much appreciated.
Cheers,
Keith
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎是一个 Eclipse bug,不会得到任何修复时间很快。如果您想使用自定义格式化程序,则需要在代码中指定它,而不是使用logging.properties。
This appears to be an Eclipse bug that won't be fixed any time soon. If you want to use a custom formatter, you'll need to specify it in code, rather than by using logging.properties.