Skip to content

coderstrong/MakeSimple.Logging

Repository files navigation

MakeSimple.Logging

Make Simple .NET logging config and tracing in microservices architecture

Build status NuGet Version NuGet Downloads

Get start

Install from Nuget

$ dotnet add package MakeSimple.Logging

Config Program.cs

public static void Main(string[] args)
{
    Activity.DefaultIdFormat = ActivityIdFormat.W3C;
    ....
}

Config Startup.cs

public void ConfigureServices(IServiceCollection services)
{
  ...
  services.AddMakeSimpleLoging(new LoggingOption()
  {
    IsOffLogSystem = bool.Parse(Environment.GetEnvironmentVariable("ISOFF_LOG_SYSTEM")),
    MinimumLevel = (LoggerLevel)int.Parse(Environment.GetEnvironmentVariable("LOG_LEVEL"))   
  });
  ...
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
  ...
  app.AddMakeSimpleLoging();
  ...
}

Add log custom property

LogContext.PushProperty("CustomerInfo", "Example");

Log properties

Property Type Description
Timestamp Datetime ISO8601
Level String
Exception String
Message String
SpanId String Id Trace context
TraceId String Id Trace context
ParentId String Id Trace context
Method String
QueryString String
Payload String
RequestedOn Datetime
Response String
ResponseCode String
RespondedOn Datetime
... ...

Log level

Level Value Description
Information 0
Verbose 1
Debug 2
Error 3
Fatal 4
Warning 5

About

Make Simple .NET logging config and tracing in microservices architecture

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages