
On Thu, May 24, 2012 at 9:01 AM, David Virdefors < david.virdefors@purplescout.se> wrote:
Hi,****
** **
I had a look at it. However it seemed to be outdated, and I really want to use the the existing ”Error Log” view. ****
I took a dive and figured it out. The first step is to add the external JARs to your project. I created a "libs" directory under my Eclipse plugin project, and symlinked the JARs there. Then I specified these project JARs with the "Bundle-ClassPath" property in the plugin's manifest. You can edit this classpath a couple ways: OPTION 1: Manually add "Bundle-ClassPath" property to META-INF/Manifest.MF like so: Bundle-ClassPath: ., libs/slf4j-api-1.6.4.jar, libs/logback-classic-1.0.3.jar, libs/logback-core-1.0.3.jar Add any other external JARs to this list if necessary. Note the first path is "." to tell the plugin to include its root directory in its classpath (it's not smart enough to assume that). OPTION 2: Use the Eclipse GUI to edit MANIFEST.MF. 1. Double-click META-INF/MANIFEST.MF, which automatically opens a GUI presenter for the file's contents. 2. Click the "Runtime" tab in the presenter. 3. In the "Classpath" section, click "New". In the prompt that opens, enter the relative path to the external JAR (e.g., libs/logback-core-1.0.3.jar). 4. Repeat step 3 for each external JAR. 5. Add the plugin's root directory to the classpath (click "New", and enter "."). 6. Sanity check: Click the "MANIFEST.MF" tab. Verify that the "Bundle-ClassPath" property contains the paths you just entered. See the attached sample project with this all working. I created the EclipseLogAppender class, which writes to Eclipse's Error Log. (It would be nice to add this class to logback's source, but it's dependent on Eclipse packages...not sure how to handle that.) To run the example: 1. From Eclipse, import the attached sample project (choose menu "File > Import... > Existing Projects into Workspace"). 2. Download logback-core-1.0.3.jar, logback-classic-1.0.3.jar, and slf4j-api-1.6.4.jar into the project's "libs" directory. 3. Rebuild and run the project (which opens a new instance of Eclipse). 4. From the new instance of Eclipse, open the Error Log (menu "Window > Show Views > Error Log"), and choose menu "Sample Menu > Sample Command". This causes a "Hello World" message box, followed by a log entry in the Error Log.