Eclipse 4 logging [message #1805736] |
Mon, 22 April 2019 20:30  |
Eclipse User |
|
|
|
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 09:40  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.10394 seconds