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.

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 K2 service fails to start

To start K2 in console mode, stop the K2 Windows Service and then launch console mode with the K2 blackpearl 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 [Program Files (x86)]\K2 blackpearl\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 article KB000309: K2 Host Server Logging for more information on Host Server logging.

It is possible to write custom logging providers that will output K2 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 \K2 blackpearl\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 [Program Files (x86)]\K2 blackpearl\ServiceBroker\logs

There are five different log files:

File Name Logged Information
brokerpackagein.log Logs the SmartObject that called the broker and the method of the SmartObject that uses the Broker. This information is useful to see which SmartObject and method were executed, when.
brokerpackageout.log Only contains a number of records that were returned by the broker. This data can be useful when you need to troubleshoot why not the number of expected records was returned to the UI. For example: if the brokerpackage reports the correct number of expected records, perhaps the UI is filtering out data after the broker returned the right number of records
serviceauth.log Shows the security credentials used when the service was executed. Check the current thread user to see which user account executed the service broker code.
servicepackagein.log Represents the Service Instance configuration, the Service Objects for the Service Instance that were called along with their Methods and Properties, the Mappings that define how the Provider Types are mapped to Service Object Types. When troubleshooting, one of the most useful values is probably the <serviceauthentication> section, where you can see the user account context that was used to query the provider.
servicepackageout.log Is the "raw" data returned by the Service Instance. This information can be useful when the data which eventually surfaces to the UI does not match the data you were expecting. Check this log file to see if the expected data was returned to the SmartObject, in which case the problem is likely on the UI side.

Active Directory User Manager Logging

K2 outputs logging information specific to the Active Directory User Manager in logfiles called [Program Files](x86)\K2 blackpearl\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 KB article KB001286: Configuration options for Active Directory User Manager message logging for more information on configuring the ADUM logging output.

Windows Event Log

The windows event log is a useful logging option. You can configure the Host Server Logging file to output information to the Windows Event log (just enable the <LogLocation Name="EventLogExtension" Active="True" LogLevel="Error" />in the host server logging configuration file ([Program Files (x86)]\K2 blackpearl\Host Server\Bin\HostServerLogging.config) to output log information to the Windows Event Log. Furthermore, the windows event log can also expose logging information regarding network connections, authentication issues, underlying O/S issues and more.

K2 blackpearl Developers Reference4.7
Video Links Learn Support
No videos found for this article
K2 on YouTube
No Additional links found for this article
No self-learning content for this article
Try some scenarios...
No relevant support links available for this article