Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-5444

Unable to use Log4j2 ContextMapLookup with pax-logging

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 4.1.2
    • None
    • karaf
    • None
    • Important

    Description

      ContextMapLookup has been worked fine using escaped

      ${ctx:xxx}

      placeholder in log4j config, but in karaf 4.1.2 it doesn't work anymore.

      To replicate the issue, add this properties in etc/org.ops4j.pax.logging.cfg trying to setup a single log file per bundle:

      log4j2.appender.bundle.type = Routing
      log4j2.appender.bundle.name = RoutingByBundle
      log4j2.appender.bundle.routes.type = Routes
      log4j2.appender.bundle.routes.pattern = \$\$\\\{ctx:bundle.name\}
      log4j2.appender.bundle.routes.bundlename.type = Route
      log4j2.appender.bundle.routes.bundlename.appender.type = RandomAccessFile
      log4j2.appender.bundle.routes.bundlename.appender.name = RandomAccessFile-\$\\\{ctx:bundle.name\}
      log4j2.appender.bundle.routes.bundlename.appender.fileName = ${karaf.data}/log/karaf.\$\\\{ctx:bundle.name\}-\$\\\{ctx:bundle.id\}.log
      log4j2.appender.bundle.routes.bundlename.appender.append = true
      log4j2.appender.bundle.routes.bundlename.appender.layout.type = PatternLayout
      log4j2.appender.bundle.routes.bundlename.appender.layout.pattern = [%d{ISO8601}][%-5.5p][%t] - %m%n
      
      log4j2.rootLogger.appenderRef.RoutingByBundle.ref = RoutingByBundle
      

      Configuration works, but restarting karaf empty values replace placeholders in config settings, breaking configuration:

      log4j2.appender.bundle.type = Routing
      log4j2.appender.bundle.name = RoutingByBundle
      log4j2.appender.bundle.routes.type = Routes
      log4j2.appender.bundle.routes.pattern = $
      log4j2.appender.bundle.routes.bundlename.type = Route
      log4j2.appender.bundle.routes.bundlename.appender.type = RandomAccessFile
      log4j2.appender.bundle.routes.bundlename.appender.name = RandomAccessFile-
      log4j2.appender.bundle.routes.bundlename.appender.fileName = /home/rolag/Desktop/apache-karaf-4.1.2/data/log/karaf.-.log
      log4j2.appender.bundle.routes.bundlename.appender.append = true
      log4j2.appender.bundle.routes.bundlename.appender.layout.type = PatternLayout
      log4j2.appender.bundle.routes.bundlename.appender.layout.pattern = [%d{ISO8601}][%-5.5p][%t] - %m%n
      
      log4j2.rootLogger.appenderRef.RoutingByBundle.ref = RoutingByBundle
      

      Attachments

        Issue Links

          Activity

            People

              gnodet Guillaume Nodet
              rolag Rocco Lagrotteria
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: