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
    • Resolution: Fixed
    • Major
    • 3.2.0
    • None
    • 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

          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