serilog-sinks-http icon indicating copy to clipboard operation
serilog-sinks-http copied to clipboard

integration with Serilog.AspnetCore.Ingestion

Open tusanesen opened this issue 4 years ago • 5 comments

There is a packet called Serilog.AspNetCore.Ingestion which is a sort of a relay to integrate clientSide serilog to the server side one seemlessly. So that logs post by client are directed to the serilog pipeline configured on the server. Only problem for http-sink to work with it is that it expects new line delimeted logs which requires one more batchFormatter..

Thanks

tusanesen avatar Apr 01 '21 14:04 tusanesen

Hi there and welcome to this repository!

A maintainer will be with you shortly, but first and foremost I would like to thank you for taking the time to report this issue. Quality is of the highest priority for us, and we would never release anything with known defects. We aim to do our best but unfortunately you are here because you encountered something we didn't expect. Lets see if we can figure out what went wrong and provide a remedy for it.

github-actions[bot] avatar Apr 01 '21 14:04 github-actions[bot]

Hi!

This sink comes prebuilt with two batch formatters, DefaultBatchFormatter and ArrayBatchFormatter. The JSON format they produce can be found here. Can you define the format you would like your formatter to produce?

FantasticFiasco avatar Apr 01 '21 18:04 FantasticFiasco

Hi..

I tried with the message below, it worked. { event n } { event n+1 }

When I look at the code, that message with line seperated objects provide a kind of convenience to get those objects in a async while loop, as follows

var reader = new StreamReader(context.Request.Body); var line = await reader.ReadLineAsync(); while (line != null) {

Ref: https://github.com/nblumhardt/serilog-sinks-browserhttp/blob/dev/src/Serilog.AspNetCore.Ingestion/AspNetCore/Ingestion/SerilogIngestionMiddleware.cs

Thanks ..

tusanesen avatar Apr 02 '21 07:04 tusanesen

Thanks for specifying the format.

Given that Serilog.Sinks.BrowserHttp still is in an experimental stage, I won't add this batch formatter until it has gotten some traction by the community. But until then you can write the batch formatter yourself and keep it in your codebase. Writing it is really easy, just copy from ArrayBatchFormatter.Format and modify it according to your needs.

I'll leave this issue open to see if other developers feel like you do. Thanks for bringing this issue to my attention!

FantasticFiasco avatar Apr 02 '21 07:04 FantasticFiasco

Yes I did my stuff. just wanted to notify you. thanks..

tusanesen avatar Apr 02 '21 15:04 tusanesen