0 Replies Latest reply on Dec 21, 2016 3:08 PM by Nicolas Cisco

    Fabric container: Logging to Database

    Nicolas Cisco Newbie

      Hi,

      i'm trying to set up a Database backend to store logs.

       

      I'm currently using JBoss Fuse 6.2.1.redhat-084 on Fabric Mode. I've created and uploaded a profile with maven. Then, i've imported the org.ops4j.pax.logging pid via karaf shell.

       

      JBossFuse: admin@child> fabric:profile-edit --import-pid --pid org.ops4j.pax.logging my-profile
      

       

      Then throught the Hawtio web interface, i editted the org.ops4j.pax.logging.properties file of my-profile:

       

      fabric.zookeeper.pid = org.ops4j.pax.logging
      log4j.appender.out = org.apache.log4j.RollingFileAppender
      log4j.appender.out.append = true
      log4j.appender.out.file = /opt/jboss-fuse/6.2.1.redhat-084/data/log/container.log
      log4j.appender.out.layout = org.apache.log4j.SanitizingPatternLayout
      log4j.appender.out.layout.ConversionPattern = Container %d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
      log4j.appender.out.layout.replacement = \\n  | 
      log4j.appender.out.layout.replaceRegex = \\n
      log4j.appender.out.maxBackupIndex = 10
      log4j.appender.out.maxFileSize = 100MB
      log4j.appender.sift = org.apache.log4j.sift.MDCSiftingAppender
      log4j.appender.sift.appender = org.apache.log4j.FileAppender
      log4j.appender.sift.appender.append = true
      log4j.appender.sift.appender.file = /opt/jboss-fuse/6.2.1.redhat-084/data/log/${bundle.name}.log
      log4j.appender.sift.appender.layout = org.apache.log4j.SanitizingPatternLayout
      log4j.appender.sift.appender.layout.ConversionPattern = %d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %m%n
      log4j.appender.sift.appender.layout.replacement = \\n  | 
      log4j.appender.sift.appender.layout.replaceRegex = \\n
      log4j.appender.sift.default = karaf
      log4j.appender.sift.key = bundle.name
      log4j.appender.stdout = org.apache.log4j.ConsoleAppender
      log4j.appender.stdout.layout = org.apache.log4j.SanitizingPatternLayout
      log4j.appender.stdout.layout.ConversionPattern = %d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
      log4j.appender.stdout.layout.replacement = \\n  | 
      log4j.appender.stdout.layout.replaceRegex = \\n
      log4j.appender.db = org.apache.log4j.jdbc.JDBCAppender
      log4j.appender.db.URL = jdbc:sqlserver://127.0.0.1:1433;DataBaseName=master
      log4j.appender.db.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
      log4j.appender.db.user=sa
      log4j.appender.db.password=yourStrong(!)Password
      log4j.appender.db.sql = INSERT INTO [dbo].[application_log] (application, level, text) VALUES ('App', 'i','%m')
      log4j.appender.db.Threshold = INFO
      log4j.appender.db.layout = org.apache.log4j.SanitizingPatternLayout
      log4j.appender.db.layout.ConversionPattern = %d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
      log4j.appender.db.layout.replacement = \\n  | 
      log4j.appender.db.layout.replaceRegex = \\n
      log4j.logger.httpclient.wire = WARN
      log4j.logger.org.apache.commons.httpclient = WARN
      log4j.logger.org.apache.sshd.server.channel.ChannelSession = INFO
      log4j.logger.org.apache.zookeeper.client.ZooKeeperSaslClient = WARN
      log4j.logger.org.apache.zookeeper.ClientCnxn = ERROR
      log4j.logger.org.apache.zookeeper.ClientCnxn$SendThread = ERROR
      log4j.logger.org.apache.zookeeper.server.NIOServerCnxn = ERROR
      log4j.logger.org.apache.zookeeper.server.NIOServerCnxnFactory = ERROR
      log4j.logger.org.apache.zookeeper.server.PrepRequestProcessor = WARN
      log4j.logger.org.apache.zookeeper.server.ZooKeeperServer = ERROR
      log4j.rootLogger = DEBUG, out, osgi:*, db, outb
      log4j.throwableRenderer = org.apache.log4j.OsgiThrowableRenderer
      service.pid = org.ops4j.pax.logging
      

       

      After creating a container with that profile, altought i can see the file /opt/jboss-fuse/6.2.1.redhat-084/data/log/container.log is created and logs are stored there, any log is inserted on the database.

       

      I don't see any error or warning on the container logs, nor on the root container logs.

       

      The table application_log:

       

      CREATE TABLE application_log
      (
          id INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
          time DATETIME NOT NULL DEFAULT GETDATE(),
          application varchar(max) NOT NULL,
          level char NOT NULL,
          text varchar(max) NOT NULL
      )
      

       

      What am i doing wrong? How can i configure JBoss Fuse in order to store logs on a database?

       

      Thanks in advanced!.