Fs.Core.SimpleLogger 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Fs.Core.SimpleLogger --version 1.1.0
                    
NuGet\Install-Package Fs.Core.SimpleLogger -Version 1.1.0
                    
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="Fs.Core.SimpleLogger" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fs.Core.SimpleLogger" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Fs.Core.SimpleLogger" />
                    
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 Fs.Core.SimpleLogger --version 1.1.0
                    
#r "nuget: Fs.Core.SimpleLogger, 1.1.0"
                    
#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 Fs.Core.SimpleLogger@1.1.0
                    
#: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=Fs.Core.SimpleLogger&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Fs.Core.SimpleLogger&version=1.1.0
                    
Install as a Cake Tool

Fs.Core.SimpleLogger

NuGet NuGet Downloads

Fs.Core.SimpleLogger 是一个轻量级、简单易用的 .NET 日志库,无第三方依赖,适用于需要"纯洁"环境的基础类库和应用程序。

✨ 特性

  • 🎯 零依赖: 无第三方 DLL 依赖,保持环境纯净
  • 📝 多种处理器: 支持控制台、文件、调试输出等多种日志处理方式
  • 🔧 易于使用: API 简单直观,快速上手
  • 🎨 灵活扩展: 支持自定义日志处理器和格式化器
  • 🐛 调试模式: 内置调试日志功能,方便开发调试
  • 📧 模块化: 支持邮件发送、数据库存储等扩展模块

📦 安装

通过 NuGet Package Manager

Install-Package Fs.Core.SimpleLogger

通过 .NET CLI

dotnet add package Fs.Core.SimpleLogger

通过 PackageReference

<PackageReference Include="Fs.Core.SimpleLogger" Version="1.0.0" />

🎯 支持的框架

  • .NET Standard 2.0 (支持 .NET Framework 4.6.1+, .NET Core 2.0+, .NET 5+)

📌 仓库定位

  1. 无依赖第三方 DLL: 建议在需要"纯洁"的场景中使用,如非高频的基础类库、程序加载器
  2. 未进行性能测试: 建议性能敏感领域使用商业库,如 NLog 或 Serilog 等

📖 参考

本项目基于 SimpleLogger 进行删减和优化。

🚀 快速开始

Usage

    public static void Main()
    {
        // Adding handler - to show log messages (ILoggerHandler)
        Logger.LoggerHandlerManager
            .AddHandler(new ConsoleLoggerHandler())
            .AddHandler(new FileLoggerHandler())
            .AddHandler(new DebugConsoleLoggerHandler());

        // Fast logging (monitor name of class and methods from which is the application logged)
        Logger.Log();

        // We define a log message
        Logger.Log("Hello world");

        // We can define the level (type) of message
        Logger.Log(Logger.Level.Fine, "Explicit define level");

        // Explicit definition of the class from which the logging
        Logger.Log<Program>("Explicit define log class");
        Logger.Log<Program>(Logger.Level.Fine, "Explicit define log class and level");

        // Settings of default type of message
        Logger.DefaultLevel = Logger.Level.Severe;

        try 
        { 
            // Simulation of exceptions
            throw new Exception();
        }
        catch (Exception exception)
        {
            // Logging exceptions
            // Automatical adjustment of specific log into the Error and adding of StackTrace
            Logger.Log(exception);
            Logger.Log<Program>(exception);
        }

        // Special feature - debug logging

        Logger.Debug.Log("Debug log");
        Logger.Debug.Log<Program>("Debug log");

        Logger.DebugOff();
        Logger.Debug.Log("Not-logged message");

        Logger.DebugOn();
        Logger.Debug.Log("I'am back!");

        Console.ReadKey();
    }
Output
12.10.2012 21:43: Info [line: 18 Program -> Main()]: There is no message
12.10.2012 21:43: Info [line: 21 Program -> Main()]: Hello world
12.10.2012 21:43: Fine [line: 24 Program -> Main()]: Explicit define level
12.10.2012 21:43: Info [line: 27 Program -> Main()]: Explicit define log class
12.10.2012 21:43: Fine [line: 28 Program -> Main()]: Explicit define log class and level
12.10.2012 21:43: Error [line: 35 Program -> Main()]: Exception of type 'System.Exception' was thrown.
12.10.2012 21:43: Error [line: 35 Program -> Main()]: Log exception -> Message: Exception of type 'System.Exception' was thrown.
StackTrace:    at SimpleLogger.Sample.Program.Main() in c:\GitHub\SimpleLogger\SimpleLogger.Sample\Program.cs:line 35

12.10.2012 21:43: Debug [line: 47 Program -> Main()]: Debug log
12.10.2012 21:43: Debug [line: 48 Program -> Main()]: Debug log
12.10.2012 21:43: Debug [line: 55 Program -> Main()]: I'am back!

Modules

Email module

    // Email module sample
    public static void EmaiLModuleSample()
    {
        // Configuring smtp server
        var smtpServerConfiguration = new SmtpServerConfiguration("userName", "password", "smtp.gmail.com", 587);

        // Creating a module
        var emailSenderLoggerModule = new EmailSenderLoggerModule(smtpServerConfiguration)
        {
            EnableSsl = true,
            Sender = "sender-email@gmail.com"
        };

        // Adding recipients
        emailSenderLoggerModule.Recipients.Add("recipients@gmail.com");

        // Add the module and it works
        Logger.Modules.Install(emailSenderLoggerModule);

        try
        {
            // Simulation of exceptions
            throw new NullReferenceException();
        }
        catch (Exception exception)
        {
            // Log exception
            // If you catch an exception error -> will be sent an email with a list of log message.
            Logger.Log(exception);
        }
    }

MS SQL database module

    // MS SQL database module sample
    public static void MsSqlDatabaseLoggerModuleSample()
    {
        var connectionString = "Your connection string";

        // Just add the module and it works! 
        Logger.Modules.Install(new MsSqlDatabaseLoggerModule(connectionString));
        Logger.Log("My first database log! ");
    }

📖 文档

更多详细文档和使用示例,请访问 GitHub 仓库

🔗 NuGet 包

访问 NuGet 获取最新版本:https://www.nuget.org/packages/Fs.Core.SimpleLogger/

🤝 贡献

欢迎贡献代码和提出问题!请访问 GitHub Issues

📄 许可证

本项目采用 MIT 许可证。

👥 作者

由 FsDiG 团队开发和维护。


更新时间: 2023-09-13 (星期三) by Zcb

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.
  • .NETStandard 2.0

    • 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.

Version Downloads Last Updated
1.1.6 98 4/24/2026
1.1.5 89 4/23/2026
1.1.4 110 4/17/2026
1.1.3 88 4/17/2026
1.1.2 92 4/17/2026
1.1.1 85 4/16/2026
1.1.0 91 4/16/2026
1.0.9 92 4/16/2026
1.0.8 86 4/16/2026
1.0.7 87 4/16/2026
1.0.6 86 4/16/2026
1.0.5 88 4/16/2026
1.0.4 173 3/9/2026
1.0.3 473 12/5/2025
1.0.2 229 12/5/2025
1.0.1 187 10/24/2025
1.0.0 224 10/21/2025
0.0.9 210 10/21/2025
0.0.8 217 10/21/2025