Skip to content

Instantly share code, notes, and snippets.

@tuannguyenssu
Created July 30, 2019 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuannguyenssu/18557b1c08048c14638cd6d6857fb78e to your computer and use it in GitHub Desktop.
Save tuannguyenssu/18557b1c08048c14638cd6d6857fb78e to your computer and use it in GitHub Desktop.
using Serilog;
using System;
namespace SerilogTest
{
class Program
{
static void Main()
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Console()
.WriteTo.File("logs\\myapp.txt", rollingInterval: RollingInterval.Day)
.CreateLogger();
Log.Information("Hello, world!");
int a = 10, b = 0;
try
{
Log.Debug("Dividing {A} by {B}", a, b);
Console.WriteLine(a / b);
}
catch (Exception ex)
{
Log.Error(ex, "Something went wrong");
}
Log.CloseAndFlush();
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment