public LogManager CreateLogger() { var logManager = new LogManager(); var serializer = new XmlSerializer<SettingsStorage>(); if (File.Exists(_logSettingsFile)) { logManager.Load(serializer.Deserialize(_logSettingsFile)); var listener = logManager .Listeners .OfType<FileLogListener>() .FirstOrDefault(fl => !fl.LogDirectory.IsEmpty()); if (listener != null) LogsDir = listener.LogDirectory; } else { logManager.Listeners.Add(new FileLogListener/*(LoggerErrorFileName)*/ { Append = true, LogDirectory = LogsDir, MaxLength = 1024 * 1024 * 100 /* 100mb */, MaxCount = 10, SeparateByDates = SeparateByDateModes.SubDirectories, }); //logManager.Listeners.Add(new FileLogListener(LoggerFileName) //{ // Append = true, // LogDirectory = LogsDir, // SeparateByDates = SeparateByDateModes.SubDirectories, //}); serializer.Serialize(logManager.Save(), _logSettingsFile); } //logManager.Listeners // .OfType<FileLogListener>() // .Where(fl => fl.FileName == Path.GetFileNameWithoutExtension(LoggerErrorFileName)) // .ForEach(fl => // { // fl.Filters.Add(LogListener.AllWarningFilter); // fl.Filters.Add(LogListener.AllErrorFilter); // }); return logManager; }