I am using NLog and I want to log to RichTextBox and File at the same time. And I want to configure the Logger programmatically, not with xml config file.
The following code only logs to the last target (File in this case). Can anybody help?
RichTextBoxTarget t1 = new RichTextBoxTarget();
t1.Layout = "${date} ${message}";
t1.ControlName = "rtb_log";
t1.FormName = "MainForm";
NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(t1, LogLevel.Debug);
FileTarget t2 = new FileTarget();
t2.Layout = "${date} ${level} ${message}";
t2.FileName = "${basedir}/Logs/today.log";
t2.KeepFileOpen = false;
t2.Encoding = "iso-8859-2";
NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(t2, LogLevel.Trace);
Logger logger = LogManager.GetLogger("MyLogger");