Hi!
I have a problem reading the configuration file (NLog.config) from my class library project when I call it from my ASP.NET MVC4 project.
I tested my code using an Unit Test Project and reads the configuration file properly and makes logging correctly on the file that I specified on the NLog.config, so the NLog.config is correctly defined.
I also set "Copy always" at Copy to Output Directory settings, just like the tutorial says.
The problem is that when I called the class library project, from my ASP project, I realized that wasn't making any kind of log, and when I debugged, I saw that It wasn't picking the configuration from NLog.config, and for that reason, my project didn't know when and where to log.
I when look into "ASP project folder"/bin, there are the files from NLog: NLog.dll, NLog.config and NLog.xml, so in theory, the ASP project, can access without problem to the NLog files.
I read the tutorial from NLog but I can't figured out the solution. Just can´t understand why from my test project works properly but when I make the same call from my ASP project just don't work.
This is my configuration file for NLog.
<?xml version="1.0" encoding="utf-8" ?>
<nlog throwExceptions="true"
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="C:\logfile.txt" layout="${callsite:fileName=true} - ${longdate} - ${level:uppercase=true} - ${logger} - ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="logfile" />
</rules>
</nlog>
And within my classes, I create the logger this way:
private static Logger logger = LogManager.GetCurrentClassLogger();
Can anybody help me with this problem?
I make the same question here if anyone want to answer there too ;)
http://stackoverflow.com/questions/13469474/reading-nlog-config-from-nlog-in-api-rest-net
Greetigs!
--
You received this message because you are subscribed to the Google Groups "NLog-Users" group.
To post to this group, send email to nlog-...@googlegroups.com.
To unsubscribe from this group, send email to nlog-users+...@googlegroups.com.
Visit this group at http://groups.google.com/group/nlog-users?hl=en.