Logging in K2

This topic lists the various logging options, configuration locations and outputs that are available in K2. As a developer, you may need to investigate logs or use the available logging targets when writing custom code against the K2 platform.

For more information on configuring logging in K2, see the topic K2 logging configuration in the Installation and Configuration guide.
For more information on logging and auditing in K2 Five, see the knowledge base article KB003293: Auditing and Logging in K2 Five
In general, when you modify any logging configuration files, you will need to restart the K2 service to pick up the changes.

Host Server Console Mode

Run K2 Host Server in console mode to see real-time activity in K2 Host Server. This is useful when troubleshooting performance issues, authentication issues and issues when the K2 service fails to start

To start K2 in console mode, stop the K2 Windows Service and then launch console mode with the K2 Server (Service Account) shortcut on the Start Menu.

We recommend starting the K2 Console in the context of the K2 Service Account to preserve the same credentials that are used when the K2 service runs as a windows service. This will help to prevent false issues, since the user context is the same for both Console and Service modes.

If you add
Console.Writeline("");
statements to custom code that executes in the context of the K2 server (such as code in a workflow or code in a custom service broker), the output will be shown in the Host Server console window.

Host Server Logging

To configure Host Server logging, modify the file "%PROGRAMFILES%\K2\Host Server\Bin\HostServerLogging.config" and set up the required log target and log level settings to output logging information. These log files are particularly helpful when troubleshooting connection and authentication issues.

See the topic K2 Host Server Logging in the Installation and Configuration Guide for more info.

It is possible to write custom logging providers that will output K2 host server logging information to a target of your choice. See the topic Custom Logging Extensions for more information.

SmartObject Runtime Logging

To set up runtime logging for SmartObjects, edit the file K2HostServer.exe.Config file located in "%PROGRAMFILES%\K2\Host Server\Bin". Then configure the <logging> section for the log files you want to output.

By default, all the log files are disabled, so change the log="no" setting to log="yes" for each logfile you want to create. Restart the K2 service to pick up the configuration changes, execute the SmartObject method and then review the log files' output. By default, the log files are written to "%PROGRAMFILES%\K2\ServiceBroker\logs"

See the topic SmartObject Server Logging in the Installation and Configuration Guide for more info.

Active Directory User Manager Logging

K2 outputs logging information specific to the Active Directory User Manager in log files called "%PROGRAMFILES%\K2\Host Server\Bin\AdumError[Date]_[Increment].log" (where [Date] is the date the file was created and [Increment] is the number of the file per date). You can configure the level of logging output by editing the RoleInit column for the K2 Security Label in the HostServer.SecurityLabel database table.

See the topic Active Directory User Manager message logging in the Installation and Configuration Guide for more info.

Windows Event Viewer Log

The Windows event log can expose logging information regarding network connections, authentication issues, underlying OS issues and more. You can configure the Host Server Logging file to output information to the Windows Event log.

See the Event Log section in the K2 Server logging topic of the Installation and Configuration Guide.