0
votes

Is there a Serilog sink that just writes to a buffer in memory? What I am thinking about is a sink that will store X lines and then I could access those X lines and show them on a web page via an api controller. This would be more for viewing recent errors that occurred in the application.

I looked on the GitHub sink page (https://github.com/serilog/serilog/wiki/Provided-Sinks) but did not see one and just wondered if there was something I was missing.

1

1 Answers

3
votes

Serilog doesn't have a built-in Sink that writes to memory, but you could easily write one just for that. Take a look, for example, at the DelegatingSink that is used in Serilog's unit tests, which is 80% of what you would need... You'd just have to store the events in an in-memory data structure.

Another option would be to use the mssqlserver sink, write the events to a simple table, and display in your web app.

A third option (which would be my recommendation) would be to just install Seq, which is free for development and single-user deployment, and just write the logs to Seq through their sink. That will save you from having to write the web app, and will give you search and filtering out-of-the-box.

Seq