public string Download(string addr) { try { logger?.Verbose("download " + addr); lock (wc) { var result = wc.DownloadString(addr); logger?.Verbose("download complete: " + addr); return(result); } } catch (WebException we) { logger?.Error(we, "Error downloading from " + addr); var rs = we.Response?.GetResponseStream(); if (rs != null) { var err = new StreamReader(rs).ReadToEnd(); logger?.Error(we, "Error downloading from " + addr + ". Response: " + err); } throw; } catch (Exception e) { logger?.Error(e, "Error downloading from " + addr); throw; } }
public void Run(string name, Action <WebClientBase> a) { Thread t = new Thread(new ThreadStart(() => { int number = taskCount++; logger.Verbose($"Start thread {name} [{number}]"); lock (locker) { try { logger.Verbose($"Execution begin {name} [{number}]"); using (wc = new WebClientBase(logger)) a(wc); logger.Verbose($"Execution end {name} [{number}]"); } catch (Exception e) { logger.Error(e, $"Exection failed: {name} [{number}]"); OnError?.Invoke($"{name} [{number}]", new ErrorEventArgs(e)); } } })); t.Start(); }
private static void InitLog() { log = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.Async(a => a.RollingFile("log/log-{Date}.txt", restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Verbose)) .WriteTo.Console(restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Debug) .CreateLogger(); log.Verbose($"▉▉▉ {Translator.get.log_init} ({DateTime.Now.ToString()}) ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉"); log.Information(Translator.get.app_starting); }
public void Verbose <T>(Exception exception, string messageTemplate, T propertyValue) { log.Verbose(exception, messageTemplate, propertyValue); }
//Ab hier starten die logger methoden public void Verbose(string message) { log.Verbose(message); }
public static void Verbose(string message) { _logger.Verbose(message); }
public void Verbose(string message, params object[] propertyValues) { Log.Verbose(message, propertyValues); }
public void Verbose() { internalLogger.Verbose(string.Empty); }
public void Verbose(string messageTemplate) { _log.Verbose(messageTemplate); }
static void Main(string[] args) { int nsecs = 1000; try { var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); config = configuration; //var configuration = builder.Build(); // config = new ConfigurationBuilder() // .AddJsonFile("appsettings.json", true, true) // .Build(); //Serilog.Debugging.SelfLog.Enable(msg => Debug.WriteLine(msg)); //Serilog.Debugging.SelfLog.Enable(Console.Error); // File logger /* * var Log = new LoggerConfiguration() * //.MinimumLevel.Information() * //.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) * .Enrich.FromLogContext() * //.WriteTo.Console() * //.WriteTo.RollingFile("log-{Date}.txt") //, fileSizeLimitBytes: 123) * .ReadFrom.Configuration(configuration) * //.ReadFrom.Configuration(config) * //.Enrich.FromLogContext() * .CreateLogger(); */ /* * var Log = new LoggerConfiguration() * .WriteTo.SumoLogic("https://endpoint4.collection.us2.sumologic.com/receiver/v1/http/ZaVnC4dhaV1OJMaHi0tURR0qnAZ2G4CmmLdC4MdjYUbmtlFDnp5jAd9h4z0AbkVsIYNHswsCLX87SsDb9hZsW_aY6umdGIQOjPoNMeoUflRQlGL4q6LYVQ==") * //.WriteTo.SumoLogic("http://localhost", textFormatter: new MessageTemplateTextFormatter("FOOBAR", null)) * .WriteTo.MongoDBCapped() * .CreateLogger(); */ // From appsettings.json Log = new LoggerConfiguration() .ReadFrom.Configuration(configuration) .CreateLogger(); /** * var Log = new LoggerConfiguration() * //.WriteTo.MongoDB("mongodb://mymongodb/logs") * .WriteTo.MongoDB("mongodb://localhost:27017/logs") * //.WriteTo.MongoDBCapped("mongodb://localhost:27017/logs", cappedMaxSizeMb: 50, cappedMaxDocuments: 7) * .MinimumLevel.Verbose() * //.MinimumLevel.Fatal() * .CreateLogger(); **/ //Console.WriteLine("The current time is " + DateTime.Now); showVitals(); listStudents(); ListCollectionAsync().Wait(); //Console.ReadLine(); Log.Verbose("VVVVVVVV Verbose"); Console.WriteLine($"'waiting {nsecs} milli secs."); Task.Delay(nsecs).Wait(); // Wait 2 seconds with blocking Log.Debug("DDDDDDDD Debug"); Console.WriteLine($"'waiting {nsecs} milli secs."); Task.Delay(nsecs).Wait(); // Wait 2 seconds with blocking Log.Information("IIIIIIII Information"); Console.WriteLine($"'waiting {nsecs} milli secs."); Task.Delay(nsecs).Wait(); // Wait 2 seconds with blocking Log.Warning("WWWWWWWW Warning"); Log.Fatal("FFFFFFFF Fatal terminated unexpectedly"); Log.Error("EEEEEEEE Error"); Log.Verbose("VVVVVVVV Error"); Log.Information("Host IIIIIIIIIIII"); nsecs = 6000; Console.WriteLine($"'waiting {nsecs} milli secs. The end is near."); Task.Delay(nsecs).Wait(); // Wait 2 seconds with blocking } catch (Exception ex) { Console.WriteLine($"\n\n catch catch\n{ex}"); if (Log != null) { Log.Fatal($"catch catch\n {ex}"); } //return; } finally { if (Log != null) { Log.Information("Fulsh"); } //Log.Information("Fulsh"); //Log.CloseAndFlush(); } Console.WriteLine($"'waiting {nsecs} milli secs. The end is near."); Task.Delay(nsecs).Wait(); // Wait 2 seconds with blocking }
public void Verbose(string mensagem) { _logger.Verbose(mensagem); }