serilog-contrib / serilog-sinks-slackclient

Slack Sink for Serilog
Apache License 2.0
27 stars 15 forks source link

Not getting any output to slack #4

Closed worldspawn closed 6 years ago

worldspawn commented 7 years ago

Hi,

i'm trying to integrate this sink. I've am using a webhook pointing to the room i want and have configured the sink

return new LoggerConfiguration()
                    .MinimumLevel.Verbose()
                    .WriteTo.Slack(settings.SlackWebhookUrl)
                    .CreateLogger();

My error is:

2016-09-26T11:08:17.7516657Z Trying to send message to webhook 'https://hooks.slack.com/services/T/B/M': 'Command Executing: 7e9d2fed-df2b-4b55-8546-f71d6e42705e - SetRatingToInvalid { DeviceRatingId: e66a3c2b-22fc-4cd7-8962-98e46a32da66, RatingValidator: Face, Notes: "Some notes" }'.
2016-09-26T11:08:18.3348892Z Caught exception while emitting to sink Serilog.Sinks.Slack.SlackSink: System.Net.WebException: The remote server returned an error: (400) Bad Request.
Response from https://hooks.slack.com/services/T/B/M:
invalid_payload ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at <StartupCode$FSharp-Core>.$Control.callback@1784.Invoke(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at FSharp.Data.HttpHelpers.augmentWebExceptionsWithDetails@493-3.Invoke(Unit unitVar) in C:\Git\FSharp.Data\src\Net\Http.fs:line 493
   at Microsoft.FSharp.Control.AsyncBuilderImpl.callA@851.Invoke(AsyncParams`1 args)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.FSharp.Control.AsyncBuilderImpl.commit[a](Result`1 res)
   at Microsoft.FSharp.Control.CancellationTokenOps.RunSynchronously[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout)
   at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken)
   at Serilog.Sinks.Slack.SlackSink.Emit(LogEvent logEvent)
   at Serilog.Core.Sinks.SafeAggregateSink.Emit(LogEvent logEvent)
2016-09-26T11:08:22.7524327Z Trying to send message to webhook 'https://hooks.slack.com/services/T/B/M': 'Command Error: 7e9d2fed-df2b-4b55-8546-f71d6e42705e'.
2016-09-26T11:08:23.7426090Z Caught exception while emitting to sink Serilog.Sinks.Slack.SlackSink: System.Net.WebException: The remote server returned an error: (400) Bad Request.
Response from https://hooks.slack.com/services/T/B/M:
invalid_payload ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at <StartupCode$FSharp-Core>.$Control.callback@1784.Invoke(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at FSharp.Data.HttpHelpers.augmentWebExceptionsWithDetails@493-3.Invoke(Unit unitVar) in C:\Git\FSharp.Data\src\Net\Http.fs:line 493
   at Microsoft.FSharp.Control.AsyncBuilderImpl.callA@851.Invoke(AsyncParams`1 args)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.FSharp.Control.AsyncBuilderImpl.commit[a](Result`1 res)
   at Microsoft.FSharp.Control.CancellationTokenOps.RunSynchronously[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout)
   at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken)
   at Serilog.Sinks.Slack.SlackSink.Emit(LogEvent logEvent)
   at Serilog.Core.Sinks.SafeAggregateSink.Emit(LogEvent logEvent)

I've modified the hook uri shown here.

marcio-azevedo commented 7 years ago

Are you sure you have a valid webhook url? Check if you're using this packages versions of:

<package id="FSharp.Core" version="4.0.0.1" targetFramework="net451" />
<package id="FSharp.Data" version="2.3.2" targetFramework="net451" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net451" />
<package id="Serilog" version="2.2.1" targetFramework="net451" />

Just released a new version fixing the package dependencies to have the right version.

worldspawn commented 7 years ago

Hi the webhook url definately works. I dont think i had newtonsoft 9, working with webapi i usually have only 6.0.8 at the most otherwise i start getting mismatches. I ended up using a fork of another slack sink that I then had to fork myself to get working (i'm not savvy with f#).

I'm going to close this as I im not going to spend more time on it. Thanks anyway.

marcio-azevedo commented 7 years ago

Ok, at least try it with the other version dependencies: `

`

yohanmishkin commented 7 years ago

@marcio-azevedo doesn't seem to be working on my system. Any insights on how I might be able to troubleshoot?

I've manually verified that the webhook works and my dependencies match yours. Thanks!

worldspawn commented 7 years ago

@yohanmishkin my colleague ended up forking a different implementation. we using it currently - https://github.com/APErebus/serilog-sinks-slack. its not on nuget. we using up to commit f601e0fa74f5526da7945352f5d7d325a8b0028b. Recommend ur fork it

Eg: var webhookUrl = settings.SlackWebhookUrl; if (!string.IsNullOrEmpty(webhookUrl)) { loggerConfig .WriteTo.Logger(lc => lc .MinimumLevel.ControlledBy(loggingLevel) .WriteTo.Slack(webhookUrl)); }

yohanmishkin commented 7 years ago

Thanks @worldspawn! I actually gave this version a shot it seemed to work.

marcio-azevedo commented 7 years ago

@yohanmishkin can you post the error? Also ensure that the dependencies have the proper (NuGet package) version installed, namely: `

`

marcio-azevedo commented 6 years ago

Closing this issue. Feel free to re-open if you still have an error.