NLog settings for LogEntries
The trick with NLog and LogEntries is to make sure you put all your NLog config data into seperate files and then use the web.config transformations to determine which file to use.
app.config
<configSections>
<section name="nlog"
type="NLog.Config.ConfigSectionHandler, NLog" />
....
</configSections>
<nlog configSource="NLog.release.config" />
nlog.config
(Not Content, Copy when new)
NOTE: This is using Sentinal for the UI
<?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"
autoReload="true"
throwExceptions="true">
<extensions>
<add assembly="LogentriesNLog"/>
</extensions>
<!-- NLog example: https://github.com/nlog/nlog/wiki/Examples -->
<targets async="true">
<target xsi:type="NLogViewer"
name="sentinal"
address="udp://127.0.0.1:9999" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="sentinal"/>
</rules>
</nlog>
nlog.release
(Not Content, Copy when new)
NOTE: replace the email settings with whatever is yours
<?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"
autoReload="true"
throwExceptions="true">
<extensions>
<add assembly="LogentriesNLog"/>
</extensions>
<!-- NLog example: https://github.com/nlog/nlog/wiki/Examples -->
<targets>
<target name="logentries" type="Logentries"
debug="false"
httpPut="false"
ssl="false"
layout="${logger} : ${LEVEL} : ${message}" />
<target name="email-Errors" xsi:type="Mail"
smtpServer="smtp.sendgrid.net"
smtpPort="587"
smtpUsername="XXXXXXXXXX"
smtpPassword="XXXXXXXXXXXXXXX"
smtpAuthentication="Basic"
from="XXXXXXXXX@YYYYYYYYYY.com"
to="XXXXXXXXX@YYYYYYYYYY.com"
subject="XXXXXXXXXXXXXX"
html="true" />
</targets>
<rules>
<logger name="*" minlevel="Debug" appendTo="logentries"/>
<logger name="*" minlevel="Warn" writeTo="email-Errors" />
</rules>
</nlog>
Written by Pure Krome
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Logging
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#