K2 Workflow REST API and OData API Logging
You can enable logging for the K2 Workflow REST API and the OData API to troubleshoot issues you may have when using either API.
- Configuring the Workflow REST API in the K2 Five User Guide
- Workflow REST API in the K2 Five Developers Reference
For information on the OData API see these topics:
- Configure the SmartObject OData API in the K2 Five User Guide
- SmartObject OData API in the K2 Five Developers Reference
API logging is disabled by default. You should only enable API logging to troubleshoot an issue you are having, then disable it to avoid K2 performance degradation. Enable logging and configure the logging level by editing the Web.config file located at:
Workflow REST API |
[Program Files]\K2\WebServices\API\Workflow\V1\Web.config Note: The V1 part of the path above represents the version of the API. The value might be different depending on the version of the workflow API you are using. At the release of K2 Five the versions available were V1 and Preview. |
OData API | [Program Files]\K2\WebServices\API\SmartObjectService.OData\Web.config |
It's recommended that you restart the IIS server using the iisreset command, and restart the K2 Server service after you have made changes to config files.
Steps to enable and configure API logging:
- Open the appropriate Web.config file in a text editor and search for the DevLogTraceListener item in the <system.diagnostics><trace><listeners> section. The line will be slightly different depending on which API Web.config file you open.Copy
Listeners section of the web.config
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add name="DevLogTraceListener" type="System.Diagnostics.TextWriterTraceListener, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" initializeData="C:\Program Files\K2\WebServices\API\Logs\WorkflowServiceTraceV1.log" traceOutputOptions="Timestamp">
<!--
Available filter initialization values are: "All", "Error", "Warning", "Verbose", or "Off"
For more info see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.sourcelevels
-->
<filter type="System.Diagnostics.EventTypeFilter" initializeData="Off" />
</add>
<remove name="DevLogTraceListener">
<!-- Remove this block to enable tracing. It's here to ensure that tracing is disabled by default. -->
</remove>
</listeners>
</trace>
</system.diagnostics> - Disable the <remove> tags by putting the <remove>...</remove> section inside a comment tag (<!-- -->) as shown below.CopyChange the initializeData property of the filter tag to set the level of logging you want (All, Error, Warning, Verbose, or Off). For more info on the diagnostic levels available, see this Microsoft article.
Remove tags
<!-- <remove name="DevLogTraceListener"> -->
<!-- Remove this block to enable tracing. It's here to ensure that tracing is disabled by default. -->
<!-- </remove> -->
<filter type="System.Diagnostics.EventTypeFilter" initializeData="All" /> - Save the Web.config file
- Reproduce the error that you are troubleshooting
- Navigate to [Program Files]\K2\WebServices\API\Logs and open relevant the log file. The log file may contain information that will help you troubleshoot the error
- When you are done troubleshooting, remove/disable the API logging by removing the comment tags that you entered in step 2 and change initializeData from step 3 back to OffCopy
Tidy up
<filter type="System.Diagnostics.EventTypeFilter" initializeData="Off" />
</add>
<remove name="DevLogTraceListener">
<!-- Remove this block to enable tracing. It's here to ensure that tracing is disabled by default. -->
</remove>