Lvhang.TinyTxtLogger 0.9.0

.NET Core 3.1
NuGet\Install-Package Lvhang.TinyTxtLogger -Version 0.9.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package Lvhang.TinyTxtLogger --version 0.9.0
<PackageReference Include="Lvhang.TinyTxtLogger" Version="0.9.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Lvhang.TinyTxtLogger --version 0.9.0
#r "nuget: Lvhang.TinyTxtLogger, 0.9.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Lvhang.TinyTxtLogger as a Cake Addin
#addin nuget:?package=Lvhang.TinyTxtLogger&version=0.9.0

// Install Lvhang.TinyTxtLogger as a Cake Tool
#tool nuget:?package=Lvhang.TinyTxtLogger&version=0.9.0

TinyTxtLogger

summary

this logger tool is fully based on Microsoft.Extensons, you can use it in .NET Worker Service or ASP.NET Core project. if you are working on those project and looking for a logger tool that save logs to local txt file, this is the one you need.

it's very easy to use this tool, you only need one line of code to add this tool to your project: logging.AddTinyTxt();

installition

you can include this tool from NuGet with name Lvhang.TinyTxtLogger.

IHost host = Host.CreateDefaultBuilder(args)
    .ConfigureLogging((context, logging) =>

    {

        logging.ClearProviders();

        logging.AddTinyTxt();//add TinyTxtLogger

    })

    .ConfigureServices(services =>

    {

        services.AddHostedService<Worker>();

    })

    .Build();

configuration

there's two way to configure the tool

way 1 with code:

logging.AddTinyTxt(options =>

        {

            options.TxtLogFolderName = "logs"; //log folder name

            options.LogFileNamePrefix = "log"; //log file prefix

            options.RollingInterval = eRollingInterval.Day; //log file rolling interval

            options.FileSizeLimit = 10240;// size limit of single file

           options.AutoCleanLogFolder = false; // if log file in folder over the limit if clean the folder

            options.ReserveLogFileCount = 30; //log file reserve when clean the log folder

        });

way 2 with appsetting.json file:

{

"Logging": {

  "LogLevel": {

    "Default": "Trace",

    "Microsoft.Hosting.Lifetime": "Trace"

  },

  "TinyTxt": {

    "LogLevel": {

      "Default": "Trace",

      "Microsoft.Hosting.Lifetime": "Trace"

    },

    "Options": {

      "TxtLogFolderName": "logs",

      "LogFileNamePrefix": "log",

      "RollingInterval": "Year",  // Hour,Day,Month,Year,Infinite

      "FileSizeLimit": 10240,  //in KB

      "AutoCleanLogFolder": false,

      "ReserveLogFileCount": 30

    }

  }

}

}

after you complete your configuration in appsetting.json, you need add one line to your code to bind your configuration:

IHost host = Host.CreateDefaultBuilder(args)

    .BindTinyTxtLoggerOptions() //this line to bind configuration

    .ConfigureLogging((context, logging) =>

    {

        logging.ClearProviders();

        logging.AddTinyTxt(;

    })

    .ConfigureServices(services =>

    {
        services.AddHostedService<Worker>();

    })

    .Build();

and that's almost every this of this tool, except that this project provide a tool to help you to view log file more friendly.

log viewer tool

log viewer tool is a single html page app, with this tool you can search logs and view log file statistics charts as below screenshot shows. you can download this tool from logviewer folder in Github or more conveniently you can visit online version TinyTxt LogViwer, BTW nothing will be uploaded in both way, all the log data are processed in browser.

image

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.9.0 109 4/14/2022