Uploaded image for project: 'Couchbase Java Client'
  1. Couchbase Java Client
  2. JCBC-1802

setup core-io-deps and core-io logging for osgi

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.2.0
    • None
    • None
    • 1

    Description

      When using in osgi (karaf), I had difficulty configuring the logging.

      I used this in the Activator to get the logging core-io-deps to work. 

      InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
       System.setProperty("log4j.configuration", "file:///Users/michaelreiche/log4j.properties");
      

       log4j.properties

      # Root logger option
      log4j.rootLogger=TRACE, stdout
       
      # Direct log messages to stdout
      log4j.appender.stdout=org.apache.log4j.ConsoleAppender
      log4j.appender.stdout.Target=System.out
      log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
      log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

       

      ==========================================================================

       Additions to apache karaf cong.properties :

      to org.osgi.framework.bootdelegation , add :
       
           javax.security.sasl, \
           javax.security.auth.*, \
           javax.crypto, \
           javax.crypto.spec, 

      ========================================================================== I modified LoggingEventConsumer.createLogger() to use a CONSOLE logger (that has trace and debug enabled)

       

      Logger logger; 
      if (loggerConfig.customLogger() != null){
       logger = loggerConfig.customLogger();
       System.out.println("CUSTOM LOGGER: "+logger); 
      }
      else if ( false && SLF4J_AVAILABLE && !loggerConfig.disableSlf4J()){ // not this
       logger = new Slf4JLogger(name); 
       System.out.println("SLF4J LOGGER: "+logger); }
      else if ( true || loggerConfig.fallbackToConsole()){ // use this
       logger = new ConsoleLogger(name); 
       System.out.println("CONSOLE LOGGER: "+logger); }
      else { 
       logger = new JdkLogger(name);
       System.out.println("JDK LOGGER: "+logger);
      }
      

      ==================================================

      Also, include these dependencies in the pom :

       

      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-log4j12</artifactId>
         <version>1.7.30</version>
      </dependency>
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-api</artifactId>
         <version>1.7.30</version>
      </dependency><dependency>
         <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-slf4j-impl</artifactId>
         <version>${log4j-slf4j-impl.version}</version>
      </dependency>
      <dependency>
         <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-api</artifactId>
         <version>${log4j-slf4j-impl.version}</version>
      </dependency>
      <dependency>
         <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-core</artifactId>
         <version>${log4j-slf4j-impl.version}</version>
      </dependency>
      <dependency>
         <groupId>log4j</groupId>
         <artifactId>log4j</artifactId>
         <version>1.2.17</version>
      </dependency>
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          michael.reiche Michael Reiche created issue -
          michael.reiche Michael Reiche made changes -
          Field Original Value New Value
          Description I used this in the Activator to get the logging core-io-deps to work. 

          InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
          System.setProperty("log4j.configuration", "file:///Users/michaelreiche/log4j.properties");

           

          log4j.properties

          # Root logger optionlog4j.rootLogger=TRACE, stdout

          # Direct log messages to stdout

          log4j.appender.stdout=org.apache.log4j.ConsoleAppender

          log4j.appender.stdout.Target=System.out

          log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

          log4j.appender.stdout.layout.ConversionPattern=%d\{yyyy-MM-dd HH:mm:ss} %-5p %c\{1}:%L - %m%n
          When using in osgi (karaf), I had difficulty configuring the logging.

          I used this in the Activator to get the logging core-io-deps to work. 

          InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
           System.setProperty("log4j.configuration", "file:///Users/michaelreiche/log4j.properties");

           

          log4j.properties
           # Root logger optionlog4j.rootLogger=TRACE, stdout

           # Direct log messages to stdout

          log4j.appender.stdout=org.apache.log4j.ConsoleAppender

          log4j.appender.stdout.Target=System.out

          log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

          log4j.appender.stdout.layout.ConversionPattern=%d\{yyyy-MM-dd HH:mm:ss} %-5p %c\{1}:%L - %m%n

          =============================================


          I modified LoggingEventConsumer.createLogger() to use a CONSOLE logger (that has trace and debug enabled)

          private Logger createLogger(final String name) {
           Logger logger;

           if (loggerConfig.customLogger() != null) {
           logger = loggerConfig.customLogger();
           System.out.println("CUSTOM LOGGER: "+logger);
           } else if (false && SLF4J_AVAILABLE && !loggerConfig.disableSlf4J()) { // not this one
           logger = new Slf4JLogger(name);
           System.out.println("SLF4J LOGGER: "+logger);
           } else if ( true || loggerConfig.fallbackToConsole()) { // This one.
           logger = new ConsoleLogger(name);
           System.out.println("CONSOLE LOGGER: "+logger);
           } else {
           logger = new JdkLogger(name);
           System.out.println("JDK LOGGER: "+logger);
           }

          ==================================================


          Also, include these dependencies in the pom :



          <dependency>
           <groupId>org.slf4j</groupId>
           <artifactId>slf4j-log4j12</artifactId>
           <version>1.7.30</version>
          </dependency>

          <dependency>
           <groupId>org.slf4j</groupId>
           <artifactId>slf4j-api</artifactId>
           <version>1.7.30</version>
          </dependency>

          <dependency>
           <groupId>org.apache.logging.log4j</groupId>
           <artifactId>log4j-slf4j-impl</artifactId>
           <version>${log4j-slf4j-impl.version}</version>
          </dependency>
          <dependency>
           <groupId>org.apache.logging.log4j</groupId>
           <artifactId>log4j-api</artifactId>
           <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
           <groupId>org.apache.logging.log4j</groupId>
           <artifactId>log4j-core</artifactId>
           <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
           <groupId>log4j</groupId>
           <artifactId>log4j</artifactId>
           <version>1.2.17</version>
          </dependency>
          Summary setup core-io-deps logging for osgi setup core-io-deps and core-io logging for osgi
          michael.reiche Michael Reiche made changes -
          Description When using in osgi (karaf), I had difficulty configuring the logging.

          I used this in the Activator to get the logging core-io-deps to work. 

          InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
           System.setProperty("log4j.configuration", "file:///Users/michaelreiche/log4j.properties");

           

          log4j.properties
           # Root logger optionlog4j.rootLogger=TRACE, stdout

           # Direct log messages to stdout

          log4j.appender.stdout=org.apache.log4j.ConsoleAppender

          log4j.appender.stdout.Target=System.out

          log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

          log4j.appender.stdout.layout.ConversionPattern=%d\{yyyy-MM-dd HH:mm:ss} %-5p %c\{1}:%L - %m%n

          =============================================


          I modified LoggingEventConsumer.createLogger() to use a CONSOLE logger (that has trace and debug enabled)

          private Logger createLogger(final String name) {
           Logger logger;

           if (loggerConfig.customLogger() != null) {
           logger = loggerConfig.customLogger();
           System.out.println("CUSTOM LOGGER: "+logger);
           } else if (false && SLF4J_AVAILABLE && !loggerConfig.disableSlf4J()) { // not this one
           logger = new Slf4JLogger(name);
           System.out.println("SLF4J LOGGER: "+logger);
           } else if ( true || loggerConfig.fallbackToConsole()) { // This one.
           logger = new ConsoleLogger(name);
           System.out.println("CONSOLE LOGGER: "+logger);
           } else {
           logger = new JdkLogger(name);
           System.out.println("JDK LOGGER: "+logger);
           }

          ==================================================


          Also, include these dependencies in the pom :



          <dependency>
           <groupId>org.slf4j</groupId>
           <artifactId>slf4j-log4j12</artifactId>
           <version>1.7.30</version>
          </dependency>

          <dependency>
           <groupId>org.slf4j</groupId>
           <artifactId>slf4j-api</artifactId>
           <version>1.7.30</version>
          </dependency>

          <dependency>
           <groupId>org.apache.logging.log4j</groupId>
           <artifactId>log4j-slf4j-impl</artifactId>
           <version>${log4j-slf4j-impl.version}</version>
          </dependency>
          <dependency>
           <groupId>org.apache.logging.log4j</groupId>
           <artifactId>log4j-api</artifactId>
           <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
           <groupId>org.apache.logging.log4j</groupId>
           <artifactId>log4j-core</artifactId>
           <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
           <groupId>log4j</groupId>
           <artifactId>log4j</artifactId>
           <version>1.2.17</version>
          </dependency>
          When using in osgi (karaf), I had difficulty configuring the logging.

          I used this in the Activator to get the logging core-io-deps to work. 

          InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
           System.setProperty("log4j.configuration", "file:///Users/michaelreiche/log4j.properties");

           

          log4j.properties
           # Root logger optionlog4j.rootLogger=TRACE, stdout

           # Direct log messages to stdout

          log4j.appender.stdout=org.apache.log4j.ConsoleAppender

          log4j.appender.stdout.Target=System.out

          log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

          log4j.appender.stdout.layout.ConversionPattern=%d\{yyyy-MM-dd HH:mm:ss} %-5p %c\{1}:%L - %m%n

          =============================================

          I modified LoggingEventConsumer.createLogger() to use a CONSOLE logger (that has trace and debug enabled)

          private Logger createLogger(final String name) {
           Logger logger;

          if (loggerConfig.customLogger() != null)

          { logger = loggerConfig.customLogger(); System.out.println("CUSTOM LOGGER: "+logger); }

          else if (false && SLF4J_AVAILABLE && !loggerConfig.disableSlf4J())

          { // not this one logger = new Slf4JLogger(name); System.out.println("SLF4J LOGGER: "+logger); }

          else if ( true || loggerConfig.fallbackToConsole())

          { // This one. logger = new ConsoleLogger(name); System.out.println("CONSOLE LOGGER: "+logger); }

          else

          { logger = new JdkLogger(name); System.out.println("JDK LOGGER: "+logger); }

          ==================================================

          Also, include these dependencies in the pom :

           
          {noformat}
          <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-log4j12</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-api</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-slf4j-impl</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>
          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-api</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
              <version>1.2.17</version>
          </dependency>{noformat}
          michael.reiche Michael Reiche made changes -
          Description When using in osgi (karaf), I had difficulty configuring the logging.

          I used this in the Activator to get the logging core-io-deps to work. 

          InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
           System.setProperty("log4j.configuration", "file:///Users/michaelreiche/log4j.properties");

           

          log4j.properties
           # Root logger optionlog4j.rootLogger=TRACE, stdout

           # Direct log messages to stdout

          log4j.appender.stdout=org.apache.log4j.ConsoleAppender

          log4j.appender.stdout.Target=System.out

          log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

          log4j.appender.stdout.layout.ConversionPattern=%d\{yyyy-MM-dd HH:mm:ss} %-5p %c\{1}:%L - %m%n

          =============================================

          I modified LoggingEventConsumer.createLogger() to use a CONSOLE logger (that has trace and debug enabled)

          private Logger createLogger(final String name) {
           Logger logger;

          if (loggerConfig.customLogger() != null)

          { logger = loggerConfig.customLogger(); System.out.println("CUSTOM LOGGER: "+logger); }

          else if (false && SLF4J_AVAILABLE && !loggerConfig.disableSlf4J())

          { // not this one logger = new Slf4JLogger(name); System.out.println("SLF4J LOGGER: "+logger); }

          else if ( true || loggerConfig.fallbackToConsole())

          { // This one. logger = new ConsoleLogger(name); System.out.println("CONSOLE LOGGER: "+logger); }

          else

          { logger = new JdkLogger(name); System.out.println("JDK LOGGER: "+logger); }

          ==================================================

          Also, include these dependencies in the pom :

           
          {noformat}
          <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-log4j12</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-api</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-slf4j-impl</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>
          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-api</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
              <version>1.2.17</version>
          </dependency>{noformat}
          When using in osgi (karaf), I had difficulty configuring the logging.

          I used this in the Activator to get the logging core-io-deps to work. 
          {code:java}
          InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
           System.setProperty("log4j.configuration", "file:///Users/michaelreiche/log4j.properties");
          {code}
           log4j.properties
          {noformat}
          # Root logger option
          log4j.rootLogger=TRACE, stdout

          # Direct log messages to stdout
          log4j.appender.stdout=org.apache.log4j.ConsoleAppender
          log4j.appender.stdout.Target=System.out
          log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
          log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n{noformat}
           

          =============================================

          I modified LoggingEventConsumer.createLogger() to use a CONSOLE logger (that has trace and debug enabled)
          {noformat}
            private Logger createLogger(final String name) {
              Logger logger; if (loggerConfig.customLogger() != null) {
                logger = loggerConfig.customLogger();
                System.out.println("CUSTOM LOGGER: "+logger);
              } else if ( false && SLF4J_AVAILABLE && !loggerConfig.disableSlf4J()) { // not this
                logger = new Slf4JLogger(name);
                System.out.println("SLF4J LOGGER: "+logger);
              } else if ( true || loggerConfig.fallbackToConsole()) { // use this
                logger = new ConsoleLogger(name);
                System.out.println("CONSOLE LOGGER: "+logger);
              } else {
                logger = new JdkLogger(name);
                System.out.println("JDK LOGGER: "+logger);
              }{noformat}
           

          ==================================================

          Also, include these dependencies in the pom :
          {noformat}<dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-log4j12</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-api</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-slf4j-impl</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>
          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-api</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
              <version>1.2.17</version>
          </dependency>{noformat}
          michael.reiche Michael Reiche made changes -
          Description When using in osgi (karaf), I had difficulty configuring the logging.

          I used this in the Activator to get the logging core-io-deps to work. 
          {code:java}
          InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
           System.setProperty("log4j.configuration", "file:///Users/michaelreiche/log4j.properties");
          {code}
           log4j.properties
          {noformat}
          # Root logger option
          log4j.rootLogger=TRACE, stdout

          # Direct log messages to stdout
          log4j.appender.stdout=org.apache.log4j.ConsoleAppender
          log4j.appender.stdout.Target=System.out
          log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
          log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n{noformat}
           

          =============================================

          I modified LoggingEventConsumer.createLogger() to use a CONSOLE logger (that has trace and debug enabled)
          {noformat}
            private Logger createLogger(final String name) {
              Logger logger; if (loggerConfig.customLogger() != null) {
                logger = loggerConfig.customLogger();
                System.out.println("CUSTOM LOGGER: "+logger);
              } else if ( false && SLF4J_AVAILABLE && !loggerConfig.disableSlf4J()) { // not this
                logger = new Slf4JLogger(name);
                System.out.println("SLF4J LOGGER: "+logger);
              } else if ( true || loggerConfig.fallbackToConsole()) { // use this
                logger = new ConsoleLogger(name);
                System.out.println("CONSOLE LOGGER: "+logger);
              } else {
                logger = new JdkLogger(name);
                System.out.println("JDK LOGGER: "+logger);
              }{noformat}
           

          ==================================================

          Also, include these dependencies in the pom :
          {noformat}<dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-log4j12</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-api</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-slf4j-impl</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>
          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-api</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
              <version>1.2.17</version>
          </dependency>{noformat}
          When using in osgi (karaf), I had difficulty configuring the logging.

          I used this in the Activator to get the logging core-io-deps to work. 
          {code:java}InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
           System.setProperty("log4j.configuration", "file:///Users/michaelreiche/log4j.properties");
          {code}
           log4j.properties
          {noformat}# Root logger option
          log4j.rootLogger=TRACE, stdout

          # Direct log messages to stdout
          log4j.appender.stdout=org.apache.log4j.ConsoleAppender
          log4j.appender.stdout.Target=System.out
          log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
          log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n{noformat}
           

          =============================================

          I modified LoggingEventConsumer.createLogger() to use a CONSOLE logger (that has trace and debug enabled)
          {noformat} private Logger createLogger(final String name) {
              Logger logger; if (loggerConfig.customLogger() != null) {
                logger = loggerConfig.customLogger();
                System.out.println("CUSTOM LOGGER: "+logger);
              } else if ( false && SLF4J_AVAILABLE && !loggerConfig.disableSlf4J()) { // not this
                logger = new Slf4JLogger(name);
                System.out.println("SLF4J LOGGER: "+logger);
              } else if ( true || loggerConfig.fallbackToConsole()) { // use this
                logger = new ConsoleLogger(name);
                System.out.println("CONSOLE LOGGER: "+logger);
              } else {
                logger = new JdkLogger(name);
                System.out.println("JDK LOGGER: "+logger);
              }{noformat}
           

          ==================================================

          Also, include these dependencies in the pom :
          {noformat}<dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-log4j12</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-api</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-slf4j-impl</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>
          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-api</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
              <version>1.2.17</version>
          </dependency>{noformat}
          michael.reiche Michael Reiche made changes -
          Assignee Michael Nitschinger [ daschl ] Michael Reiche [ JIRAUSER24711 ]
          michael.reiche Michael Reiche made changes -
          Description When using in osgi (karaf), I had difficulty configuring the logging.

          I used this in the Activator to get the logging core-io-deps to work. 
          {code:java}InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
           System.setProperty("log4j.configuration", "file:///Users/michaelreiche/log4j.properties");
          {code}
           log4j.properties
          {noformat}# Root logger option
          log4j.rootLogger=TRACE, stdout

          # Direct log messages to stdout
          log4j.appender.stdout=org.apache.log4j.ConsoleAppender
          log4j.appender.stdout.Target=System.out
          log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
          log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n{noformat}
           

          =============================================

          I modified LoggingEventConsumer.createLogger() to use a CONSOLE logger (that has trace and debug enabled)
          {noformat} private Logger createLogger(final String name) {
              Logger logger; if (loggerConfig.customLogger() != null) {
                logger = loggerConfig.customLogger();
                System.out.println("CUSTOM LOGGER: "+logger);
              } else if ( false && SLF4J_AVAILABLE && !loggerConfig.disableSlf4J()) { // not this
                logger = new Slf4JLogger(name);
                System.out.println("SLF4J LOGGER: "+logger);
              } else if ( true || loggerConfig.fallbackToConsole()) { // use this
                logger = new ConsoleLogger(name);
                System.out.println("CONSOLE LOGGER: "+logger);
              } else {
                logger = new JdkLogger(name);
                System.out.println("JDK LOGGER: "+logger);
              }{noformat}
           

          ==================================================

          Also, include these dependencies in the pom :
          {noformat}<dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-log4j12</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-api</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-slf4j-impl</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>
          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-api</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
              <version>1.2.17</version>
          </dependency>{noformat}
          When using in osgi (karaf), I had difficulty configuring the logging.

          I used this in the Activator to get the logging core-io-deps to work. 
          {code:java}InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
           System.setProperty("log4j.configuration", "file:///Users/michaelreiche/log4j.properties");
          {code}
           log4j.properties
          {noformat}# Root logger option
          log4j.rootLogger=TRACE, stdout

          # Direct log messages to stdout
          log4j.appender.stdout=org.apache.log4j.ConsoleAppender
          log4j.appender.stdout.Target=System.out
          log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
          log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n{noformat}
           

          ==========================================================================

           Additions to apache karaf congi.properties :
          {noformat}
          to org.osgi.framework.bootdelegation , add :

               javax.security.sasl, \
               javax.security.auth.*, \
               javax.crypto, \
               javax.crypto.spec, \{noformat}
          ==========================================================================

          I modified LoggingEventConsumer.createLogger() to use a CONSOLE logger (that has trace and debug enabled)
          {noformat} private Logger createLogger(final String name) {
              Logger logger; if (loggerConfig.customLogger() != null) {
                logger = loggerConfig.customLogger();
                System.out.println("CUSTOM LOGGER: "+logger);
              } else if ( false && SLF4J_AVAILABLE && !loggerConfig.disableSlf4J()) { // not this
                logger = new Slf4JLogger(name);
                System.out.println("SLF4J LOGGER: "+logger);
              } else if ( true || loggerConfig.fallbackToConsole()) { // use this
                logger = new ConsoleLogger(name);
                System.out.println("CONSOLE LOGGER: "+logger);
              } else {
                logger = new JdkLogger(name);
                System.out.println("JDK LOGGER: "+logger);
              }{noformat}
           

          ==================================================

          Also, include these dependencies in the pom :
          {noformat}<dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-log4j12</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-api</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-slf4j-impl</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>
          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-api</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
              <version>1.2.17</version>
          </dependency>{noformat}
          michael.reiche Michael Reiche made changes -
          Description When using in osgi (karaf), I had difficulty configuring the logging.

          I used this in the Activator to get the logging core-io-deps to work. 
          {code:java}InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
           System.setProperty("log4j.configuration", "file:///Users/michaelreiche/log4j.properties");
          {code}
           log4j.properties
          {noformat}# Root logger option
          log4j.rootLogger=TRACE, stdout

          # Direct log messages to stdout
          log4j.appender.stdout=org.apache.log4j.ConsoleAppender
          log4j.appender.stdout.Target=System.out
          log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
          log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n{noformat}
           

          ==========================================================================

           Additions to apache karaf congi.properties :
          {noformat}
          to org.osgi.framework.bootdelegation , add :

               javax.security.sasl, \
               javax.security.auth.*, \
               javax.crypto, \
               javax.crypto.spec, \{noformat}
          ==========================================================================

          I modified LoggingEventConsumer.createLogger() to use a CONSOLE logger (that has trace and debug enabled)
          {noformat} private Logger createLogger(final String name) {
              Logger logger; if (loggerConfig.customLogger() != null) {
                logger = loggerConfig.customLogger();
                System.out.println("CUSTOM LOGGER: "+logger);
              } else if ( false && SLF4J_AVAILABLE && !loggerConfig.disableSlf4J()) { // not this
                logger = new Slf4JLogger(name);
                System.out.println("SLF4J LOGGER: "+logger);
              } else if ( true || loggerConfig.fallbackToConsole()) { // use this
                logger = new ConsoleLogger(name);
                System.out.println("CONSOLE LOGGER: "+logger);
              } else {
                logger = new JdkLogger(name);
                System.out.println("JDK LOGGER: "+logger);
              }{noformat}
           

          ==================================================

          Also, include these dependencies in the pom :
          {noformat}<dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-log4j12</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-api</artifactId>
              <version>1.7.30</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-slf4j-impl</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>
          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-api</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              <version>${log4j-slf4j-impl.version}</version>
          </dependency>

          <dependency>
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
              <version>1.2.17</version>
          </dependency>{noformat}
          When using in osgi (karaf), I had difficulty configuring the logging.

          I used this in the Activator to get the logging core-io-deps to work. 
          {code:java}InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE);
           System.setProperty("log4j.configuration", "file:///Users/michaelreiche/log4j.properties");
          {code}
           log4j.properties
          {noformat}# Root logger option
          log4j.rootLogger=TRACE, stdout

          # Direct log messages to stdout
          log4j.appender.stdout=org.apache.log4j.ConsoleAppender
          log4j.appender.stdout.Target=System.out
          log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
          log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n{noformat}
           

          ==========================================================================

           Additions to apache karaf cong.properties :
          {noformat}to org.osgi.framework.bootdelegation , add :

               javax.security.sasl, \
               javax.security.auth.*, \
               javax.crypto, \
               javax.crypto.spec, {noformat}

          ========================================================================== I modified LoggingEventConsumer.createLogger() to use a CONSOLE logger (that has trace and debug enabled)

           
          {code:java}
          Logger logger;
          if (loggerConfig.customLogger() != null){
           logger = loggerConfig.customLogger();
           System.out.println("CUSTOM LOGGER: "+logger);
          }
          else if ( false && SLF4J_AVAILABLE && !loggerConfig.disableSlf4J()){ // not this
           logger = new Slf4JLogger(name);
           System.out.println("SLF4J LOGGER: "+logger); }
          else if ( true || loggerConfig.fallbackToConsole()){ // use this
           logger = new ConsoleLogger(name);
           System.out.println("CONSOLE LOGGER: "+logger); }
          else {
           logger = new JdkLogger(name);
           System.out.println("JDK LOGGER: "+logger);
          }
          {code}
          ==================================================

          Also, include these dependencies in the pom :

           
          {noformat}<dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
             <version>1.7.30</version>
          </dependency>
          <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
             <version>1.7.30</version>
          </dependency><dependency>
             <groupId>org.apache.logging.log4j</groupId>
             <artifactId>log4j-slf4j-impl</artifactId>
             <version>${log4j-slf4j-impl.version}</version>
          </dependency>
          <dependency>
             <groupId>org.apache.logging.log4j</groupId>
             <artifactId>log4j-api</artifactId>
             <version>${log4j-slf4j-impl.version}</version>
          </dependency>
          <dependency>
             <groupId>org.apache.logging.log4j</groupId>
             <artifactId>log4j-core</artifactId>
             <version>${log4j-slf4j-impl.version}</version>
          </dependency>
          <dependency>
             <groupId>log4j</groupId>
             <artifactId>log4j</artifactId>
             <version>1.2.17</version>
          </dependency>
          {noformat}
          daschl Michael Nitschinger made changes -
          Status New [ 10003 ] Open [ 1 ]
          daschl Michael Nitschinger made changes -
          Fix Version/s 3.2.0 [ 17431 ]
          daschl Michael Nitschinger made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]

          People

            michael.reiche Michael Reiche
            michael.reiche Michael Reiche
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty