public static void Log(string message, LogType type) { if (Server.HasArg(ArgKey.NoLog)) { return; } if (message == null) { throw new ArgumentNullException("message"); } string line = DateTime.Now.ToLongTimeString() + " > " + GetPrefix(type) + message; // localized lock ( LogLock ) { RaiseLoggedEvent(message, line, type); RecentMessages.Enqueue(line); while (RecentMessages.Count > MaxRecentMessages) { RecentMessages.Dequeue(); } if (LogFileOptions[(int)type]) { string actualLogFileName; switch (SplittingType) { case LogSplittingType.SplitBySession: actualLogFileName = Path.Combine(Paths.LogPath, SessionStart + ".log"); break; case LogSplittingType.SplitByDay: actualLogFileName = Path.Combine(Paths.LogPath, DateTime.Now.ToString(ShortDateFormat) + ".log"); // localized break; default: actualLogFileName = Path.Combine(Paths.LogPath, DefaultLogFileName); break; } try { File.AppendAllText(actualLogFileName, line + Environment.NewLine); } catch (Exception ex) { string errorMessage = "Logger.Log: " + ex.Message; RaiseLoggedEvent(errorMessage, DateTime.Now.ToLongTimeString() + " > " + GetPrefix(LogType.Error) + errorMessage, // localized LogType.Error); } } } }