NLog internal log not working with ASP.Net MVC

You can't use layout renderers ${...} in the internalLogFile property. They are for a target's layout only:

<target layout="${...}" />

Try to use relative path like "..\App_Data\NLog.log"

Update NLog 4.6 enables some simple layouts.


NLog ver. 4.6 add support for environment-variables like %appdata% or %HOME%, and using these basic layouts in internalLogFile=:

  • ${currentdir}
  • ${basedir}
  • ${tempdir}

NLog ver. 4.7 also adds this:

  • ${processdir}

See also: https://github.com/NLog/NLog/wiki/Internal-Logging


The internalLogFile attribute needs to be set to an absolute path and the executing assembly needs to have permission to write to that absolute path.

The following worked for me.

  1. Create a folder somewhere - e.g. the route of your c: drive, e.g. c:\logs
  2. Edit the permissions of this folder and give full control to everyone
  3. Set your nlog config: internalLogFile="C:\logs\nlog.txt"

Remember to clean up after yourself and not leave a directory with those sorts of permissions on