Skip to main content

WEBfactory 2010

Enabling the WCF web services logging using Nlog.config


Check out this article and learn how to enable the WCF web services logging using Nlog.config.

While WEBfactory 2010Activity Analyzer can log WCF web services activities, the logged information is truncated. This might be enough for tracking most of the WCF web services errors, but in some situations, the full logs are required. This article describes how to obtain full WCF web services logs using Nlog.config.

IMPORTANT: The Nlog.config logging method should be activated only to track WCF web services errors if required. Otherwise it must be deactivated, in order to avoid performance and disk space issues!

The Nlog.config file

The Nlog.config file can be found in the WCF folder, located in C:\inetpub\wwwroot\_SERVICES\WEBservices\WCF\. Open the file in the preferred text editor and follow the next steps to configure the logging:

If the Nlog.config file does not exist at the specified location, create the file using a text editor. Insert the following content in the new file and save it as Nlog.config (XML configuration file):

<?xml version="1.0"?>

<nlog xmlns="" xmlns:xsi="">
    <add assembly="WFCommon"/>
    <!--<add assembly="NLog.Targets.GrowlNotify" />-->
  <targets async="true">
    <target name="WTS" xsi:type="WTSLoggingTarget" ChannelID="WebServices" layout="${longdate} ${uppercase:${level}} ${message} ${onexception:\:${exception:format=type,message,method,stackTrace:maxInnerExceptionLevel=50:innerFormat=shortType,message,method,stackTrace}}"/>
    <!--<target name="growl" xsi:type="GrowlNotify" password="" host="localhost"/>-->
    <!--<target xsi:type="File"
           layout="${longdate} ${uppercase:${level}} ${message} ${onexception:\:${exception:format=type,message,method,stackTrace:maxInnerExceptionLevel=50:innerFormat=shortType,message,method,stackTrace}}"
    <!--<logger name="*" minlevel="Warn" writeTo="growl"/>-->
    <logger name="*" minlevel="Trace" writeTo="WTS" />

Make sure that the new Nlog.config file is placed in C:\inetpub\wwwroot\_SERVICES\WEBservices\WCF.

Please note that this is the default version of the Nlog.config file. To activate the WCF web services logging, please proceed with the next steps.

  1. Un-comment the second <target> element from the <targets> node by removing the <!-- and --> comment marks located before and after the <target> element. This will enable the file logging using a predefined file name and layout. The fileName property also states the location of the new file logs, a logs folder that needs to be created in the current directory.

    <target xsi:type="File" 
    	layout="${longdate} ${uppercase:${level}} ${message} ${onexception:\:${exception:format=type,message,method,stackTrace:maxInnerExceptionLevel=50:innerFormat=shortType,message,method,stackTrace}}"
  2. Add the following logger definition in the <rules> node. This will activate the file logging enabled at the previous step and set the logging level:

    <logger name="*" minlevel="Trace" writeTo="fileLog" />

    The logging level can be adjusted using the minlevel property. It can be set to Trace, Warn or Error.

  3. Create a new folder named logs inside the WCF folder (C:\inetpub\wwwroot\_SERVICES\WEBservices\WCF\logs\).

  4. Grant full control permission for the IIS user (IIS_IUSRS) over the newly created logs folder.

  5. Restart the IIS (Internet Information Services) by entering the iisreset command in a command prompt window (CMD). Alternatively, the Internet Information Services (IIS) Manager can be used to restart the IIS.


The full WCF web services logging is now enabled and the resulted logs will be available in the WCF\logs folder.

IMPORTANT: To deactivate the full WCF web services logging, simply comment out the logger definition added in step 2 to the <rules> node:

<!-- <logger name="*" minlevel="Trace" writeTo="fileLog" /> -->