K2.net 2003 SP4 introduced the new logging framework that can be used to log messages in a more flexible and structured manner compared to doing Console.WriteLine();
As described in the SP4 BOM document, you can log a message within the context of a K2.net event like so:
K2.ProcessInstance.Logger.LogInfoMessage("Some Identifying Name","The Message");
You can also pass the logger to an external assembly in case you are calling the assembly from code in a K2.net process but want to be able to log messages in your external assembly.
//Code in K2 event
//create a proxy instance of the logger
SourceCode.KO.K2LoggerProxy k2Logger = K2.ProcessInstance.Logger;
//pass the _logger object to the external assembly (in this case, using a constructor parameter)
_someObject = new someNameSpace.someObject(k2Logger);
//code in your external assembly
public someObject(SourceCode.KO.K2LoggerProxy k2Logger)
{
k2Logger.LogInfoMessage("Some Identifying Name","The Message");
}
You will need to add a reference to KO.dll and SourceCode.logging.dll to your external project to be able to use the logger.
NOTE: If you use the message ID when logging the message, do not use any of the reserved message ranges that are reserved for use by K2.net - you can have a look at logger.config to see which error numbers are already in use.
Hope this helps anyone that needs to do something like this.