Log78 2.0.2
See the version list below for details.
dotnet add package Log78 --version 2.0.2
NuGet\Install-Package Log78 -Version 2.0.2
<PackageReference Include="Log78" Version="2.0.2" />
<PackageVersion Include="Log78" Version="2.0.2" />
<PackageReference Include="Log78" />
paket add Log78 --version 2.0.2
#r "nuget: Log78, 2.0.2"
#:package Log78@2.0.2
#addin nuget:?package=Log78&version=2.0.2
#tool nuget:?package=Log78&version=2.0.2
<h1 align="center">Log78</h1> <div align="center">
English | 简体中文
Feedback QQ Group (Click to join): 323397913
1. Log78
Class Documentation
Overview
Log78
is a class for encapsulating logging functionality, supporting various types of log output including console output, file output, and server-side output. This class uses the singleton pattern to ensure there is only one instance globally and provides methods for setting different log levels.
Installation
Install via NuGet Package Manager:
dotnet add package Log78
Usage
using www778878net.log;
var log = Log78.Instance;
log.setup(serverLogger, fileLogger, consoleLogger);
var logEntry = new LogEntry();
logEntry.Basic.Message = "Hello, world!";
log.INFO(logEntry);
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;
log.setup(serverLogger, fileLogger, consoleLogger);
// 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
setup
: Sets up logger instances.DEBUG
,INFO
,WARN
,ERROR
: Record logs of different levels.ERROR(Exception, LogEntry)
: Records exception error logs.
Custom Log Entries
You can create custom log entries by inheriting from the LogEntry
class:
public class CustomLogEntry : LogEntry
{
public DateTime Date { get; set; }
public string Weather { get; set; }
public CustomLogEntry()
{
Date = DateTime.Now;
Weather = "Unknown";
Basic.HostName = Environment.MachineName;
Basic.UserName = Environment.UserName;
}
}
// Using a custom log entry
var customEntry = new CustomLogEntry
{
Basic = { Message = "Test message", Summary = "Test summary" },
Weather = "Sunny"
};
log.INFO(customEntry);
Example
using www778878net.log;
// Create logger instances
var serverLogger = new ServerLog78();
var fileLogger = new FileLog78("logfile");
var consoleLogger = new ConsoleLog78();
// Get the Log78 instance
var log = Log78.Instance;
// Setup the logger
log.setup(serverLogger, fileLogger, consoleLogger);
// Log an information message
var infoEntry = new LogEntry();
infoEntry.Basic.Message = "This is an info message.";
log.INFO(infoEntry);
// Log an error message
try
{
throw new Exception("Something went wrong!");
}
catch (Exception error)
{
var errorEntry = new LogEntry();
errorEntry.Basic.Message = "An error occurred.";
log.ERROR(error, errorEntry);
}
Other
For more detailed information, please refer to the project's GitHub repository or the API documentation.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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 Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- Newtonsoft.Json (>= 13.0.3)
- Serilog (>= 4.0.1)
- Serilog.Sinks.Console (>= 6.0.0)
- Serilog.Sinks.File (>= 6.0.0)
-
net6.0
- Newtonsoft.Json (>= 13.0.3)
- Serilog (>= 4.0.1)
- Serilog.Sinks.Console (>= 6.0.0)
- Serilog.Sinks.File (>= 6.0.0)
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 | 127 | 9/12/2024 |
2.1.2 | 119 | 9/6/2024 |
2.0.37 | 120 | 9/6/2024 |
2.0.36 | 122 | 9/5/2024 |
2.0.35 | 118 | 9/5/2024 |
2.0.34 | 113 | 9/5/2024 |
2.0.33 | 119 | 9/5/2024 |
2.0.32 | 117 | 9/5/2024 |
2.0.29 | 124 | 9/5/2024 |
2.0.5 | 123 | 9/4/2024 |
2.0.4 | 119 | 9/4/2024 |
2.0.2 | 121 | 9/4/2024 |
1.0.10 | 107 | 8/31/2024 |
1.0.9 | 107 | 8/30/2024 |
1.0.8 | 108 | 8/30/2024 |
1.0.7 | 106 | 8/30/2024 |
1.0.6 | 108 | 8/30/2024 |
1.0.5 | 119 | 8/28/2024 |
1.0.4 | 112 | 8/27/2024 |
1.0.3 | 109 | 8/27/2024 |
1.0.2 | 106 | 8/27/2024 |
0.0.8323.12 | 454 | 10/15/2022 |
0.0.8321.54 | 963 | 10/13/2022 |
0.0.8321.8 | 434 | 10/13/2022 |
0.0.8321.6 | 437 | 10/13/2022 |
0.0.8321.5 | 428 | 10/13/2022 |