-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging Example #58
Comments
This is true, logging has seen a big overhaul in R7.
The best person to give answers about this is @rotty3000 who has been doing a lot of work with R7 logging. He's probably also the best person to produce an additional enRoute example. |
thanks for your answer @timothyjward. It seems that you're involved in every project around osgi :-) Thank you |
:) I'll try to put something together in the next couple of weeks.
…On Tue, Jun 12, 2018 at 10:39 AM, Tim Ward ***@***.***> wrote:
I saw, that the Logging mechanism has been improved for the R7 compendium.
This is true, logging has seen a big overhaul in R7.
Do I have to build the bridge between the interface and the implementation
or is there something ready to go?
The best person to give answers about this is @rotty3000
<https://github.com/rotty3000> who has been doing a lot of work with R7
logging. He's probably also the best person to produce an additional
enRoute example.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#58 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAI9TBu-J5dXcBMk9BLyiPQMe6FMLmWvks5t79KfgaJpZM4UkLic>
.
--
*Raymond Augé* <http://www.liferay.com/web/raymond.auge/profile>
(@rotty3000)
Senior Software Architect *Liferay, Inc.* <http://www.liferay.com>
(@liferay)
Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org> (@OSGiAlliance)
|
@rotty3000, thank your for your very quick reply :-) I understand the following: Thanks for your help :-) |
Did you look in the DS 1.4 spec? It has code snippets for using the new
Logger with DS.
The RFC for the log update is old and superseded by the R7 spec.
On Tue, Jun 12, 2018 at 09:01 phhoef ***@***.***> wrote:
@rotty3000 <https://github.com/rotty3000>, thank your for your very quick
reply :-)
Could you give me a short answer, how to use the logging service, so that
I am able to proceed in the meanwhile?
I understand the following:
One should use the new Logger interface to be compatible with other
bundles like ConfigAdmin.
But of course, the interface does not provide the implementation. What I
don't get is, if there is a library out there like log4j etc that is
already implementing this interface and I can just add this bundle as
dependency or do I have to implement the bridge between the interface and
the logging library myself?
Obviously there is no default implementation, otherwise I would have
expected that OSGi can reference this service based on the @reference
annotation, right?
There is another point I do not completely understand. In the
specification is mentioned, that the new interface is similar to the slf4j
one. But do I have to use slf4j now or is it just a comparison to show the
approach?
Thanks for your help :-)
OSGi is quite confusing in some points for a beginner.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#58 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAQ8sltnB9L6_fnyxeNbSXXeOMNtHaIlks5t79exgaJpZM4UkLic>
.
--
BJ
|
At least I thought, I had :-) There is a short example in the I've added a field of type |
As the example in the specification shows, you need to set the type of the reference to
|
this
is currently not working on Felix SCR. |
@timothyjward, sorry for confusion. I had set the service interface explicitly, but checked in the wrong version. @rotty3000 so, you recommend using another SCR or is there any chance to get this working with Felix SCR? |
There isn't another DS impl that implements logging support to my knowledge. I've filled a bug with Felix https://issues.apache.org/jira/browse/FELIX-5865 which is already being worked on and I'm verifying a few other things. Please watch this space. This part of the DS and logging spec is new, the RIs are not yet totally stable so it will require a little patience. :) |
thanks for the explanation @rotty3000. |
You can do this:
However you still need a Log Service 1.5 (which is only available by equinox framework). |
That will work, but the issue will become log configuration. Until this whole logging story resolves itself. I would recommend to simply use the slf4j API which has OSGi support. I believe enRoute already has logback and the slf4j API available in it's templates. I would just go with that for the time being. |
thanks for your suggestion, but that confuses me. So it would look something like this: |
just like this:
|
Thank you all for your help |
FYI, once the next release of Felix SCR is made the logging pattern suggested in the R7 DS spec will work (though bind and constructor injection patterns will need to wait until bnd supports DS 1.4):
|
Hello, I have set the configuration for my bundle to Info via Configuration Admin Service and during debugging I see that the logger has the right context, name and the desired LogLevel INFO. if (log.isInfoEnabled()) { Unfortunately the message is not displayed on the console. Do I still have to configure a console appender? Jetty writes debug messages out a lot. And they can't be limited. I used to log to the console myself using LogListener. Is that still the case? Many thanks and greetings |
The OSGi Log Service distributes logged information to registered LogServiceReader services or active PushStreams from the LogStreamProvider service. So you will still need a way to display logged information. You may want to look at Apache Felix Logback which does a nice job of integration the OSGi Log Service 1.4 with Logback. |
Thank you very much, so far so good. Then I have to implement my own LogServiceReader which is parameterized by ConfigurationAdmin and not externally by the logback.xml. Greeting |
Could you please add a small example, that shows how to use the new, improved logging mechanism in OSGi R7.
I built a small OSGi application based on this tutorial. https://github.com/osgi/osgi.enroute/tree/master/examples/microservice
I saw, that the Logging mechanism has been improved for the R7 compendium. https://github.com/osgi/design/blob/master/rfcs/rfc0219/rfc-0219-LogService-Update.pdf on page 12
So, I added a field in my my controller class of the rest-service project.
@Reference private org.osgi.service.log.Logger _logger;
Unfortunately, OSGi is not resolving this
@Reference
and the field is alwaysnull
.I am quite new to the OSGi stuff, but as far as I understand the whole thing, I have to add a logging library, that implements this interface. Unfortunately I cannot find a library like log4j, logback, etc that implements the new interface. Do I have to build the bridge between the interface and the implementation or is there something ready to go?
The text was updated successfully, but these errors were encountered: