Comments (10)
This is to confirm that I can reproduce your issue (without the need for Task.Run
), as such I will be re-opening this.
from serilog-sinks-slack.
I was pretty confident that this issue has already been resolved in the past - and in fact it was. Unfortunately a later commit undid the fix through an out-of-order disposal.
This should be resolved again in v2.2.0. Kindly confirm.
from serilog-sinks-slack.
I am running into the same issue, my work around is not efficient (using sleep thread) but has improved my delivery rate.
private void FlushAndExit(Exception exception, string message = "")
{
if (string.IsNullOrEmpty(message)) { message = "Unrecoverable Runtime Error, Application Will Exit"; }
Log.Fatal(exception, message); // NOTE: Will post Fatal events to #devops slack channel
Log.Information("[{Name} - END...]", Assembly.GetEntryAssembly().GetName().Name);
Log.CloseAndFlush();
// Give ample time for the CloseAndFlush to finish...
Thread.Sleep(new TimeSpan(0, 0, 0, 10));
Environment.Exit(-1);
}
from serilog-sinks-slack.
Same problem here, my program terminates rather quickly after i log an event to this sink. (i only send Fatal messages to slack as it runs on multiple machines).
When testing with the Thread.Sleep, i start to get the messages with a delay of about 1200-1250 ms, 1500 to be safe.
This however is very machine and instance specific and i'd figure there should be a different, more flexible way of checking if everything is sent before i dispose my program.
from serilog-sinks-slack.
v2.1.0 still not fixed
from serilog-sinks-slack.
@homolibere I'm going to need more information to work with this. This should have been fixed since v2.0.0, but there may be situations in which the app terminates before it is done flushing the content to the underlying sink, and thereby logging to slack.
from serilog-sinks-slack.
when i call Log.CloseAndFlush(); it does not wait till it flushes all messages and terminates application right away.
using Thread.Sleep is a only workaround, but it's a very dirty code.
from serilog-sinks-slack.
If I recall correctly that should be one of the more common scenarios which should work correctly, without the need for Thread.Sleep
. I might need to take another look at it at some point next week. How are you using the logger in your application? Are you using DI at all, or working directly with the static Log
? Could you share a snippet of how you're configuring the logger in a succinct manner that reproduces the error?
from serilog-sinks-slack.
using Serilog;
using Serilog.Formatting.Json;
using Serilog.Sinks.Slack;
var configuration = new LoggerConfiguration().Enrich.FromLogContext();
configuration.WriteTo.Console(formatter: new JsonFormatter());
configuration.WriteTo.Slack("https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
Log.Logger = configuration.CreateLogger();
Task task = Task.Run(async () => {
for (int i = 0; i < 10; i++)
{
Log.Logger.Information(i.ToString());
Task.Delay(500).Wait();
}
});
task.Wait();
Log.CloseAndFlush();
net6 console example. without delay 500 - it does not show any messages, with it at least firs 3-4
from serilog-sinks-slack.
Confirm, it is fixed now
from serilog-sinks-slack.
Related Issues (20)
- Stacktrace field with too long message causes incorrect display HOT 2
- Sign the Assembly with a Strong Name
- usage with Serilog.Settings.Configuration HOT 3
- Add support for outputTemplate message formatting HOT 2
- Slack webhook only working in dotnet core HOT 1
- Sink not writing to Slack HOT 7
- Support custom timestamp attachment format
- Missing license file HOT 1
- Can we show Event properties fullscreen? HOT 3
- MinimumLogEventLevel is ignored HOT 4
- Add Serilog Sink icon to Serilog.Sinks.Slack NuGet package HOT 1
- Application exit before slack log is "slacked" HOT 1
- Expose QueueLimit configuration option
- Publish to NuGet fails HOT 5
- Sink not working in .NET Framework 4.5.2 HOT 1
- Enhancement: Allow option to add custom attachments
- Allow one channel per log level HOT 1
- Upgrading to the latest version of Serilog causes infinite loop HOT 5
- Feature Request: Filtering Logs based on Properties HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serilog-sinks-slack.