Logging with K2.Net 2003

K2 Add comments

The release of the K2.Net Service Pack 4 included an extensive logging framework that records and stores every K2.Net Server event. In a recent workflow project I thought I would implement logging using the Logging Framework provided. The framework contains an XML configuration file that the Logging Framework Configuration uses. It also has a list of message categories and specific predefined messages. The configuration file allows for settings to be altered after a solution has been deployed without the need for a redeployment. There is no need to restart the K2.net 2003 Server unless the ProcessModel section has been changed. There are a couple of steps involved when implementing logging.

Step 1: Configuring the Logging Configuration File
The configuration file can be altered using a text editor or the Logging Configuration Editor (LogConfig.exe found under the [InstallDrive]:\Program Files\K2.Net 2003\Bin directory). It provides a graphical interface that can be used to edit and save the configuration properties. It looks as follows:

Logging Configuration EditorLogging Configuration EditorLogging Configuration Editor

The configuration file is made up of three sections:

  • General Settings: allows for setting the log file name, file path, level of logging, log to Console, log to Event Viewer, log to File, max log size, etc.
  • Message Category: allows for setting categories under which messages can be logged.
  • Predefined Message List: contains known predefined messages and allows for more to be added.

Step 2: Implementing Logging in the K2.Net 2003 Studio Solution

Anywhere in the K2.Net 2003 solution where code is written you can add logging as long as you have a reference to the K2 ProcessInstance. An example would look as follows:

Logging CodeLogging Code

The Logger.LogDebugMessage which takes has four overloads. The following parameters can be set:

  • string MessageSource (set in example)
  • string MessageName
  • string MessageString (set in example)
  • string MessageCategory
  • long MessageID

Step 3: Restart the K2 Service

You need to restart the K2 Service to kick off logging to the file, event viewer, etc.

Pretty easy, happy logging!

,

View blog reactions

Bookmark and Share Bookmark and Share

One Response to “Logging with K2.Net 2003”

  1. K2.NET 2003 Log Reader « Says:

    [...] Further article about the Logging Framework here. [...]

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in