M2e log while debugging Eclipse plug-ins

This post is targeting Eclipse plug-in developers..If you are creating Eclipse plug-ins and debugging them using the PDE, you might have seen that recently the console is full of garbage coming from m2e (Maven/Eclipse integration), like:
2015-03-09 21:38:43,210 [Worker-17] INFO o.e.m.c.i.l.LifecycleMappingFactory - Using org.eclipse.m2e.jdt.JarLifecycleMapping lifecycle mapping for MavenProject: com.darwino:dwo-jre-jdbc-pool-dbcp:0.0.1-SNAPSHOT @ C:\phildev\Workspace-luna\darwino-platform\darwino\parent-dwo-core\parent-dwo-jre\dwo-jre-jdbc-pool-dbcp\pom.xml.
That's makes the console unpractical, particularly because m2e is now bundled with Eclipse. You get your own log completely diluted within this debug information.
I reported it to the m2e team a while ago, see: https://dev.eclipse.org/mhonarc/lists/m2e-users/msg05102.html, where the issue was identified as an SLF4J configuration in Eclipse. But as of Mars 4.5.2, the problem still exists. So I took Igor's suggestion and added the following snippet to one of my plug-in Activator:
@Override
public void start(BundleContext bundleContext) throws Exception {
super.start(bundleContext);

// Activate m2e configuration to load the logging options
try {
Bundle m2eLog = Platform.getBundle("org.eclipse.m2e.logback.configuration");
if(m2eLog.getState()!=Bundle.ACTIVE) {
m2eLog.start();
}
} catch(BundleException ex) {
// Ok, might take too much time to start
}
That did the trick and I'm no longer seeing the m2e log. So add that to your own plug-in, at least during debug, and your experience will be back to normal.


Comments