public ILogger CreateLogger(IConfiguration configuration) { var logFilePath = GetLogFilePath(configuration); if (IsCustomLogFilePath(logFilePath)) { FileSystemHelpers.EnsureFileDirectoryExists(logFilePath); } var logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.File(new JsonFormatter(), logFilePath, rollingInterval: RollingInterval.Day) .WriteTo.Console() .CreateLogger(); return(logger); }
public void CreateJsonReport( string reportDirectoryPath, IEnumerable <Entity> publishedEntitiesWithUnexpectedStage, string tenantName) { Log.Information("Creating JSON report for tenant {TenantName}...", tenantName); var reportFilePath = GetReportFilePath(reportDirectoryPath, tenantName); Log.Debug("Computed report file absolute path for tenant {TenantName} is {ReportFilePath}", tenantName, reportFilePath); FileSystemHelpers.EnsureFileDirectoryExists(reportFilePath); using (var streamWriter = File.CreateText(reportFilePath)) { var serializer = new JsonSerializer { Formatting = Formatting.Indented }; serializer.Serialize(streamWriter, publishedEntitiesWithUnexpectedStage); } Log.Debug("JSON report successfully created for tenant {TenantName}", tenantName); }