All Projects → andrewlock → NetEscapades.Extensions.Logging

andrewlock / NetEscapades.Extensions.Logging

Licence: MIT License
A rolling file logging provider for ASP.NET Core 2.0

Programming Languages

C#
18002 projects
powershell
5483 projects
shell
77523 projects
Batchfile
5799 projects

Projects that are alternatives of or similar to NetEscapades.Extensions.Logging

DNZ.MvcComponents
A set of useful UI-Components (HtmlHelper) for ASP.NET Core MVC based-on Popular JavaScript Plugins (Experimental project).
Stars: ✭ 25 (-71.26%)
Mutual labels:  aspnetcore, asp-net-core
Something-about-aspnetcore-book
The Something about ASP.NET Core Book is introduction to web programming and based on ASP.NET Core 2.2
Stars: ✭ 35 (-59.77%)
Mutual labels:  aspnetcore, asp-net-core
smart-blazor
Blazor UI Components & Examples
Stars: ✭ 32 (-63.22%)
Mutual labels:  aspnetcore, asp-net-core
AspNetCoreMvcAngular
ASP.NET Core MVC with angular in MVC View OpenID Connect Hybrid Flow
Stars: ✭ 54 (-37.93%)
Mutual labels:  aspnetcore, asp-net-core
OrdersManagementSystem
Project demonstrates usage of Prism composition library, Material design library, SQL Server, Entity Framework in WPF application
Stars: ✭ 29 (-66.67%)
Mutual labels:  aspnetcore, asp-net-core
high-performance-aspnet-core-workshop
Sample application used in the High-Performance ASP.NET Core Workshop
Stars: ✭ 29 (-66.67%)
Mutual labels:  aspnetcore, asp-net-core
JwtAuthDemo
ASP.NET Core + Angular JWT auth demo; integration tests; login, logout, refresh token, impersonation, authentication, authorization; run on Docker Compose.
Stars: ✭ 278 (+219.54%)
Mutual labels:  aspnetcore, asp-net-core
grandnode2
Free, Open source, Fast, Headless, Multi-tenant eCommerce platform built with .NET Core, MongoDB, AWS DocumentDB, Azure CosmosDB, LiteDB, Vue.js.
Stars: ✭ 626 (+619.54%)
Mutual labels:  aspnetcore, asp-net-core
BlazorWasmWithDocker
Companion code sample for my blog post - Containerising a Blazor WebAssembly App
Stars: ✭ 16 (-81.61%)
Mutual labels:  aspnetcore, asp-net-core
BlazorServerWithDocker
Companion code sample for my blog post - Containerising a Blazor Server App
Stars: ✭ 16 (-81.61%)
Mutual labels:  aspnetcore, asp-net-core
SimpleSocial
A simple social network web application using ASP.NET Core 3.1
Stars: ✭ 16 (-81.61%)
Mutual labels:  aspnetcore, asp-net-core
SignalR-Core-SqlTableDependency
Shows how the new SignalR Core works with hubs and sockets, also how it can integrate with SqlTableDependency API.
Stars: ✭ 36 (-58.62%)
Mutual labels:  aspnetcore, asp-net-core
DNTCaptcha.Core
DNTCaptcha.Core is a captcha generator and validator for ASP.NET Core applications
Stars: ✭ 181 (+108.05%)
Mutual labels:  aspnetcore, asp-net-core
Awesome-Nuget-Packages
📦 A collection of awesome and top .NET packages sorted by most popular needs.
Stars: ✭ 87 (+0%)
Mutual labels:  aspnetcore, asp-net-core
TheLastTime
C# .NET 5 Blazor WebAssembly Progressive Web Application that tracks when was the last time you did something
Stars: ✭ 23 (-73.56%)
Mutual labels:  aspnetcore, asp-net-core
Ext.NET
Ext.NET public Issues.
Stars: ✭ 28 (-67.82%)
Mutual labels:  aspnetcore, asp-net-core
MvcControlsToolkit.Core
Core Code for MvcControlsToolkit packages
Stars: ✭ 13 (-85.06%)
Mutual labels:  aspnetcore, asp-net-core
MvcSimplePager
Simple,lightweight,easy to expand pager for asp.net mvc and asp.net core,针对asp.net mvc 和 asp.net core 设计的通用、扩展性良好的轻量级分页扩展
Stars: ✭ 13 (-85.06%)
Mutual labels:  aspnetcore, asp-net-core
AspNetCore.Mvc.FluentActions
Fluent Actions for ASP.NET Core MVC are abstractions of regular MVC actions that are converted into MVC actions during startup.
Stars: ✭ 17 (-80.46%)
Mutual labels:  aspnetcore, asp-net-core
Home
Asp.net core Mvc Controls Toolkit
Stars: ✭ 33 (-62.07%)
Mutual labels:  aspnetcore, asp-net-core

