c# - NLog not writing from referenced dll -


i have dll created sending email. have nlog included in project logs c:\logs{logfilename.log} <--this either error or event log. when working project locally works fine , writes out file during testing. when reference emailing dll project has nlog not outputting log files. config email dll in bin directory of new project referencing it. can create logs new project using trace didn't print email dll entries. there special need in new project email dll write logs? i've searched answer keywords not produce results need. i'm new nlog, please gentle.

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"> <targets> <target xsi:type="file"         name="default"         layout="${longdate} - ${level:uppercase=true}: ${message}${onexception:${newline}exception\: ${exception:format=tostring}}"         filename="c:\logs\default.log"         keepfileopen="false"         archivefilename="c:\logs\ntc_utility\default.{##}.log"         archivenumbering="sequence"         archiveevery="day"         maxarchivefiles="30"         /> <target xsi:type="file"     name="error"     layout="${longdate} - ${level:uppercase=true}: ${message}${onexception:${newline}exception\: ${exception:format=tostring}}"     filename="c:\logs\error.log"     keepfileopen="false"     archivefilename="c:\logs\ntc_utility\error.{##}.log"     archivenumbering="sequence"     archiveevery="day"     maxarchivefiles="90"         />  <target xsi:type="file"         name="emaillog"         layout="-------------------- ${message} (${longdate}) --------------------${newline} from: ${event-context:item=from}${newline} to: ${event-context:item=to}${newline} bcc: ${event-context:item=bcc}${newline} cc: ${event-context:item=cc}${newline} subject: ${event-context:item=subject}${newline} body: ${event-context:item=body}${newline} attachments: ${event-  context:item=attachments}${newline}--------------------------------------------------------------------${newline}"         filename="c:\logs\emaillog.log"         keepfileopen="false"         archivefilename="c:\logs\ntc_utility\emaillog_.{##}.log"         archivenumbering="sequence"         archiveevery="day"         maxarchivefiles="90"         />  </targets>  <rules> <logger name="*" writeto="error" level="error" final="true" /> <logger name="*" writeto="emaillog" level="info" final="true" /> <logger name="*" writeto="default" minlevel="debug" /> </rules> </nlog> 

this log.cs compiled utility dll

using nlog; namespace ntc.utility {     internal static class log     {         public static logger instance { get; private set;}         static log()         {             logmanager.reconfigexistingloggers();             instance = logmanager.getcurrentclasslogger();         }     } } 

this line calls logging method after email sent.

logemailsent(imperemail); 

which calls method...

    private void logemailsent(emailmessage email)     {                     logger logger = logmanager.getcurrentclasslogger();         logeventinfo thisevent = new logeventinfo(loglevel.info, "default","email sent");         thisevent.properties["from"] = email.from;         thisevent.properties["to"] = emailcollectiontocsv(email.torecipients);                     thisevent.properties["bcc"] = emailcollectiontocsv(email.bccrecipients);         thisevent.properties["cc"] = emailcollectiontocsv(email.ccrecipients);         thisevent.properties["subject"] = email.subject;         thisevent.properties["body"] = email.body;         thisevent.properties["attachments"] = attachmentcollectiontocsv(email.attachments);         logger.log(thisevent);      } 

check nlog.config if not. there posibilities configurations injected within code..

http://www.codeproject.com/articles/10631/introduction-to-nlog


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -