Reputation: 3143
How to configure NLog in UWP project to show logs in Visual Studio Window:Output?
Note that in UWP apps Console.WriteLine("hello")
doesn't work.
To write in VisualStudio Window:Output you have to use Debug.WriteLine("hello")
from System.Diagnostic
.
I use below (almost default) NLog config.
Log to file works nice. Log to console doesn't work.
var config = new NLog.Config.LoggingConfiguration();
var storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = storageFolder.Path + @"\file.txt" };
var logconsole = new NLog.Targets.ConsoleTarget("logconsole");
config.AddRule(LogLevel.Debug, LogLevel.Fatal, logconsole);
config.AddRule(LogLevel.Debug, LogLevel.Fatal, logfile);
NLog.LogManager.Configuration = config;
Upvotes: 1
Views: 553
Reputation: 36859
UWP won't support console.
You could write to the Trace target. This will use the System.Diagnostics.Trace
- which is almost the same as System.Diagnostics.Debug
- both are visible in Visual Studio.
var traceTarget = new NLog.Targets.TraceTarget("target1");
Upvotes: 2