title: Use Nlog to log context info of Asp.Net Web API
body: <p>I've two separate tables to log user activity and errors in asp.net web Api.
  Here's my Activity Log table:
  <a href="https://i.stack.imgur.com/6ePpH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6ePpH.png" alt="ActivityLog"></a></p>
  
  <p>To store the Log information in the table, Here's the Nlog.config setting.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;target name="database" xsi:type="Database" keepConnection="true" useTransactions="true"
               dbProvider="System.Data.SqlClient" commandType="Text"
          connectionString="data source=XXXXX;initial catalog=XXXXX;integrated security=false;persist security info=True;User ID=XXXXX;Password=XXXXX"
          commandText="INSERT INTO [dbo].[ActivityLog]([PageName],[MethodName],[IPAddress],[RequestedUrl],[IsAuthenticated],[UserName],[Date]) VALUES(@PageName,@MethodName,@IPAddress,@RequestedUrl,@IsAuthenticated,@UserName,@Date)"&gt;
    &lt;parameter name="@PageName" layout="" /&gt;
    &lt;parameter name="@MethodName" layout="" /&gt;
    &lt;parameter name="@IPAddress" layout=""/&gt;
    &lt;parameter name="@RequestedUrl" layout="${aspnet-request:serverVariable=HTTP_URL}"/&gt;
    &lt;parameter name="@IsAuthenticated" layout="${aspnet-user-identity}:isAuthenticated"/&gt;
    &lt;parameter name="@UserName" layout="${aspnet-user-identity}"/&gt;
    &lt;parameter name="@Date" layout="${date:s}"/&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>For the Page Name parameter I need the Web API Controller Name, and for Method Name parameter I need the action Method of the Controller that is called.
  Also I need to know whether the user is authenticated or not. </p>
  
  <p>Now Kindly let me know the settings defined in the Nlog config file are correct or not and also how to pass values to the other parameters.</p>