c# - How to send e-mails using NLog? -


i'm using nlog, , i'm pretty new @ logging. created log files somehow have problem send e-mails. followed instructions can't make it.

mail settings in configuration tags in web.config:

<system.net> <mailsettings>   <smtp deliverymethod="specifiedpickupdirectory" from="some@some.org">     <network host="localhost"/>     <specifiedpickupdirectory pickupdirectorylocation="d:\tmp\email"/>   </smtp>  </mailsettings> </system.net> 

and target inside nlog.config:

    <target name="mail" xsi:type="mail" html="true" subject="error received"   body="${message}"  to="some1@some.com"  from="some@gmail.com"  encoding="utf-8"  smtpusername="some@some.com"  enablessl="false"  smtppassword="password"  smtpauthentication="basic"  smtpserver="smtp.some.com"  smtpport="25" /> 

the rule used:

       <logger name="*" minlevel="error" writeto="mail" /> 

and called logger this:

     logger logger = logmanager.getcurrentclasslogger();      try{ //something }      catch(exception ex){  logger.error(ex);  } 

and i'm pretty confused places of settings , configurations. thank you.

the body layout format, not sure if process ${message} tag. change ${message] layout name in nlog.config or leave off ${message}${newline} default.

you can turn on internal debugging

change top xml parent to

<nlog internallogfile="c:\log.txt" internalloglevel="trace"> 

this might give idea on issue. authentication issue server or issue.

since specifying server information in target, don't need web.config settings.

not sure if fixed yet, should add timeout="10000" target closes connection.

there pretty example in nlog wiki gmail works


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -