Currently im working on a WPF version of an existing console application. In the console application i use log4net to do all my logging. Therefore i configured all my appenders etc in the App.config file. Everything works fine in the console application.
Now i want to implement the same logging functionality in my WPF application. I have to say that im totally new in WPF and this is my first WPF project. I just tried to add the App.config (exactly the same one) to my WPF project as i had it in my console application. But it does not work. No files are created by the FileAppenders. But i also dont get any error or warning when compiling.
What do i have to do to get the same logging functionality for log4net as in my console app? How can i configure log4net (Appenders) in an WPF application?
Thx in advance
xxxxxx Edit xxxxxx
Based on Roberts hint i could solve it. I added
log4net.Config.XmlConfigurator.Configure()
to my Main Window. Now my logging works exactly in the same way as it does in my console application.
public MainWindow()
{
// check if Application is already running
// if it is running - Kill
if (System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Length > 1) System.Diagnostics.Process.GetCurrentProcess().Kill();
log4net.Config.XmlConfigurator.Configure();
InitializeComponent();
}
You need to call log4net.Config.XmlConfigurator.Configure()
on startup.