NetEscapades.Extensions.Logging

Build status NuGet RollingFile

NetEscapades.Extensions.Logging.RollingFile

A rolling file provider for ASP.NET Core 2.1 Microsoft.Extensions.Logging, the logging subsystem used by ASP.NET Core. Writes logs to a set of text files, one per day.

Getting Started

First Install the NetEscapades.Extensions.Logging.RollingFile package from NuGet, either using powershell:

Install-Package NetEscapades.Extensions.Logging.RollingFile

or using the .NET CLI:

dotnet add package NetEscapades.Extensions.Logging.RollingFile

Next configure the provider by calling AddFile() on an ILoggingBuilder during logger configuration in Program.cs.

public class Program
{
    public static void Main(string[] args)
    {
        BuildWebHost(args).Run();
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .ConfigureLogging(builder => builder.AddFile()) // <- Add this line
            .UseStartup<Startup>()
            .Build();
}

You can pass additional options to the Add File by passing an Action<FileLoggerOptions>, for example:

public class Program
{
    public static void Main(string[] args)
    {
        BuildWebHost(args).Run();
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .ConfigureLogging(builder => builder.AddFile(options => {
                options.FileName = "diagnostics-"; // The log file prefixes
                options.LogDirectory = "LogFiles"; // The directory to write the logs
                options.FileSizeLimit = 20 * 1024 * 1024; // The maximum log file size (20MB here)
                options.FilesPerPeriodicityLimit = 200; // When maximum file size is reached, create a new file, up to a limit of 200 files per periodicity
                options.Extension = "txt"; // The log file extension
                options.Periodicity = PeriodicityOptions.Hourly // Roll log files hourly instead of daily.
            })) 
            .UseStartup<Startup>()
            .Build();
}

Finally The provider will create log files prefixed with the FileName, and suffixed with the current date in the yyyyMMddHHmm format (using only the portions up to the selected periodicity, yyyyMMdd for the default of daily).

log-20160631.txt
log-20160701.txt
log-20160702.txt

Logs will look something like the following:

2017-09-01 18:34:18.083 +01:00 [Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request starting HTTP/1.1 GET http://localhost:50037/api/values  
2017-09-01 18:34:18.159 +01:00 [Information] Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker: Executing action method SampleApp.Controllers.ValuesController.Get (SampleApp) with arguments ((null)) - ModelState is Valid
2017-09-01 18:34:18.161 +01:00 [Information] SampleApp.Controllers.ValuesController: Executed Get action
2017-09-01 18:34:18.165 +01:00 [Information] Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutor: Executing ObjectResult, writing value Microsoft.AspNetCore.Mvc.ControllerContext.
2017-09-01 18:34:18.192 +01:00 [Information] Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker: Executed action SampleApp.Controllers.ValuesController.Get (SampleApp) in 36.3435ms
2017-09-01 18:34:18.195 +01:00 [Information] Microsoft.AspNetCore.Hosting.Internal.WebHost: Request finished in 113.6076ms 200 application/json; charset=utf-8

Credits

This provider is heavily cribbed from the Azure App Service Logging Provider from the ASP.NET team.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].