ASP.NET Core 2.2.1 Hosting Tips: How To Archive Log Files Using NLog With ASP.NET Core

Rate this post

In this article, you will learn how to archive log files using NLog with ASP.NET Core . Most of the time, we will store logs in files, and we should archive them so that we can manage them easier. Let’s take a look at how to use NLog to archive log files. Create a new ASP.NET Core Web API Application and install NLog.Web.AspNetCore via nuget.

Create a nlog.config file, and enable copy to bin folder. We just archive the log files via this configuration file.

Just pay attention to the opions that contains archive. The above configuration means that we hava a main log file named nlogdemo.log which stores today’s log. It will archive logs daily and the file name of the archive log file will be formatted like nlogdemo-20180505.log.

And the max number of archived log files is 4 which means it will keep only the newest 4 files.

Step 3

Update program.cs so that we can enable NLog.

Step 4

Write some logs in controller.

Now, change the date of computer to see the results.

Best ASP.NET Core 2.2.1 Hosting Recommendation

One of the most important things when choosing a good ASP.NET Core 2.2.1 hosting is the feature and reliability. HostForLIFE is the leading provider of Windows hosting and affordable ASP.NET Core 2.2.1 , their servers are optimized for PHP web applications such as the latest ASP.NET Core 2.2.1 version. The performance and the uptime of the ASP.NET Core 2.2.1 hosting service are excellent and the features of the web hosting plan are even greater than what many hosting providers ask you to pay for. At HostForLIFE.eu, customers can also experience fast ASP.NET Core 2.2.1 hosting. The company invested a lot of money to ensure the best and fastest performance of the datacenters, servers, network and other facilities. Its datacenters are equipped with the top equipments like cooling system, fire detection, high speed Internet connection, and so on. That is why HostForLIFE.eu guarantees 99.9% uptime for ASP.NET Core 2.2.1. And the engineers do regular maintenance and monitoring works to assure its ASP.NET Core 2.2.1 hosting are security and always up.

 

hostforlifebanner

Leave a Reply

Your email address will not be published. Required fields are marked *