Simple Logging with ILogger, Serilog and SQLite

Jay (Vijayasimha BR)
2 min readJan 11, 2025

--

attractive young indian woman, wearing a crop top, jeans shorts, logging notes in front of a dashboard

A quick demo in .NET 8.0 web api showcasing simple logging using a combination of ILogger, Serilog and SQLite.

This is a quick and simple project that shows logging with Serilog using ILogger and SQLite.

1. Serilog is one of the recommended libraries for production quality logging.

1. Using SQLite for the sake of simplicity, and the ‘log sink’.

1. Should be straighforward to switch the sink from SQlite to something else.

You can find the code here.

Logging in Action.

        [HttpGet("info")]
public IActionResult LogInformation()
{
_logger.LogInformation("This is an informational log message.");
return Ok("Information log recorded.");
}

[HttpGet("warning")]
public IActionResult LogWarning()
{
_logger.LogWarning("This is a warning log message.");
return Ok("Warning log recorded.");
}

[HttpGet("error")]
public IActionResult LogError()
{
_logger.LogError("This is an error log message.");
return Ok("Error log recorded.");
}

The logs look pretty cool in the SQLite DB.

That’s all there is to it.

I work as a coding tutor. You can hire me on Upwork, Fiverr and Codementor. You can also book a session on calendly, and visit my website. Also, video tutorials on my YouTube Channel. My Podcast is here.

--

--

No responses yet