public void EnableLogging(LoggingInfo.LoggingSubsystem subsystem, LoggingInfo.LoggingType type) { try { this._renderer.SetLoggingStatus(subsystem, type, LoggingInfo.LogsStatus.Enable); AppUtil.LogEvent(RuntimeContext.CurrentContextName, subsystem.ToString() + " logging enabled successfully", EventLogEntryType.Information, EventCategories.Information, EventID.LoggingEnabled); } catch (Exception exc) { AppUtil.LogEvent(RuntimeContext.CurrentContextName, exc.ToString(), EventLogEntryType.Error, EventCategories.Error, EventID.GeneralError); throw; } }
public void DisableLogging(LoggingInfo.LoggingSubsystem subsystem, LoggingInfo.LoggingType type) { try { this._renderer.SetLoggingStatus(subsystem, type, LoggingInfo.LogsStatus.Disable); AppUtil.LogEvent("NCache", subsystem.ToString() + " logging disabled successfully", EventLogEntryType.Information, EventCategories.Information, EventID.LoggingDisabled); } catch (Exception exc) { AppUtil.LogEvent("NCache", exc.ToString(), EventLogEntryType.Error, EventCategories.Error, EventID.GeneralError); throw; } }
/// <summary> /// Get logging status for logging type /// </summary> /// <param name="type">Type of logging</param> /// <returns>Current status of logging</returns> public abstract LoggingInfo.LogsStatus GetLoggingStatus(LoggingInfo.LoggingSubsystem subsystem, LoggingInfo.LoggingType type);
/// <summary> /// Set and apply logging status for a logging type /// </summary> /// <param name="type">Type of logging</param> /// <param name="status">Logging status to set</param> public abstract void SetLoggingStatus(LoggingInfo.LoggingSubsystem subsystem, LoggingInfo.LoggingType type, LoggingInfo.LogsStatus status);
public void EnableLogging(LoggingInfo.LoggingSubsystem subsystem, LoggingInfo.LoggingType type) { ManagementCommand command = GetManagementCommand(ManagementUtil.MethodName.EnableLogging); command.Parameters.AddParameter(subsystem); command.Parameters.AddParameter(type); ExecuteCommandOnCacehServer(command); }
/// <summary> /// Set and apply logging status /// </summary> /// <param name="subsystem"></param> /// <param name="type"></param> /// <param name="status"></param> public override void SetLoggingStatus(LoggingInfo.LoggingSubsystem subsystem, LoggingInfo.LoggingType type, LoggingInfo.LogsStatus status) { if (subsystem == LoggingInfo.LoggingSubsystem.Client) { bool updateClient = false; switch (type) { case LoggingInfo.LoggingType.Error: case LoggingInfo.LoggingType.Detailed: updateClient = ConnectionManager.SetClientLoggingInfo(type, status); break; case (LoggingInfo.LoggingType.Error | LoggingInfo.LoggingType.Detailed): bool updateErrorLogs = ConnectionManager.SetClientLoggingInfo(LoggingInfo.LoggingType.Error, status); bool updateDetailedLogs = ConnectionManager.SetClientLoggingInfo(LoggingInfo.LoggingType.Detailed, status); updateClient = (updateErrorLogs || updateDetailedLogs); break; } if (updateClient) ConnectionManager.UpdateClients(); } else if (subsystem == LoggingInfo.LoggingSubsystem.Server) { switch (status) { case LoggingInfo.LogsStatus.Disable: ///If error logs are disabled, then disable both if (type == LoggingInfo.LoggingType.Error || type == (LoggingInfo.LoggingType.Error | LoggingInfo.LoggingType.Detailed)) { this.InitializeLogging(false, false); } else if (type == LoggingInfo.LoggingType.Detailed) { this.InitializeLogging(Logger.IsErrorLogsEnabled, false); } break; case LoggingInfo.LogsStatus.Enable: bool error = Logger.IsErrorLogsEnabled; bool detailed = Logger.IsDetailedLogsEnabled; if (type == LoggingInfo.LoggingType.Error) { error = true; detailed = false; } else if (type == LoggingInfo.LoggingType.Detailed | type == (LoggingInfo.LoggingType.Error | LoggingInfo.LoggingType.Detailed)) { error = true; detailed = true; } this.InitializeLogging(error, detailed); break; } } }
/// <summary> /// Get current logging status for specified type /// </summary> /// <param name="subsystem"></param> /// <param name="type"></param> /// <returns></returns> public override LoggingInfo.LogsStatus GetLoggingStatus(LoggingInfo.LoggingSubsystem subsystem, LoggingInfo.LoggingType type) { switch (subsystem) { case LoggingInfo.LoggingSubsystem.Server: lock (_serverLoggingInfo) { return _serverLoggingInfo.GetStatus(type); } case LoggingInfo.LoggingSubsystem.Client: return ConnectionManager.GetClientLoggingInfo(type); default: return LoggingInfo.LogsStatus.Disable; } }
/// <summary> /// Set client logging info /// </summary> /// <param name="type"></param> /// <param name="status"></param> public static bool SetClientLoggingInfo(LoggingInfo.LoggingType type, LoggingInfo.LogsStatus status) { lock (_clientLogginInfo) { if (_clientLogginInfo.GetStatus(type) != status) { _clientLogginInfo.SetStatus(type, status); return true; } return false; } }
/// <summary> /// Get client logging information /// </summary> public static LoggingInfo.LogsStatus GetClientLoggingInfo(LoggingInfo.LoggingType type) { lock (_clientLogginInfo) { return _clientLogginInfo.GetStatus(type); } }