使用serilog
This commit is contained in:
parent
14aa806058
commit
1b9e125010
@ -20,6 +20,12 @@
|
|||||||
<ProjectReference Include="..\FastGithub.ReverseProxy\FastGithub.ReverseProxy.csproj" />
|
<ProjectReference Include="..\FastGithub.ReverseProxy\FastGithub.ReverseProxy.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
|
||||||
|
<PackageReference Include="Serilog.Settings.Configuration" Version="3.2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="../README.md" Link="README.md">
|
<None Include="../README.md" Link="README.md">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
@ -55,6 +56,13 @@ namespace FastGithub
|
|||||||
kestrel.ListenHttpReverseProxy();
|
kestrel.ListenHttpReverseProxy();
|
||||||
kestrel.ListenGithubSshProxy();
|
kestrel.ListenGithubSshProxy();
|
||||||
});
|
});
|
||||||
|
webBuilder.UseSerilog((hosting, logger) =>
|
||||||
|
{
|
||||||
|
logger
|
||||||
|
.ReadFrom.Configuration(hosting.Configuration)
|
||||||
|
.Enrich.FromLogContext()
|
||||||
|
.WriteTo.Console(outputTemplate: "{Timestamp:O} [{Level:u3}]{NewLine}{SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,13 +31,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Serilog": {
|
||||||
"LogLevel": {
|
"MinimumLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Yarp": "Warning",
|
"Override": {
|
||||||
"System": "Warning",
|
"Yarp": "Warning",
|
||||||
"Microsoft": "Warning",
|
"System": "Warning",
|
||||||
"Microsoft.AspNetCore.Server.Kestrel": "Error"
|
"Microsoft": "Warning",
|
||||||
|
"Microsoft.AspNetCore.Server.Kestrel": "Error"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user