Hosting services in .NET Core console application

Building .NET Core console applications with IHost and HostBuild to take advantage of IHostedService, graceful shutdown, dependency injection, logging, configuration and more.

When building services for data processing you do not always need a user interface. An IHost is very capable of hosting such an application in a console application as headless service. The IHost does give you a number of advantages like graceful shut down, dependency injection, logging, and configuration. When running long processing tasks in Docker containers, graceful shut down helps you to keep the state of your application consistent. This post explains how making use of the generic IHost in .NET Core for headless services.

Continue reading “Hosting services in .NET Core console application”

Log4Net troubleshooting, debug your configuration

See some common log4net problems and learn how to debug/solve then.

logoLog4net is a fail-stop logging system. Fail stop means that it stops logging on an internal exception and by design does not interact with the program flow. Knowing this explains you troubleshooting log4net isn’t so easy. If logging fails, your program does not notice. You see a lot of questions about: why is my log4net logging not working? This article explains the basic troubleshooting and most common solutions.

Continue reading “Log4Net troubleshooting, debug your configuration”

Get your web application errors into Slack

Get your devops going by integrating your application into your team communication tooling.

bugbotTo get more out of Slack and your team, you can integrate Slack with your application. Integrating with slack is done with webhooks. In this sample I use a Incoming Webhook to post the messages from the application to slack. By adding a GlobalExceptionFilter to you .Net Core web application, you can get all exceptions that are not handled in your web application.
Continue reading “Get your web application errors into Slack”

Application Shutdown in ASP.NET Core with IApplicationLifetime

Learn how to gracefully handle Application Shutdown in ASP.NET Core by looking at the handling of flushing the application insights messages when asp.net core exits

When running an ASP.NET Core web application, there are cases when you need to do some logic when the application stops. An example: you are logging and have to flush the last message to the log (Application Insights). In that case you need can add an event in the Configure method. In this post I show a short example of how doing this.
Continue reading “Application Shutdown in ASP.NET Core with IApplicationLifetime”