I want to use NLog to log messages to existing rich text box. Up to now I used code approach, given in this answer, but I found out this codeplex issue that explains how I can use configuration after all. Problem is, it does not work, separate rich text box window is still opened. My project is WPF, window name and control name are set in xaml like this:
<Window x:Name="Main_Window" ...>
...
<DockPanel ...>
...
<RichTextBox x:Name="rtbLog" ... />
</DockPanel>
</Window>
and they are used in Nlog.config like this:
<target xsi:type="RichTextBox"
formName="Main_Window" controlName="rtbLog" ... />
So, names match. I set the logger in Window_Loaded
event handler:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
log = LogManager.GetCurrentClassLogger();
}
What am I doing wrong?