开发者

Howto reach logback.xml in an Eclipse RCP plugin?

开发者 https://www.devze.com 2023-03-07 12:30 出处:网络
I created an Eclipse RCP \"Hello World\"-Plugin, it\'s running and showing me the main window, then I created a second plugin called \"logging\" with the logback libraries and added this logging-plugi

I created an Eclipse RCP "Hello World"-Plugin, it's running and showing me the main window, then I created a second plugin called "logging" with the logback libraries and added this logging-plugin as a dependency to the main plugin.

The main plugin now knows the logger-classes, and I can use them, but how do I reach the "logback.xml"-file from the main plugin? This file is stored in the "resources"-folder in the logging-plugin.

-mainplugin   <---knows logging classes, but not reaching log开发者_Go百科back.xml
-logging
|-libs 
|-resources
  |-logback.xml    


logback.xml is a configuration file for your logging, the one where you set log level ect. ... right? In this case it belongs to the mainplugin, not to the logging plugin (which would only expose the methods of the jar file in the libs folder).

Like this:

-mainplugin
|-resources
  |-logback.xml
-logging
|-libs 

In order to work you would have to set buddy policies in your plugins and lockback.xml have to be in the classpath (!). This is required to allow the logging plugin to find the lockback.xml inside your plugin without to have a direct dependency.

in the MANIFEST.MF of the logging plugin you would have to add:

Eclipse-BuddyPolicy: registered

In the MANIFEST.MF of your mainplugin you would have to add:

Eclipse-RegisterBuddy: org.logplugin.id

with org.logplugin.id being the id of your logging plugin.

For more information: http://www.eclipsezone.com/articles/eclipse-vms/


A more introductory, including another two approaches, is described at http://devblog.virtage.com/2012/07/logback-and-eclipse-attaching-logback-xml/.

0

精彩评论

暂无评论...
验证码 换一张
取 消