5 Replies Latest reply on May 4, 2015 1:57 AM by Traveller X

    Logging in Custom WorkItemHandler not working

    Traveller X Newbie

      Hello Everyone,

      I am new to JBPM.


      JBPM: 6.2.0

      JBoss : AS 7.1.1

      JDK : 1.7+



      I am working on some custom workitemhandlers. I am stuck about how to use the logging apis like log4j or logback.


      When I use System.out.println, it's getting logged on the jboss server.log


      However, when used log4j or logback, it's not logging anything. Neither on server.log or log files.


      Sample WorkItemHandler:


      import org.kie.api.runtime.process.WorkItem;

      import org.kie.api.runtime.process.WorkItemHandler;

      import org.kie.api.runtime.process.WorkItemManager;

      import org.slf4j.Logger;

      import org.slf4j.LoggerFactory;

       

       

      /**

      *

      */

      public class SampleWorkItemHandler implements WorkItemHandler {

       

       

        // logger for SampleWorkItemHandler

        private static Logger logger = (Logger) LoggerFactory

        .getLogger(SampleWorkItemHandler.class);

       

       

        /*

        * (non-Javadoc)

        *

        * @see

        * org.kie.api.runtime.process.WorkItemHandler#executeWorkItem(org.kie.api

        * .runtime.process.WorkItem, org.kie.api.runtime.process.WorkItemManager)

        */

        public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {

        System.out.println("I am in SampleWorkItemHandler");

        logger.debug("Hey I am in SampleWorkItemHandler");

        manager.abortWorkItem(workItem.getId());

        }

       

       

        /*

        * (non-Javadoc)

        *

        * @see

        * org.kie.api.runtime.process.WorkItemHandler#abortWorkItem(org.kie.api

        * .runtime.process.WorkItem, org.kie.api.runtime.process.WorkItemManager)

        */

        public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {

        manager.abortWorkItem(workItem.getId());

        }

       

       

      }

       

      My log4j.xml, logging.properties, log4j.properties:

       

      # Additional logger names to configure (root logger is always configured)

      loggers=org.jboss.as.config

       

       

      # Dump system environment at boot by default

      logger.org.jboss.as.config.level=DEBUG

       

       

      # Root logger level

      logger.level=DEBUG

      # Root logger handlers

      logger.handlers=FILE,CONSOLE

       

       

      # Console handler configuration

      handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler

      handler.CONSOLE.properties=autoFlush

      handler.CONSOLE.level=DEBUG

      handler.CONSOLE.autoFlush=true

      handler.CONSOLE.formatter=PATTERN

       

       

      # File handler configuration

      handler.FILE=org.jboss.logmanager.handlers.FileHandler

      handler.FILE.level=DEBUG

      handler.FILE.properties=autoFlush,fileName

      handler.FILE.autoFlush=true

      handler.FILE.fileName=${org.jboss.boot.log.file:boot.log}

      handler.FILE.formatter=PATTERN

       

       

      # Formatter pattern configuration

      formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter

      formatter.PATTERN.properties=pattern

      formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n

       

      ---

       

      <?xml version="1.0" encoding="UTF-8" ?>

      <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

      <log4j:configuration debug="true"

        xmlns:log4j='http://jakarta.apache.org/log4j/'>

       

       

        <appender name="console" class="org.apache.log4j.ConsoleAppender">

        <layout class="org.apache.log4j.PatternLayout">

        <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />

        </layout>

        </appender>

       

       

        <appender name="file" class="org.apache.log4j.RollingFileAppender">

        <param name="append" value="false" />

        <param name="maxFileSize" value="10MB" />

        <param name="maxBackupIndex" value="10" />

        <param name="file" value="/logs/xxx.log" />

        <layout class="org.apache.log4j.PatternLayout">

        <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />

        </layout>

        </appender>

       

       

        <root>

        <level value="DEBUG" />

        <appender-ref ref="console" />

        <appender-ref ref="file" />

        </root>

       

       

      </log4j:configuration>

       

       

      Appreciate any help !