added console target to NLogConfig.xml, to help debugging on console, rather than using console.writelines.

This commit is contained in:
Chris.Watts90@outlook.com 2018-03-08 09:18:20 +00:00
parent fb068cbdf2
commit 9ba44d273e
2 changed files with 6 additions and 2 deletions

View File

@ -4,8 +4,12 @@
autoReload="true">
<targets>
<target name="viewer" xsi:type="Chainsaw" address="udp://127.0.0.1:4000" />
<target xsi:type="Console" name="consoleViewer"
layout="${longdate}|${level:uppercase=true}|${message}"
detectConsoleAvailable="true" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="viewer" />
<logger name="*" minlevel="Trace" writeTo="consoleViewer" />
</rules>
</nlog>

View File

@ -9,14 +9,14 @@ namespace NLogLogger
{
public class NLogger:ILogger
{
private NLog.Logger _logger;
private readonly Logger _logger;
public NLogger()
{
var nlogConfigPathOption =
ConfigurationHandler.ConfigurationHandler.GetConfiguration("NLogConfigFilePath");
if (nlogConfigPathOption == null)
{
throw new ArgumentNullException("nlogConfigPath");
throw new ArgumentNullException("nlogConfigPath", "NLogConfigFilePath missing from application config file.");
}
var nlogConfigPath = new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase), nlogConfigPathOption)).LocalPath;
LogManager.Configuration = new XmlLoggingConfiguration(nlogConfigPath);