Austin Donley Austin Donley - 5 months ago 30
C# Question

NLog file not writing

I've been trying to build an app that will use NLog to log a file. The code is really basic, but not seeming to work. Anyone have any ideas? I've set the correct things to "copy always" as well, like in this question. NLog doen't work on IIS

Code below.

MAIN (Including using statements to show I am actually using them)

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Configuration;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;

class Program

static void Main(string[] args)
var logger = LogManager.GetCurrentClassLogger();


<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns=""

<target name="file" xsi:type="File"
layout="${longdate} ${logger} ${message}"
fileName="${basedir}/log/logfile.txt" />

<logger name="*" minlevel="Debug" writeTo="file" />


<?xml version="1.0" encoding="utf-8" ?>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
<bindingRedirect oldVersion="" newVersion="" />



Check whether your process has write access to the ${basedir} location. Also, if your application is running from a special folder, make sure the process is running elevated.