I am trying to implement a simple log using Nlog Refresh 1.0 for a class Library project. It seems nlog does not create a logfile when it's instantiated from within a dll.
Is there some other way around this ?
my config file looks like this:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
throwExceptions="true">
<targets>
<target name="file" xsi:type="File" fileName="${basedir}/nlog.txt" />
<target name="console" xsi:type="Console" />
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="file" />
<logger name="*" minlevel="Info" writeTo="console" />
</rules>
</nlog>
I know there is nothing wrong with this config because it works from within an exe project.
Edit: just to clarify: I have no access to the calling program which uses my dll as a plugin. The calling program is in fact outlook which uses my dll as a plugin. I would want to keep a log which is only relevant to my dll and has nothing to do with outlook itself.
NLog is a flexible and free logging platform for various . NET platforms, including . NET standard. NLog makes it easy to write to several targets. (database, file, console) and change the logging configuration on-the-fly.
Create a Console Application project in Visual Studio. Install NLog and its dependencies. Create and configure the NLog logger. Integrate the logger into the C# Console Application.
you have to add the nlog.config to the location of the exe file that uses the dll!
Edit: You don't have to modify the exe file just place the nlog.config in the same directory, if that is no option i guess you will have to configure it from code https://github.com/nlog/NLog/wiki/Configuration-API
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With