Hi i try use Nlog in with caliburn micro, I have use this tutorial http://buksbaum.us/2010/08/08/how-to-do-logging-with-caliburn-micro/.
Firstt I defined Nloagger class, here is it:
public class NLogLogger : ILog
{
#region Fields
private readonly NLog.Logger _innerLogger;
#endregion
#region Constructors
public NLogLogger(Type type)
{
_innerLogger = NLog.LogManager.GetLogger(type.Name);
}
#endregion
#region ILog Members
public void Error(Exception exception)
{
_innerLogger.ErrorException(exception.Message, exception);
}
public void Info(string format, params object[] args)
{
_innerLogger.Info(format, args);
}
public void Warn(string format, params object[] args)
{
_innerLogger.Warn(format, args);
}
#endregion
}
That I modified MEF bootraper:
#region Constructors
public MefBootStrapper()
: base()
{
_msgBox = new MessageBoxes();
_doHandle = true;
}
static MefBootStrapper()
{
LogManager.GetLog = type => new NLogLogger(type);
}
#endregion
and last modified app.config
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="logfile" xsi:type="File" fileName="file.txt" />
</targets>
<rules>
<logger name="*" minlevel="Error" writeTo="logfile" />
</rules>
</nlog>
</configuration>
It is really stupid for me but I dont know how to use now logger in View model class and second I would like to know if it is possible log with NLog to XML files.
Thank you for support