Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Eclipse 4 logging(Exception throws in startup in Activator)
Eclipse 4 logging [message #1805736] Tue, 23 April 2019 00:30 Go to next message
Janusz Dalecki is currently offline Janusz DaleckiFriend
Messages: 63
Registered: January 2010
Location: Sydney
Member
Hi All,
I am trying to follow the tutorial "Eclipse Logging- Tutorial" by Lars Vogel and Simon Scholz - using Eclipse Photon, Java 1.8_0_121 windows 10. (https://www.vogella.com/tutorials/EclipseLogging/article.html).
I would like to be able to use slf4j API for logging purpose.
I have a function (taken from the tutorial) called 'configureLogbackExternal':
private void configureLogbackExternal(Bundle bundle) throws JoranException, IOException {
	    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
	    JoranConfigurator jc = new JoranConfigurator();
	    jc.setContext(context);
	    context.reset();

	    // overriding the log directory property programmatically
//	    String logDirProperty = "";// ... get alternative log directory location
//	    context.putProperty("LOG_DIR", logDirProperty);

	    // get the configuration location where the logback.xml is located
	    Location configurationLocation = Platform.getInstallLocation();
	    File logbackFile = new File(configurationLocation.getURL().getPath(), "logback.xml");
	    if(logbackFile.exists()) {
	        jc.doConfigure(logbackFile);
	    } else {
	        URL logbackConfigFileUrl = FileLocator.find(bundle, new Path("logback.xml"), null);
	        jc.doConfigure(logbackConfigFileUrl.openStream());
	    }
	}	


When the method 'Platform.getInstallLocation()' is called I get an exception:
Root exception:
org.eclipse.core.runtime.AssertionFailedException: assertion failed: The application has not been initialized.
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
	at org.eclipse.core.internal.runtime.InternalPlatform.assertInitialized(InternalPlatform.java:174)
	at org.eclipse.core.internal.runtime.InternalPlatform.getInstallLocation(InternalPlatform.java:340)
	at org.eclipse.core.runtime.Platform.getInstallLocation(Platform.java:1326)
	at config.Activator.configureLogbackExternal(Activator.java:101)
	at config.Activator.start(Activator.java:44)


Could somebody help me with this I don't know why the exception is generated.

Kind Regards,
Janusz
Re: Eclipse 4 logging [message #1805807 is a reply to message #1805736] Wed, 24 April 2019 13:40 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 865
Registered: January 2012
Senior Member

The platform maintains several "locations". It seems your bundle is being started before the primary Eclipse Platform bundle (org.eclipse.core.runtime) has been started: your bundle likely has a start-level that's less than that set for org.eclipse.core.runtime, so it's being started before org.eclipse.core.runtime. Change your start-level to be higher than the core.runtime.

Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:[RESOLVED] Core expression checking for project natures not working
Next Topic:AddOn does not execute
Goto Forum:
  


Current Time: Mon Dec 09 18:32:40 GMT 2019

Powered by FUDForum. Page generated in 0.01749 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top