public static DateTimeLoggerAppender CreateLogger(bool useDifferentFileNamesForLogs) { var consoleLogger = new ConsoleLogger(LogLevel.Verbose); var logFileName = useDifferentFileNamesForLogs ? DateTime.Now.ToString("yyyy-MM-dd--HH-mm-ss") + ".txt" : "Log.txt"; var fileLoggerPath = Path.Combine(FolderHelperMethods.AssemblyDirectory, "Logs", logFileName); var fileLogger = new FileLogger(fileLoggerPath, LogLevel.Verbose); var multiLogger = new MultiLoggerAppender(new List <ILogger>() { consoleLogger, fileLogger }); var loggingLevelAppender = new LoggingLevelLoggerAppender(multiLogger, " <:>"); var dateTimeAppender = new DateTimeLoggerAppender(loggingLevelAppender, ":"); return(dateTimeAppender); }
public async Task StartTelegramBot() { var config = BotConfigLoader.LoadFromEnvironmentVariables(Configuration); if (!config.IsValid) { config = BotConfigLoader.LoadFromStaticFile(); } if (!config.IsValid) { DirtyMemoryLogger.LoggingLines.Add($"{DateTime.Now}: Bot configuration not valid"); } var extraLogger = new DateTimeLoggerAppender(new DirtyMemoryLogger(LogLevel.Verbose), ": "); var telegramBot = new DeveHangmanTelegramBot(config, extraLogger); await telegramBot.Start(); }