Easily track and troubleshoot errors in your .NET 7 web app using Konso's logging feature
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
- Add Logging functionality to your bucket
- 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
- Configuration
Go to Settings -> API access for obtaining api-key and bucket id
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
- Navigate to Observability -> Logs -> Overview to find logging dashboard
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.
🚀 Turbocharge Your Infrastructure with Our Terraform Template Kits! 🚀
🌟 Slash deployment time and costs! Discover the ultimate solution for efficient, cost-effective cloud infrastructure. Perfect for DevOps enthusiasts looking for a reliable, scalable setup. Click here to revolutionize your workflow!
Learn More about Starter Terraform Kits for AKS,EKS and GKE
No comments are allowed for this post