Akore
Akore

Reputation: 85

cannot use ${aspnet-request-ip}

here is my layout:

    <target xsi:type="File" name="ownFile-web" fileName="c:\temp\nlog-own-${shortdate}.log"
            layout="${longdate}|${aspnet-request-ip}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" />
  </targets>

${aspnet-request-ip} part does not work.

I have installed both nlog and nlog.web. Both are in dotnet core version.

Upvotes: 1

Views: 1099

Answers (1)

Akore
Akore

Reputation: 85

I have to add an extension to make it works (this was left off in the official document)

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      internalLogLevel="info"
      internalLogFile="c:\temp\internal-nlog.txt">

  <extensions>
    <add assembly="NLog.Web.AspNetCore"/>
  </extensions>

...

@Rolf thank you :)

Upvotes: 2

Related Questions