SimpleGelf.Extensions.Logging
1.0.0
dotnet add package SimpleGelf.Extensions.Logging --version 1.0.0
NuGet\Install-Package SimpleGelf.Extensions.Logging -Version 1.0.0
<PackageReference Include="SimpleGelf.Extensions.Logging" Version="1.0.0" />
paket add SimpleGelf.Extensions.Logging --version 1.0.0
#r "nuget: SimpleGelf.Extensions.Logging, 1.0.0"
// Install SimpleGelf.Extensions.Logging as a Cake Addin #addin nuget:?package=SimpleGelf.Extensions.Logging&version=1.0.0 // Install SimpleGelf.Extensions.Logging as a Cake Tool #tool nuget:?package=SimpleGelf.Extensions.Logging&version=1.0.0
That class example demostrate as to use provider.
The appsettings.json file may config:
"LogConfig": { "NameFile": "C:\Logs\ApiBIlling\apiLog", "LogEventLevel": 4, "FlushToDiskIntervalHour": 24, "Providers": [ "File", "Console", "Graylog" ] }, "GelfLoggerConfig": { "User": "", "Password": "", "UsingAuthenticate": false, "Host": "http://127.0.0.1", "Port": 12201, "LogSource": "billing_api", "HttpTimeoutSeconds": 30, "ListLogLevel": [ 4, 5 ] },
public class ApplicationLogging : ILoggingService { private static ILoggerFactory _Factory = null; const string providerConsole = "CONSOLE"; const string providerFile = "FILE"; const string providerGrayLog = "GRAYLOG";
public ApplicationLogging(ILoggerFactory factory, LogConfig logConfig, GelfLoggerConfig gelfLoggerConfig)
{
var hasLoggerConsole = logConfig.Providers.Any(x => x.ToUpper().Equals(providerConsole));
var hasLoggerFile = logConfig.Providers.Any(x => x.ToUpper().Equals(providerFile));
var hasLoggerGrayLog = logConfig.Providers.Any(x => x.ToUpper().Equals(providerGrayLog));
var configLogger = new LoggerConfiguration()
.MinimumLevel.Override("Microsoft", (LogEventLevel)logConfig.LogEventLevel)
.Enrich.FromLogContext();
if (hasLoggerConsole)
configLogger.WriteTo.Console();
if(hasLoggerFile)
configLogger.WriteTo.File($"{logConfig.NameFile}.txt",
rollingInterval: RollingInterval.Day,
flushToDiskInterval: new TimeSpan(logConfig.FlushToDiskIntervalHour, 0, 0),
restrictedToMinimumLevel: (LogEventLevel)logConfig.LogEventLevel,
rollOnFileSizeLimit: true);
Log.Logger = configLogger.CreateLogger();
if (hasLoggerGrayLog)
factory.AddSimpleGelf(gelfLoggerConfig);
_Factory = factory.AddSerilog(Log.Logger);
}
public ILoggerFactory LoggerFactory
{
get
{
return _Factory;
}
}
}
Product | Versions 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. |
.NET Core | netcoreapp2.1 is compatible. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
- Microsoft.Extensions.Logging (>= 2.1.1)
- Microsoft.Extensions.Options (>= 2.1.1)
- Newtonsoft.Json (>= 11.0.2)
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.0.0 | 1,298 | 7/20/2018 |
This is simple extension the .Net Core for using as provider loggin..