// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using Microsoft.Extensions.Logging; using Logging.Util; namespace Logging.MsExtLog { public class Test { private static ILogger log = LogContext.Instance.CreateLogger(); public static int Fac(int n) { int res; if (n <= 1) { res = 1; } else { res = n * Fac(n - 1); } if(log.IsEnabled(LogLevel.Debug)) { log.LogDebug("fac : n = " + n + " res = " + res); } return res; } public static void Main(string[] args) { log.LogInformation("Start"); Console.WriteLine(Fac(50)); log.LogInformation("End"); LogContext.Instance.FlushAll(); } } }