Git Product home page Git Product logo

nlogtoslack's People

Contributors

cyrilgandon avatar eth0izzle avatar naugolnykh-arkadium avatar philjones avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nlogtoslack's Issues

SlackTarget should override Write(LogEventInfo)

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.

Doesn't work

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:

  1. Open visual studio
  2. Create new console app
  3. Open package manager console
  4. Install-Package NLogToSlack
    (see below for versions which were installed on my machine)
  5. Add nlog.config (see below) and set property "Copy to output directory": Copy if newer
  6. Add sample code (see below)
  7. Build and run

Result:

  1. NLog is uninitialised - will enter "throw new Exception" block (see below)
  2. If you comment out the slack target & rule then nlog intialises successfully and will log to console

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();
        }

Troubleshooting broken Slack destination

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.