Alex's Coding Blog
  • Home
  • About
  • Projects
  • Contact me

Blog

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

  • January 12, 2023 January 12, 2023
  • by Alexander

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. 

  1. Create konso account, it has free plan :)

  2. 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 referense can be found https://docs.konso.io/api/logs

.NET Core How-to

Debugging microservices is always tricky and time consuming specially without proper code level logging in place.

Meet Konso. It's developed as a solution for this challenge and can help with saving development effort for your team up to 30%. 🎯🎉

The key functions are:

🔥 Centralized logging for your microservices
🔥 Tracing with metrics and value tracking events
🔥 Ad-Hoc events exploration
🔥 Saving your queries
🔥 Create alerts and get notified


You can start collecting you project's logs in 5 minutes. 🕐💪

To Learn more about logging tool, book a free demo.
To get started for free, Create your free account now

Alexander Lvovich

Solution Architect and Software Developer.

Share on:

No comments are allowed for this post

Recent Posts

  • How to disable object model validation .NET 7
  • Keep Your Passwords Safe: 5 Tips for Protecting Yourself After the Latest LastPass Data Breach
  • How to ping from .net application container
  • Freelancing myths you should consider before dive in
  • How to set up a honey token for dotnet project with Konso

Categories

  • Azure
  • Architecture
  • .NET Core
  • Certification
  • DevOps
  • How-to
  • Azure Functions
  • Serverless
  • Cosmos DB
  • Security
  • Thoughts
© Copyright 2023, Alexander Lvovich. Theme by Colorlib