How to create a text file in my current directory with NLog?

c#, console, nlog

Solution

Did you set the NLog.config 'copy to output directory' to 'copy always'?

You should get it to work if you follow their tutorial.

Problem

I am using Nlog for the first time. My aim is to just write to a text file. In main.c I have ``` class Program { private static Logger logger = LogManager.GetCurrentClassLogger(); static void Main(string[] args) { logger.Trace("Sample trace message"); logger.Debug("Sample debug message"); logger.Info("Sample informational message"); logger.Warn("Sample warning message"); logger.Error("Sample error message"); logger.Fatal("Sample fatal error message"); } } ``` My `Nlog.config` file is as follows: ``` <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <targets> <target name="logfile" xsi:type="File" fileName="file.txt" /> </targets> <rules> <logger name="*" minlevel="Info" writeTo="logfile" /> </rules> </nlog> ``` But I am not able to create a txt file in my current directory.

Original source