| Some questions about logging [message #662013] |
Mon, 28 March 2011 17:17  |
Karl Weber Messages: 63 Registered: September 2010 |
Member |
|
|
I apologize for re-posting this in the right forum. I accidentally posted it in an inappropriate forum before.
In e4 there are two ways to log something:
- The org.eclipse.e4.core.services.log.Logger
- The org.osgi.service.log.LogService
As far as I understand it, these two things seem to be related in the sense that the first uses the second, i.e. the org.eclipse.e4.core.services.log.Logger uses the org.osgi.service.log.LogService. Is this correct?
I observed at least the following: If an RCP application uses some pure OSGi bundles that do not know anything but the OSGi specification and, thus, use the LogService, the messages end up in the same log file as the messages generated with the Logger. Is this part of the eclipse "API", i.e. will this always be the case, or is this a mere "accident"?
If this behaviour is intended, I do not understand why the OSGi specification is not strictly implemented: The LogService has two kinds of logging methods, e.g.
// first way
fLogService.log(LogService.LOG_ERROR, "This is my first log message");
//second way
fLogService.log(serviceReference, LogService.LOG_ERROR, "This is my first log message");
If I did not make a(nother) mistake, the LogEntry in the log file does not contain any service reference. I am no OSGi expert, but wouldn't this be a violation of the OSGi specification? Someone could get the log entries via org.osgi.service.log.LogReaderService.getLog(). This should return the log entries from the log file. The OSGi specification does not require this method to return all log entries. But I would expect that the log entries it does return are "complete".
Another point is that log entries created with the LogService correctly show the originating bundle while log entries created with the Logger all seem to show the bundle org.eclipse.e4.ui.workbench. This should be a bug or shouldn't it?
Or am I all wrong about this logging?
|
|
|
| Re: Some questions about logging [message #662027 is a reply to message #662013] |
Mon, 28 March 2011 18:54   |
Thomas Schindl Messages: 4462 Registered: July 2009 |
Senior Member |
|
|
Hi Karl,
I worked on the logging stuff some time before the 4.0 release to only
make it a bit more useable.
The logger you are seeing is the one the org.eclipse.e4.ui.workbench
injected into to context. Instead you should inject yourself the
ILoggerProvider which allows you to create a specific logger for this
class similar to the Logger.getLogger() works in case of log4j.
The API of the Logger we provide does NOT necessarily use the
OSGi-LogService (our default implementation though does) but should be
able to get replaced e.g. through log4j, ... .
Tom
Am 28.03.11 14:17, schrieb Karl Weber:
> I apologize for re-posting this in the right forum. I accidentally
> posted it in an inappropriate forum before.
>
> In e4 there are two ways to log something:
>
> The org.eclipse.e4.core.services.log.Logger
> The org.osgi.service.log.LogService
>
> As far as I understand it, these two things seem to be related in the
> sense that the first uses the second, i.e. the
> org.eclipse.e4.core.services.log.Logger uses the
> org.osgi.service.log.LogService. Is this correct?
>
> I observed at least the following: If an RCP application uses some pure
> OSGi bundles that do not know anything but the OSGi specification and,
> thus, use the LogService, the messages end up in the same log file as
> the messages generated with the Logger. Is this part of the eclipse
> "API", i.e. will this always be the case, or is this a mere "accident"?
>
> If this behaviour is intended, I do not understand why the OSGi
> specification is not strictly implemented: The LogService has two kinds
> of logging methods, e.g.
>
> // first way
> fLogService.log(LogService.LOG_ERROR, "This is my first log message");
> //second way
> fLogService.log(serviceReference, LogService.LOG_ERROR, "This is my
> first log message");
>
> If I did not make a(nother) mistake, the LogEntry in the log file does
> not contain any service reference. I am no OSGi expert, but wouldn't
> this be a violation of the OSGi specification? Someone could get the log
> entries via org.osgi.service.log.LogReaderService.getLog(). This should
> return the log entries from the log file. The OSGi specification does
> not require this method to return all log entries. But I would expect
> that the log entries it does return are "complete".
>
> Another point is that log entries created with the LogService correctly
> show the originating bundle while log entries created with the Logger
> all seem to show the bundle org.eclipse.e4.ui.workbench. This should be
> a bug or shouldn't it?
>
> Or am I all wrong about this logging?
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.09066 seconds