Easily track and troubleshoot errors in your .NET 7 web app using Konso's logging feature

With Konso's logging integration, our .NET 7 web application is now even more robust. This powerful feature gives us detailed insights into the app's performance, making it easier to identify and fix any issues that arise.

Observability is obviously the thing for next couple of years. It is one of system's attributes, which differs modern system from legacy.  

The starting point for every project's observability is our old friend - logging. Major problem with logs is that Developers usually do not like adding logs to their code, the business, in its turn, doesn't see a value of it and topic usually gets deprioritized. 

Everyone recalls of logs when something bad happens. To avoid this sort of adventures, logs should be in code from day one and maintained as project grows.

Another, but not less dramatic problem is that amount of log data is huge, specially for microservices solutions. Developers do have a hard time to find something valuable in such data chaos. Konso is about to address this exact problem. 

We created Konso based on our internal product we developed and maintained for years as development team. Konso allows easily explore logs and integration is super fast without an agent installation. 

Here in this post I would like to show how can you quickly integrate with konso and start receiving and explore data. 

Create konso account, it has free plan :)

Create a new bucket

image

  1. Add Logging functionality to your bucket

image

  1. Clone source or install nuget package to your project

Repository from github

git clone https://github.com/konsoio/konso-logs-clients-dotnet .

Nuget usage

Install-Package Konso.Clients.Logging
  1. Configuration

Go to Settings -> API access for obtaining api-key and bucket id

image

Add configuration to your **appsettings.json**

"Konso": {
    "Logging": {
        "Endpoint": "https://apis.konso.io",
        "BucketId": "<your bucket id>",
        "ApiKey": "<bucket's access key>",
        "App": "api",
        "Level": "Information"
    }
}

Then configure logging

.ConfigureLogging(logging => {
    logging.ClearProviders();
    logging.AddKonsoLogger();
})
.ConfigureServices((hostContext, services) =>
{
    var _logsConfig = new KonsoLoggerConfig();
    _logsConfig.Endpoint = hostContext.Configuration.GetValue<string>("Konso:Logging:Endpoint");
    _logsConfig.BucketId = hostContext.Configuration.GetValue<string>("Konso:Logging:BucketId");
    _logsConfig.AppName = hostContext.Configuration.GetValue<string>("Konso:Logging:App");
    _logsConfig.ApiKey = hostContext.Configuration.GetValue<string>("Konso:Logging:ApiKey");
    services.AddSingleton(_logsConfig);
    services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
})

Now you can run your project

  1. Navigate to Observability -> Logs -> Overview to find logging dashboard

image

Next, you can navigate to the Explore screen to search for, filter, and delve into the detailed information about the project's logs.

Detailed API reference can be found https://docs.konso.io/api/logs

Check out the example of todo application with logging on GitHub: todo. It provides a hands-on demonstration of how to use Konso logging, allowing you to explore the code and understand the underlying concepts.

Facing a similar decision?

Tell me what you're working on. We'll start from the problem, not a service package.

Discuss your challenge