Skip to content

練習透過組態切換 Logger 機制於 .NET 上。(To practice how switch logger by config on .NET.)

License

Notifications You must be signed in to change notification settings

cdcd72/Net.SwitchLoggerByConfig.Demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Net.SwitchLoggerByConfig.Demo

練習透過組態切換 Logger 機制於 .NET 上。
To practice how switch logger by config on .NET.

運行專案

透過 Visual Studio 2022 或者利用 dotnet run 指令先把專案跑起來。

  1. Run the project from Visual Studio 2022 or by typing dotnet run in a command window.

回到命令列視窗,你將會看到以下訊息(目前使用 Serilog):

  1. Back to command window, your will see the message (currently use serilog):
    Image Image

http://localhost:5232 並觸發寫記錄。

  1. Go to http://localhost:5232 and trigger write log. Image Image

嘗試修改 logsettings.Development.json 來使用 NLog。

  1. Try to modify logsettings.Development.json below setting to use NLog.

    {
      "CoreLoggerOptions": {
        "LoggerType": "NLog",
        "NLogOptions": {
          "ConfigFilePath": "config/nlog.config"
        }
      },
      "Logging": {
        "LogLevel": {
          "Default": "Information",
          "Microsoft.AspNetCore": "Warning"
        }
      }
    }

    Image

嘗試修改 logsettings.Development.json 來使用 log4net。

  1. Try to modify logsettings.Development.json below setting to use log4net.
    {
      "CoreLoggerOptions": {
        "LoggerType": "Log4Net",
        "Log4NetOptions": {
          "ConfigFilePath": "config/log4net.config"
        }
      },
      "Logging": {
        "LogLevel": {
          "Default": "Information",
          "Microsoft.AspNetCore": "Warning"
        }
      }
    }
    Image

自己試試吧。

  1. Try it yourself.

About

練習透過組態切換 Logger 機制於 .NET 上。(To practice how switch logger by config on .NET.)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages