Skip to content

Commit

Permalink
Add namespace and class name to demo project
Browse files Browse the repository at this point in the history
  • Loading branch information
Jandini committed Nov 5, 2024
1 parent 96a0174 commit 1c85161
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/Serilog.Enrichers.ClassName.Demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@
using Serilog.Enrichers.ClassName;
using SerilogDemo;

namespace Demo;

Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.Enrich.WithClassName()
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] [{ClassName}] [{SourceContext}] {Message:lj}{NewLine}{Exception}")
.CreateLogger();
class MyProgram
{
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.Enrich.WithClassName()
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] [{ClassName}] [{SourceContext}] {Message:lj}{NewLine}{Exception}")
.CreateLogger();

Log.Information("Application starting...");
Log.Information("Application starting...");

// Log from another class
var demoClass = new DemoClass();
demoClass.DoWork();
// Log from another class
var demoClass = new DemoClass();
demoClass.DoWork();

Log.Information("Application ending...");
Log.CloseAndFlush();

Log.Information("Application ending...");
Log.CloseAndFlush();
}
}

0 comments on commit 1c85161

Please sign in to comment.