/// <summary> /// Logs an event to the audit log using the format as described in DICOM Supplement 95. /// </summary> /// <param name="message">The audit message to log.</param> public static void Log(DicomAuditHelper message) { if (AuditingEnabled) { AuditLog.WriteEntry(message.Operation, message.Serialize(false)); } }
/// <summary> /// Logs an event to the audit log using the format as described in DICOM Supplement 95. /// </summary> /// <remarks> /// Use this overload to explicitly specify the user and session ID. /// </remarks> /// <param name="message">The audit message to log.</param> /// <param name="username"></param> /// <param name="sessionId"></param> private static void Log(DicomAuditHelper message, string username, string sessionId) { if (AuditingEnabled) { AuditLog.WriteEntry(message.Operation, message.Serialize(false), username, sessionId); } }
/// <summary> /// Log an Audit message. /// </summary> /// <param name="helper"></param> public static void LogAuditMessage(DicomAuditHelper helper) { // Found doing this on the local thread had a performance impact with some DICOM operations, // make run as a task in the background to make it work faster. Task.Factory.StartNew(delegate { lock (_syncLock) { if (_log == null) _log = new AuditLog(ProductInformation.Component, "DICOM"); string serializeText = null; try { serializeText = helper.Serialize(false); _log.WriteEntry(helper.Operation, serializeText, GetUserName(), GetUserSessionId()); } catch (Exception ex) { Platform.Log(LogLevel.Error, ex, "Error occurred when writing audit log"); var sb = new StringBuilder(); sb.AppendLine("Audit Log failed to save:"); sb.AppendLine(String.Format("Operation: {0}", helper.Operation)); sb.AppendLine(String.Format("Details: {0}", serializeText)); Platform.Log(LogLevel.Info, sb.ToString()); } } }); }
/// <summary> /// Log an Audit message. /// </summary> /// <param name="helper"></param> public static void LogAuditMessage(DicomAuditHelper helper) { lock (_syncLock) { if (_log == null) _log = new AuditLog(ProductInformation.Component,"DICOM"); string serializeText = null; try { serializeText = helper.Serialize(false); _log.WriteEntry(helper.Operation, serializeText); } catch(Exception ex) { Platform.Log(LogLevel.Error, ex, "Error occurred when writing audit log"); StringBuilder sb = new StringBuilder(); sb.AppendLine("Audit Log failed to save:"); sb.AppendLine(String.Format("Operation: {0}", helper.Operation)); sb.AppendLine(String.Format("Details: {0}", serializeText)); Platform.Log(LogLevel.Info, sb.ToString()); } } }