Log78 2.2.5

dotnet add package Log78 --version 2.2.5
                    
NuGet\Install-Package Log78 -Version 2.2.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="Log78" Version="2.2.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Log78" Version="2.2.5" />
                    
Directory.Packages.props
<PackageReference Include="Log78" />
                    
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 Log78 --version 2.2.5
                    
#r "nuget: Log78, 2.2.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 Log78@2.2.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=Log78&version=2.2.5
                    
Install as a Cake Addin
#tool nuget:?package=Log78&version=2.2.5
                    
Install as a Cake Tool

<h1 align="center">Log78</h1> <div align="center">

English | 简体中文

License Test Status QQ Group </div>

Feedback QQ Group (Click to join): 323397913

1. Log78 Class Documentation

Overview

Log78 is a powerful and easy-to-use logging class that supports various types of log output including console, file, and server-side output. It uses the singleton pattern to ensure there's only one global instance, making it incredibly convenient to use throughout your application without explicit setup.

Installation

Install via NuGet Package Manager:

dotnet add package Log78

Quick Start

Log78 offers two ways to log messages: a simple method for quick logging and a more detailed method using LogEntry objects. Here's how to get started with the simple method:

using www778878net.log;

// Get the Log78 instance - no setup required!
var log = Log78.Instance;

// Log a simple message
log.INFO("Hello, Log78!");

// Log with a summary and custom level
log.WARN("This is a warning", "Warning Summary", 60);

For more detailed logging, you can use the LogEntry object:

var logEntry = new LogEntry();
logEntry.Basic.Message = "Detailed log message";
logEntry.Basic.Summary = "Log Summary";
log.INFO(logEntry);

Both methods are ready to use out of the box with default console and file logging.

Advanced Configuration (Optional)

If you need custom logging behavior, you can use the setup method:

// Create custom logger instances if needed
var serverLogger = new ServerLog78();
var fileLogger = new FileLog78("custom_logfile");
var consoleLogger = new ConsoleLog78();

// Setup custom loggers
log.setup(serverLogger, fileLogger, consoleLogger);

Properties

  • debugKind: A HashSet of log debugging keywords used to control which types of logs are recorded.
  • LevelFile, LevelConsole, LevelApi: Respectively represent the threshold levels for file logs, console logs, and API logs.
  • DebugEntry: Used to set more fine-grained debugging conditions.

Suggested Log Levels

  • DEBUG (10): Detailed debug information, typically used only in development environments
  • INFO (50): General information, can be used to track normal application operations
  • WARN (50): Warning information, indicating potential issues but not affecting main functionality
  • ERROR (70): Errors and serious problems that require immediate attention

Example: Adjusting Log Levels

using www778878net.log;
var log = Log78.Instance;

// Adjust console log level to 0 to print all logs (for debugging)
log.LevelConsole = 0;
// Adjust file log level to 60 to only record more severe warnings and errors
log.LevelFile = 60;

// Using different levels to record logs
var logEntry = new LogEntry();
logEntry.Basic.Message = "Debug information";
log.DEBUG(logEntry); // Will only output to console

logEntry.Basic.Message = "General information";
log.INFO(logEntry); // Will output to console, not recorded in file

logEntry.Basic.Message = "Warning";
log.WARN(logEntry); // Will be recorded in both console and file

logEntry.Basic.Message = "Error";
log.ERROR(logEntry); // Will be recorded in console, file, and API

Methods

  • DEBUG, INFO, WARN, ERROR: Record logs of different levels.
  • ERROR(Exception, LogEntry): Records exception error logs.

Using the LogEntry Class

The LogEntry class provides structured information for detailed logging:

var logEntry = new LogEntry();
logEntry.Basic.Summary = "User login successful";
logEntry.Basic.LogLevelNumber = 50;
logEntry.Basic.LogLevel = "INFO";
logEntry.Basic.Message = "User johndoe successfully logged into the system";
logEntry.Basic.ServiceName = "AuthService";
logEntry.Basic.UserId = "user123";
logEntry.Basic.UserName = "johndoe";

logEntry.Event.EventCategory = "authentication";
logEntry.Event.EventAction = "login";
logEntry.Event.EventOutcome = "success";

logEntry.Http.HttpRequestMethod = "POST";
logEntry.Http.HttpRequestBodyContent = "{\"username\":\"johndoe\",\"password\":\"*****\"}";
logEntry.Http.HttpResponseStatusCode = 200;
logEntry.Http.UrlOriginal = "https://api.example.com/login";

// Add custom properties
logEntry.AddProperty("customField", "customValue");

log.INFO(logEntry);

Other

For more detailed information, please refer to the project's GitHub repository or the API documentation.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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.  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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Log78:

Package Downloads
HttpClient78

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.5 125 9/12/2024
2.1.2 118 9/6/2024
2.0.37 118 9/6/2024
2.0.36 121 9/5/2024
2.0.35 117 9/5/2024
2.0.34 112 9/5/2024
2.0.33 117 9/5/2024
2.0.32 115 9/5/2024
2.0.29 122 9/5/2024
2.0.5 121 9/4/2024
2.0.4 117 9/4/2024
2.0.2 120 9/4/2024
1.0.10 106 8/31/2024
1.0.9 106 8/30/2024
1.0.8 107 8/30/2024
1.0.7 105 8/30/2024
1.0.6 107 8/30/2024
1.0.5 117 8/28/2024
1.0.4 109 8/27/2024
1.0.3 107 8/27/2024
1.0.2 105 8/27/2024
0.0.8323.12 450 10/15/2022
0.0.8321.54 959 10/13/2022
0.0.8321.8 430 10/13/2022
0.0.8321.6 433 10/13/2022
0.0.8321.5 424 10/13/2022