cyrilgandon / nlogtoslack Goto Github PK
View Code? Open in Web Editor NEWAn NLog target for Slack
An NLog target for Slack
Instead of doing this override:
protected override void Write(AsyncLogEventInfo info)
Then SlackTarget should perform the following override (and remove the try-catch-logic)
protected override void Write(LogEventInfo info)
The override of the AsyncLogEventInfo-variant is intended for async-operations, where the result is returned later on a different thread.
I've created a simple console app and installed this package and nlog fails to initialise if I have an xsi:type="Slack" target.
Repro steps:
Result:
Notes:
Any relation to this issue?
NLog/NLog#904
nuget package versions:
<packages>
<package id="NLog" version="4.1.0" targetFramework="net45" />
<package id="NLogToSlack" version="4.1.2.0" targetFramework="net45" />
</packages>
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">
<extensions>
<add assembly="NLogToSlack" />
</extensions>
<targets async="true">
<target xsi:type="Console" name="console"
layout="${longdate}|${level:uppercase=true}|${machinename}|${processname}|${processid}|${threadid}|${event-properties:item=caller}|${event-properties:item=PortfolioId}|${message}" />
<target xsi:type="Slack"
name="slackTarget"
layout="${message}"
webHookUrl="https://xxx.slack.com/services/hooks/incoming-webhook?token=xxx"
channel="#log"
username="NLogToSlack"
compact="false"
icon=":ghost:" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="console" />
<logger name="*" minlevel="Fatal" writeTo="slackTarget" />
</rules>
</nlog>
sample code:
static void Main(string[] args)
{
var Logger = NLog.LogManager.GetCurrentClassLogger();
if (Logger.IsInfoEnabled == false && Logger.IsWarnEnabled == false && Logger.IsErrorEnabled == false && Logger.IsFatalEnabled == false)
{
throw new Exception("NLog failed to initialise - check NLog.config, and ensure all nlog extension dlls are present in directory");
}
Logger.Info("Info");
Logger.Error("Error");
Logger.Fatal("Fatal");
NLog.LogManager.Flush();
}
First @cyrilgandon, thanks for making this package available, it's awesome! I know that the repo's not a high priority item for you, but I've run into issues with a recent deployment that has me scratching my head and unsure of how to troubleshoot.
In one solution where NLogToSlack was working perfectly fine before, I updated my NLog dependencies from 4.3.7 to 4.4.6 (was and am running NLogToSlack 4.2.0). This solution is deployed as on Azure App Service. After updating NLog and pushing up to Azure, I no longer am getting messages coming through to Slack.
When testing locally though, the Slack destination works just fine (triggering log entries locally goes to my expected destination Slack). But any log messages generated on Azure don't make it through. This makes me think that the problem probably doesn't lie with NLogToSlack, but something obviously changed and I don't know how to figure out what.
Any thoughts at all as to how to go about solving this? I know there's been PRs in the past to update to more recent versions to NLog--does that sort of thing often resolve these types of problems or is it more of a maintenance thing? Thanks for any tips you've got!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.