static void LogAuditMessage(DicomAuditHelper helper, string userId, string sessionId = null) { // 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) { string serializeText = null; try { serializeText = helper.Serialize(false); _log.WriteEntry(helper.Operation, serializeText, userId, sessionId); } 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()); } } }
/// <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) { AuditLogHelper.Log(message); }