We first struggle to get a good picture of logging and what this Felix
Logback was doing. So here's a picture that might help. And btw, if our
understanding is incorrect, please correct us.

[image: image.png]

On Tue, Sep 18, 2018 at 4:54 AM Raymond Auge <raymond.a...@liferay.com>
wrote:

> On Tue, Sep 18, 2018 at 4:42 AM Philipp Höfler <
> philipp.hoef...@pernexas.com>
> wrote:
>
> > Hallo Ray,
> >
> > thanks for your explanation.
> >
> > Based on the new information, I am trying to use Logback.
> > I actually made some progress, but still have one fundamental problem.
> >
> > I added the logback maven dependencies. I found some documentation from
> > you, saying that I also have to add sl4j as dependency.
> > Why is this necessary?
> >
>
> slf4j is just a compile dependency. It's the API "used" by logback.
>
>
> >
> > I set the configurationFile as runproperties and of course I added the
> > configuration file itself:
> > <configuration scan="true" scanPeriod="5 seconds">
> >
> >     <!-- defined a console append -->
> >     <appender name="FILE" class="ch.qos.logback.core.FileAppender">
> >         <file>myApp.log</file>
> >         <append>true</append>
> >         <immediateFlush>true</immediateFlush>
> >
> >         <encoder>
> >             <pattern>%-4relative [%thread] %-5level %logger{35} -
> > %msg%n</pattern>
> >         </encoder>
> >     </appender>
> >
> >     <!-- log all Bundle events -->
> >     <logger name="Events.Bundle" level="TRACE"/>
> >
> >     <!-- log WARN Framework service events of bundles whose BSN starts
> > with `org.eclipse.osgi` (guess who that is?) -->
> >     <logger name="Events.Service.org.eclipse.osgi" level="WARN"/>
> >
> >     <!-- log DEBUG Service events for bundles whose BSN starts with
> > `com.pernexas` -->
> >     <logger name="com.pernexas" level="DEBUG" />
> >
> >     <root level="ERROR">
> >         <appender-ref ref="FILE" />
> >     </root>
> > </configuration>
> >
> > Here is where the problem starts.
> > I do not get any log entry for any of the three configured packages,
>
> especially of "com.pernexas".
> >
>
> What logging API does it use?
>
>
> > BUT, when I set the root level to DEBUG I do get log entries from several
> > bundles (e.g. jetty). Unfortunately, I do not get any log from
> com.pernexas.
> >
> > I found also your Github project "osgi-to-logback". I am not sure, if
> this
> > is still necessary now, after the release of osgi r7 and new logback?
> > Especially as the project is archived.
> >
>
> That project is no longer valid. It was the basis of the contribution to
> Apache Felix. You should ignore it.
>
>
> >
> > Is it still necessary to add a configuration for a bundle in order to
> > configure the log level through config admin? I was hoping, that this is
> > now done by logback?
> >
>
> When using Felix Logback, I would start by having NO configurations for
> logging besides the logback.xml.
>
> I wonder if it would be possible to share something like a git(hub) project
> with me?
>
> - Ray
>
>
> >
> > Thanks for your patient help.
> > Philipp
> >
> >
> > Am 17.09.18, 15:22 schrieb "Raymond Auge" <raymond.a...@liferay.com>:
> >
> >     Philipp,
> >
> >     a) you don't need logback, but the Log Service spec doesn't define
> >     appenders per say, so you either have to provide your own LogListener
> >     implementation, fetch a LogStreamProvider and process the events, or
> > maybe
> >     the LogService implementation offers it's own appenders (my
> experience
> > has
> >     been that I want everything to land in the same place.)
> >     b) you can use configuration admin to configure log levels as per the
> > spec
> >     [1] which is to say that you create a configuration using the
> > following PID
> >     scheme [2].
> >
> >     *Note:* every bundle has it's own LoggerContext (mapped to a
> > configuration
> >     PID as described in [2]). There is also a ROOT context which is
> > effectively
> >     the fallback for everything (so you could use that as the singular
> >     configuration if you like.)
> >
> >     Logback support is really to unify all the different logging APIs
> into
> > a
> >     single backend because the stark reality is that you will encounter
> > other
> >     logging APIs if you spend enough time with your application and the
> > effort
> >     of handling each of those on it's own always causes pain. The goal of
> > Felix
> >     Logback is to make that scenario less painful.
> >
> >     Sincerely,
> >     - Ray
> >
> >     [1]
> > https://osgi.org/specification/osgi.cmpn/7.0.0/service.log.html#d0e2548
> >     [2]
> >
> >
> https://osgi.org/specification/osgi.cmpn/7.0.0/service.log.html#org.osgi.service.log.admin.LoggerContext.LOGGER_CONTEXT_PID
> >
> >     On Mon, Sep 17, 2018 at 5:25 AM Philipp Höfler <
> > philipp.hoef...@pernexas.com>
> >     wrote:
> >
> >     > Hi,
> >     >
> >     > with the latest update of the Felix SCR, I am able to get an
> > instance of
> >     > the LogService by referencing the LoggerFactory using this line of
> > code:
> >     > @Reference(service = LoggerFactory.class)
> >     > private Logger _logger;
> >     >
> >     > Now, I would have expected, that I can configure the LogService
> > through
> >     > the Web Console (Configuration Admin).
> >     > There is a menu LogService in the WebConsole and it says “Log
> > Service is
> >     > running”, but there is not one single log entry available nor can I
> > change
> >     > the log level of classes (or bundles).
> >     >
> >     > I found the documentation (
> >     >
> > http://felix.apache.org/documentation/subprojects/apache-felix-log.html)
> >     > and it says that it is possible to configure the logging through
> the
> >     > Configuration Admin.
> >     > But it’s not clear to me, what exactly I have to do.
> >     > Is it necessary to use LogBack (or any other logging framework)?
> > According
> >     > to my current understanding, I do not have to use an additional
> > logging
> >     > framework. Anyhow, do you recommend utilizing one?
> >     >
> >     > Obviously, I am missing something important.
> >     > Could somebody please give me an introduction on how to properly
> use
> > the
> >     > LogService. I think I make correctly use of it in the code, but I
> do
> > not
> >     > understand how to use/configure it after compilation.
> >     >
> >     > Thanks,
> >     > Philipp
> >     >
> >     >
> >
> >     --
> >     *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)
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
> > For additional commands, e-mail: users-h...@felix.apache.org
> >
>
>
> --
> *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)
>

Reply via email to