I'm trying to log my application with NLog, but the code
using System;
using System.Collections.Generic;
using acad = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using NLog;
[assembly:CommandClass(typeof(TestNLogAcad.MyClass))]
namespace TestNLogAcad
{
public class MyClass
{
private static Logger log = LogManager.GetCurrentClassLogger();
[CommandMethodAttribute("nlog")]
public void test()
{
log.Info("Hello NLog!");
acad.DocumentManager
.MdiActiveDocument.Editor
.WriteMessage("\nHello NLog!");
}
}
}
only writes message to command line. And there is no log file.
NLog.config:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--
See http://nlog-project.org/wiki/Configuration_file
for information on customizing logging rules and outputs.
-->
<targets>
<target name="file" xsi:type="File" fileName="${basedir}/nlog.txt" layout="${date}|${level}|${message}" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="file" />
</rules>
</nlog>
What is wrong in my solution?