/

Levels

ByteHide.Logger is a flexible and powerful logging library for .NET applications, providing advanced features such as file rotation, data masking, duplicate log suppression, user identification, and metadata enrichment to ensure robust logging and analysis capabilities.

Learn all the levels we have

Info

Used to log informational messages that highlight the progress of the application at a coarse-grained level. These messages are typically used for tracking the general flow of the application.

This method logs an informational message.

public void Info(string message)

Example usage:

Log.Info("Application started successfully.");

Warn

Used to log potentially harmful situations which are not necessarily errors but could lead to issues if not addressed. These messages indicate that something unexpected happened, but the application is still running.

This method logs a warning message.

public void Warn(string message, Exception exception = null)

Example usage:

Log.WithTags("performance", "database")
    .WithContext("Query", "SELECT * FROM users WHERE id = 1234")
    .Warn("Database query delay.");
Log.Warn("Disk space is running low.");

Error

Used to log error events that might still allow the application to continue running. These messages indicate that a problem occurred, but it is not fatal to the application.

This method logs an error message.

public void Error(string message, Exception exception = null, object context = null)

Example usage:

try {
    throw new Exception("Failed to connect to the database");
}
catch (Exception ex)
{
    Log.WithMetadata("TransactionID", "abc123")
        .Error("Error connecting to the database.", ex, new { retryCount = 3 });
}
Log.Error("Failed to connect to the database.");

Critical

Used to log very severe error events that will presumably lead the application to abort. These messages indicate a critical failure in the application.

This method logs a critical error message.

public void Critical(string message, Exception exception = null, object context = null)

Example usage:

try {
    throw new Exception("Unhandled exception occurred.");
}
catch (Exception ex)
{
    Log.WithMetadata("OperationID", "xyz789")
       .Critical("Critical failure in the application.", ex, new { userId = "user123" });
}
Log.Critical("Unhandled exception occurred. Shutting down the application.");
Previous
Quick Start