8 Replies Latest reply on Jul 13, 2006 11:36 AM by michaelholtzman

    JBPM_LOG: who performed the transition?

    wrschneider99

      I'm using jBPM to provide some basic state-machine type functionality, focusing on nodes and transitions for the time being. Transitions are manually performed through the user interface.

      I see that, in my limited use case, the jBPM logging service keeps track of three different types of data:
      - signals (timestamp and transition ID)
      - transitions (source/destination node, w/timestamp of transition)
      - nodes (enter/leave times, time elapsed in node)

      But there doesn't seem to be anywhere to keep track of *who* performed a given signal/transition, which would make sense in my use case. The only thing that is recorded is the old/new actor ID in the case of task assignment.

      In the 3.1.1 source, I do see a 'getActorId' method on ProcessLog, and see a reference to getActorId:

      // AuthenticationLog overriddes the getActorId
      


      ... but no AuthenticationLog to be found anywhere else.

      Am I missing something? Thanks!

        • 1. Re: JBPM_LOG: who performed the transition?
          m_ok

          That makes two of us. I hope you get an answer as my questions where barely answered a year ago.

          The need for actor ids in logging is fundamental to answering the three basic questions: Who did What and When.

          There's currently What happpened and When but finding Who did What requires so much juggling and gymnastics it's an olympic feat in itself!

          • 2. Re: JBPM_LOG: who performed the transition?
            kukeltje

            I'm not realy good at juggling and gymnastics, so I keep faar from that . That is why I use tasks if I need to know who did what and when. So the answer is largly already in the initial question. If it is relevant, use a task (you do not need the jBPM ui for this if you do not want to) if you want to have logged who did what when no task is used, file a Jira issue (as a feature request, not a bug)


            • 3. Re: JBPM_LOG: who performed the transition?
              m_ok

              Thanks for replying. I'm not good at gymnastics and juggling either (but it's always good for a laugh ; ).

              Could you elaborate on your view of what JBPM_LOG is for?

              I don't see a point in reanalyzing every task of a process every time I want to provide a log to my users. I know I could store that info somewhere but then again isn't that what the JBPM_LOG table is for?

              From my perspective, in a system, users do things and that is logged for reference/proof/audit, etc.

              Another word for this is audit trail. I think of logging (as in the case of JBPM_LOG and not log4j) as a synonym of audit trail and so I thought of logging in jbpm in that sense.

              Am I wrong in my assumption of what JBPM_LOG is for?

              (Sorry to the OP for thread-jacking a bit.)

              • 4. Re: JBPM_LOG: who performed the transition?
                koen.aers

                JBPM_LOG is indeed the way to construct the audit trail.

                Regards,
                Koen

                • 5. Re: JBPM_LOG: who performed the transition?

                  I've looked through the documentation & googled around a bit and I haven't found what "the" way is to enable logging to JBPM_LOG. I have

                  <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />

                  in my jbpm.cfg.xml, but that itself doesn't seem to do the trick. What I currently have is this
                   processInstance.getInstance(LoggingInstance.class);
                  


                  after I create a new ProcessInstance, and that seems to work. Is there a global way of enabling logging, though?

                  Cheers,
                  Brice

                  p.s. The JBPM docs reference a LoggingDefinition, which no longer exists. You also can't addInstance(new LoggingInstance()) on a ProcessInstance, JBPM throws an exception. So, may I suggest cleaning up the docs on chapter 12. Logging? :)

                  • 6. Re: JBPM_LOG: who performed the transition?
                    hannes

                    I have changed the 'ProcessLog.java' and 'ProcessLog.hbm.xml' by adding a property named 'actorId' which is set in the constructor: 'actorId = Authentication.getAuthenticatedActorId();'

                    hbm:

                    <property name="actorId" column="ACTOR_" />


                    This was made with 3.0, but maybe it works for 3.1 too.

                    • 7. Re: JBPM_LOG: who performed the transition?
                      m_ok

                       

                      "Hannes" wrote:
                      I have changed the 'ProcessLog.java' and 'ProcessLog.hbm.xml' by adding a property named 'actorId' which is set in the constructor: 'actorId = Authentication.getAuthenticatedActorId();'

                      hbm:
                      <property name="actorId" column="ACTOR_" />


                      This was made with 3.0, but maybe it works for 3.1 too.


                      Thank you very much for posting that.

                      I know I added a sort of ProcessInstanceCreateLog.hbm.xml to log when a process was created. And it worked well also.

                      At the time, I didn't want to modify the JBPM source code because we would then have to do it every time we update. You're giving me motivation to go ahead and do it though.


                      • 8. Re: JBPM_LOG: who performed the transition?
                        michaelholtzman

                        I solved this by adding my own ProcessLog subclass:

                        package com.olf.bpm.identity;
                        
                        import org.jbpm.logging.log.*;
                        
                        public class IdentityLog extends CompositeLog {
                        
                         private static final long serialVersionUID = 1L;
                        
                         protected String actorId = null;
                        
                         public IdentityLog() {
                         }
                        
                         public IdentityLog(String invoker) {
                         this.actorId = invoker;
                         }
                        
                         public String getActorId() {
                         return actorId;
                         }
                        
                         public String toString() {
                         return "invoker["+ actorId +"]";
                         }
                        }
                        


                        And the corresponding hibernate config file:
                        <?xml version="1.0"?>
                        
                        <!DOCTYPE hibernate-mapping PUBLIC
                         "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                         "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
                        
                        <hibernate-mapping default-access="field">
                        
                         <subclass name="com.olf.bpm.identity.IdentityLog"
                         extends="org.jbpm.logging.log.ProcessLog"
                         discriminator-value="9">
                        
                         <property name="actorId"
                         column="TASKACTORID_"/>
                        
                         </subclass>
                        
                        </hibernate-mapping>
                        



                        Then, before initiating any BPM action, I call:
                        idLog = new IdentityLog(invoker);
                        token.startCompositeLog(idLog);