Luilliarcec.Logger
1.1.0
dotnet add package Luilliarcec.Logger --version 1.1.0
NuGet\Install-Package Luilliarcec.Logger -Version 1.1.0
<PackageReference Include="Luilliarcec.Logger" Version="1.1.0" />
paket add Luilliarcec.Logger --version 1.1.0
#r "nuget: Luilliarcec.Logger, 1.1.0"
// Install Luilliarcec.Logger as a Cake Addin #addin nuget:?package=Luilliarcec.Logger&version=1.1.0 // Install Luilliarcec.Logger as a Cake Tool #tool nuget:?package=Luilliarcec.Logger&version=1.1.0
Net Framework Logger
Helps keep a record of exceptions generated at runtime.
Installation
You can install the package via nuget:
dotnet add package Luilliarcec.Logger
Usage
You can use the Logger in each method that is necessary
using Luilliarcec.Logger;
// ...
namespace Test
{
public class Foo
{
public void Sumar()
{
try {
// ...
} catch (Exception ex) {
Log.Error(ex);
}
}
}
}
Or you can use the Application.ThreadException event to catch all the unhandled errors.
If you want to send an email with the error report, the package uses an asynchronous delivery method to send the error report to the email. So if you want to get a notification when the submission is complete use the SendCompleted event.
But for the sending of emails to be effective, you must configure your App.config with the following values, or pass these values to the send method of the Log class.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="MAIL_FROM_NAME" value="Sender name"/>
<add key="MAIL_USERNAME" value="Sender email"/>
<add key="MAIL_PASSWORD" value="Sender password"/>
<add key="MAIL_TO" value="Receiver email"/>
<add key="ClientSettingsProvider.ServiceUri" value=""/>
</appSettings>
</configuration>
using Luilliarcec.Logger;
// ...
namespace YourProject
{
static class Program
{
/// <summary>
/// Punto de entrada principal para la aplicación.
/// </summary>
[STAThread]
static void Main()
{
// ...
Log.SendCompleted += Log_SendCompleted;
Application.ThreadException += Application_ThreadException;
// ...
}
private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
Log.Error(e.Exception);
Log.Send();
// or
// Log.Send("Sender name", "Sender email", "Sender password", "Receiver email");
}
private static void Log_SendCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
// Notify here that the email has been sent
}
}
}
The exposed methods to keep an error log are:
Methods | Return | Description |
---|---|---|
Error | bool |
Save the file with error type |
Warning | bool |
Save the file with warning type |
Info | bool |
Save the file with information type |
Drop | bool |
Delete the file |
Copy | bool |
Copy the file to a destination path |
Exists | bool |
Verify that the file exists in the directory |
Send | void |
Send an email with the error report |
Path | property (get, set) |
Log path, default project root directory |
Follow these tips and have a happy code.
Security
If you discover any security related issues, please email luilliarcec@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Send bug report by mail.