-
-
Save tuannguyenssu/18557b1c08048c14638cd6d6857fb78e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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