Flatfile logging a WPF app

Hello. I have a WPF app that I need to log events to a flat file. I took a look at the LoggingQuickStart sample project, and tried to do the same in my app, but I can't get the configuration right. When I appended the logging sections from LoggingQuickStart
to my app's App.config, my app wouldn't start.

As soon as it did start (making changes to the config entries), I keep getting the "The configuration section for Logging cannot be found in the configuration source." exception.

I came across a blog post that said:

this exception is usually caused by the Logger façade, which forcibly initializes using the application default .NET configuration file and not the one specified in the IConfigurationSource. In this scenario,
avoid using the Logger class and use the LogWriter created from the Iconfiguration source.

and suggested:

// Reads a Logging Application Block configuration from an external configuration file
var fcs = new FileConfigurationSource(@"C:\TEMP\MyLoggingConfiguration.config");
var logWriter = new LogWriterFactory(fcs).Create();
var logEntry = new LogEntry() { Message = "Hello logging!" };
// You can use the logWriter directly
logWriter.Write(logEntry);
// Throws a ConfigurationErrorsException "The configuration section for Logging cannot be found in the configuration source."
// Because the Logger facade forcibly initializs using the application�s default .NET configuration file and not the one
// we specified manually (EntLib 4.1)
Logger.Write(logEntry);

Although this sidetracks the configuration exception, it doesn't log anything to the file mentioned in the config file.

Based on the sample code you sent to me, you are logging using the "Troubleshooting" category and this category references a Formatted Event Log Trace Listener which logs to the event log. So if you want to log to the trace.log file,
you should use any of the following categories: Data Access Events, Trace, or UI Events. Sample code below:

logEntry.Categories.Add("Data Access Events");

By the way, if you specified only trace.log in the fileName, meaning without specifying an absolute path, then the file goes to the project's output folder which is in the bin\debug folder (for Debug mode).

If you're sure you're logging using the correct category but still unable to see the log file, check the event log for any error log indicating why logging to file failed.