/// <summary> /// Injects a file logger into the framework construction /// </summary> /// <param name="construction">The construction</param> /// <param name="logPath">The path of the file to log to</param> /// <param name="logLevel">Log level start for logging</param> /// <param name="trimSize">Says what file size triggers the trimming to half of the logs in a file. Unit = Byte</param> /// <returns></returns> public static FrameworkConstruction AddFileLogger(this FrameworkConstruction construction, string logPath = "log.txt", LogLevel logLevel = LogLevel.Information, int trimSize = 0) { // Make use of AddLogging extension construction.Services.AddLogging(options => { // Add file logger options.AddFile(logPath, new FileLoggerConfiguration { LogLevel = logLevel, LogTime = true, TrimByteSize = trimSize, }); }); // Chain the construction return(construction); }
/// <summary> /// Injects the default logger into the framework construction /// </summary> /// <param name="construction">The construction</param> /// <returns></returns> public static FrameworkConstruction AddDefaultLogger(this FrameworkConstruction construction) { // Add logging as default construction.Services.AddLogging(options => { // Setup loggers from configuration options.AddConfiguration(construction.Configuration.GetSection("Logging")); // Add console logger //options.AddConsole(); // Add debug logger options.AddDebug(); }); // Adds a default logger so that we can get a non-generic ILogger // that will have the category name of "Ixs.DNA" construction.Services.AddTransient(provider => provider.GetService <ILoggerFactory>().CreateLogger("Ixs.DNA (Framework)")); // Chain the construction return(construction); }