https://github.com/huanent/Logging
microsoft.extensions.logging日志组件拓展
https://github.com/huanent/Logging
asp-net-core dotnetcore logging netcore2
Last synced: about 1 year ago
JSON representation
microsoft.extensions.logging日志组件拓展
- Host: GitHub
- URL: https://github.com/huanent/Logging
- Owner: huanent
- Created: 2017-04-24T02:55:25.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-08-27T01:37:06.000Z (almost 2 years ago)
- Last Synced: 2025-04-08T00:43:34.178Z (about 1 year ago)
- Topics: asp-net-core, dotnetcore, logging, netcore2
- Language: C#
- Homepage:
- Size: 375 KB
- Stars: 33
- Watchers: 3
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Microsoft.Extensions.Logging extensions
## Install
[](https://www.nuget.org/packages/Huanent.Logging.Core/)
[](https://www.nuget.org/packages/Huanent.Logging.File/)
## Usage
### Huanent.Logging.Core
```
public class ConsoleLogWriter : ILogWriter
{
public void WriteLog(LogLevel level, string message, string name, Exception exception, EventId eventId)
{
Console.WriteLine($"From {nameof(ConsoleLogWriter)} {level} {message} {name} {exception} {eventId}");
}
}
//ILoggingBuilder
logging.AddImplementation();
```
### Huanent.Logging.File
```
//ILoggingBuilder
logging.AddFile();
```
Log will out in {application folder}/logs/20211020.txt
```
[Error] [LoggingFileSample.Worker] [0] [2021/10/20 01:05:35 +00:00]
Worker running at: 10/20/2021 21:05:35 +08:00
System.Exception: error
[Error] [LoggingFileSample.Worker] [0] [2021/10/20 01:05:36 +00:00]
Worker running at: 10/20/2021 21:05:36 +08:00
System.Exception: error
[Error] [LoggingFileSample.Worker] [0] [2021/10/20 01:05:37 +00:00]
Worker running at: 10/20/2021 21:05:37 +08:00
System.Exception: error
```