Skip to main content

I have a question have you worked on error handling and logging in K2 workflow.


 


1.       Adding K2.processInstance.logger.LogInfoMessage(source,message);


       to exception rule code behind  with custom error message.


2.        Create  a class library project , define a class which  override void LogMessage(MessageObject messageObject, string logStrMsg)


3.      Creating a email with message object error message as content of it and sending to K2 admin.


4.      Then adding the dll created as an extension K2 host config file. 


 


 


Can you please tell me what message source has – does it contains the workflow solution name or process name?


 


Is these steps correct or I am missing anything. Can you please suggest?  


 


 


 

The 'source' parameter of the LogInfoMessage method can be anything you want it to be.  It is simply passed through and then written to the targeted output.  It is generally used to make categorize messages so you can easily group/find them when reviewing the logs.  Process Name might be a useful way to categorize these.


Additionally, it sounds like you are trying to make a custom logging extension.  Have you seen thd blog post http://www.k2underground.com/blogs/fromthebench/archive/2008/03/03/logging-framework.aspx?  This walks through how to do one.


HTH.


Hi Bob,


I have a question, does the message object capture these custom error messages , if we are creating a custom extension logging .


Thanks.


 


 


Within the K2 logging framework, messages are decoupled from output targets (where an output target can be any combination of server console, Windows Event log, trace file, a custom component like an emailer).  A when a message is created, it is submitted to the logging framework, then the logging framework determines what outputs are currently enabled and then passes the message along to the ones that it finds are enabled.


I'm not aware of the logging framework distinguishing between a message coded into the process defintion by the workflow designer (e.g. by explicitly calling something like K2.ProcessInstance.Logger.LogInfoMessage()) and ones that are generated by K2 processing.  To the best of my knowledge, the interal K2 components actually use this same exactly logging framework API to generate their own messages.


 


Reply