Utility.FileSystem.Logging 1.0.1

dotnet add package Utility.FileSystem.Logging --version 1.0.1
NuGet\Install-Package Utility.FileSystem.Logging -Version 1.0.1
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.
<PackageReference Include="Utility.FileSystem.Logging" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Utility.FileSystem.Logging --version 1.0.1
#r "nuget: Utility.FileSystem.Logging, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Utility.FileSystem.Logging as a Cake Addin
#addin nuget:?package=Utility.FileSystem.Logging&version=1.0.1

// Install Utility.FileSystem.Logging as a Cake Tool
#tool nuget:?package=Utility.FileSystem.Logging&version=1.0.1

Utility.FileSystem.Logging


A simple library used to log data to the file system.

How to Use

<summary>There are two main ways to use the logging library. Both a valid and can be used interchangeably based on your needs.</summary>

1. Direct Calls to the Logger Class.

Calling the Logger methods directly gives you more control over the logging and allows you to log everything and anything.

Reasons to Use
  • You have full control over how the system logs information.
  • If you log it, it will write it to the filesystem.
  • If user control over logging needs are minimal or you want to let you user select between errors only or everything then these methods may make more sense.
Reasons to Avoid
  • This method of logging does not provide levels of logging that you may want to use to give you more information when troubleshooting issues.
  • The only way to limit logging is using the LogErrorsOnly variable in the GlobalObjects class.
2. Using the partial classes ConsoleOnly and Log.

By using the two partial classes ConsoleOnly and Log you have extended functionality over the logging process greater control over when and where you log something information. All the features used in the partial classes are available in the Logger class, but moved into a more helpful format to reduce the amount of duplication you have to do in order to log something in one part of your application and not in another. It also gives you the ability to control how much information is logged and when.

Reasons to Use
  • You to give more control over how much data is written to the log file or console when testing and reduce or log only specific events without having to comment all your previous logging activity out before publishing the application.
  • You may want to log something to the console and not write it to a log file.
Reasons to Avoid
  • You have a user who needs to see everything the application is doing and may miss important details if the logging is limited.

Log Levels


<summary>The logging levels are used by the partial classes and set in order so that all actions are logged by the logging level below. For example: if you set the 'LogLevel' to Debug, it will log all logging events. Whereas 'Fatal' will only log if the LogType being logged is sent in as a Fatal log.</summary>

Debug
Info
Warn
Error
Fatal

PlaceHolder Values


<summary>Placeholder values are used in the 'LogFileLocation' and 'LogFileName' to dynamically set the location and name of the file and directory. This makes the creation of log files over many days, months or years easier to organize. <warn>If you adjust the default value be sure that the GlobalObjects have replaced the PlaceHolder values or it will create a new log every time the placeholder value changes.</warn></summary>

Placeholder Options
DateTime Formats

{Day}: DateTime.Now.Day - 2 digit
{Month}: DateTime.Now.Month - 2 digit
{Year}: DateTime.Now.Year - 4 digit
{Hour}: DateTime.Now.Hour - 2 digit
{Minute}: DateTime.Now.Minute - 2 digit
{Second}: DateTime.Now.Second - 2 digit
{Millisecond}: DateTime.Now - 3 digit
{DayOfWeek}: DateTime.Now.DayOfWeek
{DayOfYear}: DateTime.Now.DayOfYear - 2 digit
{Ticks}: DateTime.Now.Ticks

DateTime UTC Formats
With an Underscore

{Day_UTC}: DateTime.UtcNow.Day - 2 digit
{Month_UTC}: DateTime.UtcNow.Month - 2 digit
{Year_UTC}: DateTime.UtcNow.Year - 4 digit
{Hour_UTC}: DateTime.UtcNow.Hour - 2 digit
{Minute_UTC}: DateTime.UtcNow.Minute - 2 digit
{Second_UTC}: DateTime.UtcNow.Second - 2 digit
{Millisecond_UTC}: DateTime.UtcNow - 3 digit
{DayOfWeek_UTC}: DateTime.UtcNow.DayOfWeek
{DayOfYear_UTC}: DateTime.UtcNow.DayOfYear - 2 digit
{Ticks_UTC}: DateTime.UtcNow.Ticks

Without an Underscore

{DayUTC}: DateTime.UtcNow.Day - 2 digit
{MonthUTC}: DateTime.UtcNow.Month - 2 digit
{YearUTC}: DateTime.UtcNow.Year - 4 digit
{HourUTC}: DateTime.UtcNow.Hour - 2 digit
{MinuteUTC}: DateTime.UtcNow.Minute - 2 digit
{SecondUTC}: DateTime.UtcNow.Second - 2 digit
{MillisecondUTC}: DateTime.UtcNow - 3 digit
{DayOfWeekUTC}: DateTime.UtcNow.DayOfWeek
{DayOfYearUTC}: DateTime.UtcNow.DayOfYear - 2 digit
{TicksUTC}: DateTime.UtcNow.Ticks

Available Classes

GlobalObjects

<summary>The initial class you must set the values of in order for it to log information to the file system in a location other that default.</summary>

Logger

<summary>Primary class that is used to log information to the file system.</summary>

Partial Classes

<summary>The partial classes are used to extend the functionality of the primary class.</summary>

ConsoleOnly

<summary>This partial class is used when you would like to log the information using the LogLevel functions, but don't want all that data written to the log file.</summary>

Log

<summary>While this is a partial class. It is really going to be used as a primary class, because it extends the base functions of the Logger class to utilize the LogLevel function. This way you can tell the logger class that you want to make sure this piece of information is logged, but only when the user has defined the log level for it. This allows a user to add in Debug level logging without the need to comment it out when they push their code to production and only want Info level logging.</summary>

Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 is compatible.  net452 is compatible.  net46 is compatible.  net461 is compatible.  net462 is compatible.  net463 was computed.  net47 is compatible.  net471 is compatible.  net472 is compatible.  net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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
1.0.1 132 8/23/2023
1.0.0 105 8/23/2023

Release Notes.md