Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Can we have logback as the default logging implementation of pax-logging-service and have a way to load custom appender?

      We want to create a log appender with custom threading control and found that we can't with log4j 1.x (https://issues.apache.org/jira/browse/LOG4J2-3). Karaf's pax-logging-service uses (slf4j+log4j), so we replaced pax-logging-logback. But we find it difficult to do because pax-logging-logback embeds Logback jars inside the bundle without exporting packages and faced with osgi class loading issues. We can do it by defining custom appender fragment for pax-logging-logback host at startup.properties and set the org.ops4j.pax.logging.cfg for logback configuration. But we find that is not convenient for development for having to copy updated Jars to <kavaf_home>/system folder in every iteration.

      We are wondering if there is better way dynamically add the appender when we install our bundle on a standard Karaf distribution?

        Activity

        Hide
        gcollins Gareth Collins added a comment -

        PaxAppender does not get passed markers, does it (markers are only supported by logback and log4j 2)?

        Show
        gcollins Gareth Collins added a comment - PaxAppender does not get passed markers, does it (markers are only supported by logback and log4j 2)?
        Hide
        jbonofre Jean-Baptiste Onofré added a comment -

        I discussed with Guillaume about that.

        1/ thanks for Pax Logging 1.7.0 (and the support of OSGi services "registration"), it's possible to create a logback appender that implement an interface provided by pax-logging, and register it as a service. This part should be documented.
        2/ on the other hand, an interesting improvement can be added to pax-logging: a wrapper that implements the pax-logging interface using an existing appender.

        Show
        jbonofre Jean-Baptiste Onofré added a comment - I discussed with Guillaume about that. 1/ thanks for Pax Logging 1.7.0 (and the support of OSGi services "registration"), it's possible to create a logback appender that implement an interface provided by pax-logging, and register it as a service. This part should be documented. 2/ on the other hand, an interesting improvement can be added to pax-logging: a wrapper that implements the pax-logging interface using an existing appender.
        Hide
        gnt Guillaume Nodet added a comment -

        If you use PaxAppender, you can deploy it as an OSGi service instead of using fragments. That's how it's done in Karaf, and the paxlogging api has been recently enhanced to also support custom layouts, filters and error handlers.

        Show
        gnt Guillaume Nodet added a comment - If you use PaxAppender, you can deploy it as an OSGi service instead of using fragments. That's how it's done in Karaf, and the paxlogging api has been recently enhanced to also support custom layouts, filters and error handlers.
        Hide
        achim_nierbeck Achim Nierbeck added a comment -

        yep, I wrote a blog about it.

        Show
        achim_nierbeck Achim Nierbeck added a comment - yep, I wrote a blog about it.
        Hide
        powerpk Phyo Kyaw added a comment -

        We didn't experiment with pax logging. If log4j is fixed in paxlogging, can we just extend org.ops4j.pax.logging.spi.PaxAppender in a fragment to add our custom thread safe appender?

        Show
        powerpk Phyo Kyaw added a comment - We didn't experiment with pax logging. If log4j is fixed in paxlogging, can we just extend org.ops4j.pax.logging.spi.PaxAppender in a fragment to add our custom thread safe appender?
        Hide
        gnt Guillaume Nodet added a comment -

        Did you experiment with paxlogging ? The threading issues have been fixed in the custom version of log4j which is embedded.

        For custom appenders, paxlogging has a dedicated api you can use so that it's independant of the backend being log4j or logback.

        Show
        gnt Guillaume Nodet added a comment - Did you experiment with paxlogging ? The threading issues have been fixed in the custom version of log4j which is embedded. For custom appenders, paxlogging has a dedicated api you can use so that it's independant of the backend being log4j or logback.

          People

          • Assignee:
            Unassigned
            Reporter:
            kdong Keren Dong
          • Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

            • Created:
              Updated:

              Development