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.
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.
// Install FlashLog as a Cake Addin #addin nuget:?package=FlashLog&version=1.0.5 // Install FlashLog as a Cake Tool #tool nuget:?package=FlashLog&version=1.0.5
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
- Install nuget postsharp 6.10.5 (in first run only you should create your postsharp license)
- 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
- Change all the details according to yours
- 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
- 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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Microsoft.ApplicationInsights.NLogTarget (>= 2.21.0)
- Microsoft.Extensions.Logging.EventLog (>= 7.0.0)
- NLog (>= 5.2.5)
- NLog.WindowsEventLog (>= 5.2.5)
- PostSharp (>= 2023.0.8)
- System.Configuration.ConfigurationManager (>= 7.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.