Log.to.Text.File
4.0.0
dotnet add package Log.to.Text.File --version 4.0.0
NuGet\Install-Package Log.to.Text.File -Version 4.0.0
<PackageReference Include="Log.to.Text.File" Version="4.0.0" />
<PackageVersion Include="Log.to.Text.File" Version="4.0.0" />
<PackageReference Include="Log.to.Text.File" />
paket add Log.to.Text.File --version 4.0.0
#r "nuget: Log.to.Text.File, 4.0.0"
#:package Log.to.Text.File@4.0.0
#addin nuget:?package=Log.to.Text.File&version=4.0.0
#tool nuget:?package=Log.to.Text.File&version=4.0.0
About
Helper class which writes to txt file. Useful when running scheduled scripts and you want to have something to double check what was done and when.
Runs with netcoreapp3.1, net5.0 and net6.0 only Windows.
Usage
Initiate logger like this (uses System.AppDomain.CurrentDomain.BaseDirectory to determine the destination directory):
var log = new SessionLog();
or define your own destination like this:
var log = new SessionLog(@"C:\Users\USER\Desktop");
You can log text like this:
log.Write("Hello World!");
You can screenshot like this:
log.Screenshot();
Or retrieve the path of the log file like this:
string publicProperty = log.FilePath;
Example
using System;
using Log.to.Text.File;
namespace Example
{
class Program
{
static void Main(string[] args)
{
var log = new SessionLog(@"C:\Users\USER\Desktop");
try
{
log.Write("I declared an array");
int[] myArray = new int[1];
log.Write("I set 99 to second index");
myArray[1] = 99;
}
catch (System.Exception e)
{
log.Screenshot();
log.Write(e);
}
}
}
}
Session_Log_07122022_125838.txt
12/7/2022 12:58:38 PM >> I declared an array
12/7/2022 12:58:38 PM >> I set 99 to second index
12/7/2022 12:58:38 PM >> Screenshot_12072022_125838.png
12/7/2022 12:58:38 PM >> EXCEPTION MESSAGE: Index was outside the bounds of the array.
12/7/2022 12:58:38 PM >> STACK TRACE: at Log_to_TXT.Program.Main(String[] args) in C:\Users\USER\source\repos\Log_to_TXT\Log_to_TXT\Program.cs:line 15
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net5.0-windows7.0 is compatible. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net6.0-windows7.0 is compatible. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- System.Drawing.Common (>= 6.0.0)
-
net5.0-windows7.0
- System.Drawing.Common (>= 6.0.0)
-
net6.0-windows7.0
- System.Drawing.Common (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added 'Screenshot' method, Repaced for only Windows usage