Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/SpringHgui/serilog-sinks-skywalking
Write Serilog log events to skywalking apm
https://github.com/SpringHgui/serilog-sinks-skywalking
aspnetcore serilog sink skywalking
Last synced: 2 days ago
JSON representation
Write Serilog log events to skywalking apm
- Host: GitHub
- URL: https://github.com/SpringHgui/serilog-sinks-skywalking
- Owner: SpringHgui
- Created: 2022-06-16T09:17:57.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-02-09T06:05:37.000Z (almost 2 years ago)
- Last Synced: 2024-04-27T06:22:40.069Z (7 months ago)
- Topics: aspnetcore, serilog, sink, skywalking
- Language: C#
- Homepage:
- Size: 25.4 KB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# serilog-sinks-skywalking
[![Nuget](https://img.shields.io/nuget/v/Serilog.Sinks.Skywalking)](https://www.nuget.org/packages/Serilog.Sinks.Skywalking/)Write Serilog events to skywalking apm
# 使用
1. 集成[SkyAPM.Agent.AspNetCore](https://github.com/SkyAPM/SkyAPM-dotnet)
2. 集成[Serilog.AspNetCore](https://github.com/serilog/serilog-aspnetcore)
3. 安装nuget包 `Serilog.Sinks.Skywalking`
```c#
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSerilog((context, services, configuration) =>
{
configuration
.MinimumLevel.Debug()
.Enrich.FromLogContext()
.WriteTo.Skywalking(services) //添加这一行
.WriteTo.Console();
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup();
});
```或者在 `MiniApi`项目中
```c#
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog((context, services, configuration) =>
{
configuration
.MinimumLevel.Debug()
.Enrich.FromLogContext()
.WriteTo.Skywalking(services) //添加这一行
.WriteTo.Console();
});
```# 高级
自定义Formater```c#
configuration
.WriteTo.Skywalking(services, new JsonFormatter())
```
更多Formatter实现查看Serilog文档,或自行实现`ITextFormatter`