protected TestBase() { var configBuilder = new ConfigurationBuilder(); var config = configBuilder .AddUserSecrets <LoggingTests>() .Build(); var twilioConfig = new TwilioConfiguration { AccountSID = config.GetValue <string>("twilio:AccountSID"), AccountToken = config.GetValue <string>("twilio:AccountToken"), FromNumber = config.GetValue <string>("twilio:FromNumber"), Recipients = new List <string> { "+1 650 868 3367" } }; var loggerConfig = new J4JLoggerConfiguration(FilePathTrimmer) .AddTwilio(twilioConfig); loggerConfig.SerilogConfiguration .WriteTo.Debug(outputTemplate: loggerConfig.GetOutputTemplate(true)) .WriteTo.LastEvent(out var temp); loggerConfig.NetEvent(); LastEvent = temp !; Logger = loggerConfig.CreateLogger(); Logger.SetLoggedType(GetType()); Logger.LogEvent += LogEvent; }
protected TestBaseNoDI() { var loggerConfig = new J4JLoggerConfiguration(FilePathTrimmer); loggerConfig.SerilogConfiguration .WriteTo.Debug(outputTemplate: loggerConfig.GetOutputTemplate(true)); Logger = loggerConfig.CreateLogger(); Logger.SetLoggedType(GetType()); }
static void Main(string[] args) { var loggerConfig = new J4JLoggerConfiguration(FilePathTrimmer); var outputTemplate = loggerConfig.GetOutputTemplate(true); loggerConfig.SerilogConfiguration .WriteTo.Debug(outputTemplate: outputTemplate) .WriteTo.Console(outputTemplate: outputTemplate) .WriteTo.File(path: Path.Combine(Environment.CurrentDirectory, "log.txt"), outputTemplate: outputTemplate, rollingInterval: RollingInterval.Day); var logger = loggerConfig.CreateLogger(); logger.SetLoggedType(typeof(Program)); logger.Information("This is an Informational logging message"); logger.Fatal("This is a Fatal logging message"); }
static void config_logger(IConfiguration buildConfig, J4JLoggerConfiguration loggerConfig) { loggerConfig.SerilogConfiguration .WriteTo .Debug(outputTemplate: loggerConfig.GetOutputTemplate(true)); }