7 Replies Latest reply on May 11, 2006 12:51 PM by tobysaville

    How to get process logging?

    cwad0000

      can someone show me examples how to use the process logging?
      I am primarily interested in extracting information about the processes (which nodes was traversed, etc)

      I tried to fetch information using findLogsByProcessInstance, but it only seems to return some initial information from the first node (and not information for all nodes as I was expecting?)

      Can someone explain how it works? Or give my pointers to some source code that displays logging information, I could not find any in the src directory?

      This is my code:

      Map logMap = myLog.findLogsByProcessInstance(processInstanceId);
      for (Iterator it = logMap.entrySet().iterator(); it.hasNext();) {
       Map.Entry entry = (Map.Entry) it.next();
       Token myToken = (Token) entry.getKey();
       List myList = (List) entry.getValue();
       log.debug(logPrefix2 + "Token.toString=" + myToken.toString());
      
       WorkflowLogTO myEntry = new WorkflowLogTO();
       myEntry.tokenInfo = myToken.toString();
       myEntry.logEntries = new ArrayList<String>();
      
       for (Iterator iter2 = myList.iterator(); iter2.hasNext();) {
       ProcessLog myP = (ProcessLog) iter2.next();
       log.debug(logPrefix2 + "...log=" + myP.toString());
       myEntry.logEntries.add(myP.toString());
       }
      


        • 1. Re: How to get process logging?
          tobysaville

          you have to write the log yourself in your application logic. For example, when i end a task in the controller of my MVC middleware, i perform the following:

          MessageLog mLog = new MessageLog(actorId +
           " ended the task " + ti.getName() +
           " with action " + action);
          procInstance.getLoggingInstance().addLog(mLog);
          


          Then when the process instance is saved, it will cascade save the Message Log attribute.

          cheers, toby

          • 2. Re: How to get process logging?
            kukeltje

            Toby,

            I saw your post in the other topic http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3942962#3942962, don't you think that solution is better than to write custom messages? afaik the information is almost the same or do you write some additional info?

            • 3. Re: How to get process logging?
              tobysaville

              yeah, i add other information, i just used the message here in this post as an example.

              • 4. Re: How to get process logging?
                cwad0000

                 

                "kukeltje" wrote:


                http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3942962#3942962, don't you think that solution is better than to write custom messages? afaik the information is almost the same or do you write some additional info?

                does this mean that I do NOT need to write any special logging code?

                If not, I am puzzled because isn't the code in that thread doing exactly the same as my code above?

                JbpmContext context = JbpmConfiguration.getInstance().createJbpmContext();
                try
                {
                 Map logs = context.getLoggingSession().findLogsByProcessInstance(152);
                
                 List logList = (List)logs.get(logs.keySet().iterator().next());
                 for (Iterator it = logList.iterator(); it.hasNext(); )
                 {
                 Object log = it.next();
                 System.out.println("LOG TYPE: " + log.getClass().getName() + " --> " + log.toString());
                 }
                }
                finally
                {
                 context.close();
                }
                


                • 5. Re: How to get process logging?
                  hosierdm

                  Every little detail of process execution is automatically logged by jbpm. I was able to see the entire path of execution using my code that you referenced from the other thread. You might try my code and see what you get. On the surface, your code looks to be the same (but I didn't look too closely at it), except that you handle the case where the log may have multiple tokens.

                  • 6. Re: How to get process logging?
                    cwad0000

                    Thanks, I will give your code a try.

                    • 7. Re: How to get process logging?
                      tobysaville

                      dont use MessageLog to write logs about the execution process, use it to write logs about something that is specific to your application.