VOOZH about

URL: https://www.nuget.org/packages/FlashLog/

⇱ NuGet Gallery | FlashLog 1.0.5




👁 Image
FlashLog 1.0.5

dotnet add package FlashLog --version 1.0.5
 
 
NuGet\Install-Package FlashLog -Version 1.0.5
 
 
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="FlashLog" Version="1.0.5" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FlashLog" Version="1.0.5" />
 
Directory.Packages.props
<PackageReference Include="FlashLog" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FlashLog --version 1.0.5
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FlashLog, 1.0.5"
 
 
#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.
#:package FlashLog@1.0.5
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FlashLog&version=1.0.5
 
Install as a Cake Addin
#tool nuget:?package=FlashLog&version=1.0.5
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Instructions

Follow these steps to add FlashLog© to your project

  1. Install nuget postsharp 6.10.5 (in first run only you should create your postsharp license)
  2. Create a file "nlog.config" in your project root, change it's "Copy to output directory" to "Copy if newer", and copy this content:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

 <extensions>
 <add assembly="Microsoft.ApplicationInsights.NLogTarget" />
 </extensions>

 <targets>
 <target
 xsi:type="Console"
 name="consoleTarget"
 layout="${longdate} | ${level:uppercase=false} | ${logger} | ${message}">
 </target>
 <target
 xsi:type="ApplicationInsightsTarget"
 name="aiTarget"
 instrumentationKey="[instrumentationKey]">
 <contextproperty name="threadid" layout="${threadid}" />
 </target>
 <target
 xsi:type="File"
 name="fileTarget"
 fileName="c:\logs\log.log"
 layout="${longdate} | ${level:uppercase=false} | ${logger} | ${message}" />
 <target
 name="Mail"
 xsi:type="Mail"
 html="true"
 subject="AspectLogger Trace"
 body="${longdate} | ${level:uppercase=false} | ${logger} | ${message}"
 to="[To_mail]"
 from="[From_mail]"
 Encoding="UTF-8"
 smtpUsername="[From_mail]"
 enableSsl="True"
 smtpPassword="[Password]"
 smtpAuthentication="Basic"
 smtpServer="[smtp_server]"
 smtpPort="[smtp_port]" />
 </targets>

 <rules>
 <logger name="*" minlevel="Trace" writeTo="consoleTarget,aiTarget,fileTarget" />
 <logger name="*" minlevel="Error" writeTo="consoleTarget,aiTarget,fileTarget,Mail" />
 </rules>
</nlog>

remember! this is your output settings: writeTo="consoleTarget,aiTarget,fileTarget"

consoleTarget = console window output aiTarget = application insights fileTarget = file in c:\logs\log.log

in case of exception a mail log too

  1. Change all the details according to yours
  2. create a file "app.config" in your executable, change it's "Copy to output directory" to "Copy if newer", and copy this content:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
 <appSettings>
 <add key="logExceptionsOnly" value="false"/>
 </appSettings>
</configuration>

keep in mind that:

 <add key="logExceptionsOnly" value="true"/> //will print exceptions only
 <add key="logExceptionsOnly" value="false"/> //will print EVERY function entry + exceptions
  1. We are all set! now all you need to do is add an attribute [AspectLogger] in your class

Example for class with AspectLogger


class Program
{
 static void Main(string[] args)
 {
 MyClass testClass = new ();

 testClass.Func1();
 testClass.Func2();
 }
}


// this is the logger attribute that will log every step and exception of your class
[AspectLogger]
public class MyClass
{
	public void Func1()
	{}

	public void Func2()
	{}
}


the output will be:

2022-01-02 09:02:49.4440 | Info | FlashLog.Logging.NLogLogger | Entering Method:".ctor" 
2022-01-03 09:02:49.4441 | Info | FlashLog.Logging.NLogLogger | Entering Method:"Func1" 
2022-01-03 09:02:49.4442 | Info | FlashLog.Logging.NLogLogger | Entering Method:"Func2" 

Manual Print

FlashLog can also print log manually, add this code wherever you need to log.

Logger.GetLogger().Log("Print1");

the output will be:

2022-01-03 09:02:49.4580 | Info | FlashLog.Logging.NLogLogger | Print1 
Product Versions Compatible and additional computed target framework versions.
.NET net7.0 net7.0 is compatible.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows 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.5 756 11/1/2023
1.0.4 1,318 1/3/2022
1.0.3 910 1/3/2022
1.0.2 956 1/3/2022
1.0.1 934 1/1/2022
1.0.0 998 1/1/2022