private void AssertLogData(MockTraceLogger logger, TraceSeverity severity) { Assert.AreEqual("Message", logger.Message); Assert.AreEqual("Category1", logger.Category); Assert.AreEqual(99, logger.EventID); Assert.AreEqual(severity, logger.Severity); }
internal static void Logger(string categoryName, TraceSeverity severity, string format, params object[] args) { var logger = Instance; var category = logger.Areas[ProductDiagnosticName].Categories[categoryName]; logger.WriteTrace(0, category, severity, format, args); }
public static void WriteTrace(uint tag, TraceSeverity level, Guid correlationGuid, string exeName, string productName, string categoryName, string message) { const ushort sizeOfWCHAR = 2; NativeMethods.ULSTrace ulsTrace = new NativeMethods.ULSTrace(); // Pretty standard code needed to make things work ulsTrace.Header.Size = (ushort)Marshal.SizeOf(typeof(NativeMethods.ULSTrace)); ulsTrace.Header.Flags = NativeMethods.WNODE_FLAG_TRACED_GUID; ulsTrace.ULSHeader.dwVersion = NativeMethods.TRACE_VERSION_CURRENT; ulsTrace.ULSHeader.dwFlags = NativeMethods.TraceFlags.TRACE_FLAG_ID_AS_ASCII; ulsTrace.ULSHeader.Size = (ushort)Marshal.SizeOf(typeof(NativeMethods.ULSTraceHeader)); // Variables communicated to SPTrace ulsTrace.ULSHeader.Id = tag; ulsTrace.Header.Class.Level = (byte)level; ulsTrace.ULSHeader.wzExeName = exeName; ulsTrace.ULSHeader.wzProduct = productName; ulsTrace.ULSHeader.wzCategory = categoryName; ulsTrace.ULSHeader.wzMessage = message; ulsTrace.ULSHeader.correlationID = correlationGuid; // Pptionally, to improve performance by reducing the amount of data copied around, // the Size parameters can be reduced by the amount of unused buffer in the Message if (message.Length < 800) { ushort unusedBuffer = (ushort)((800 - (message.Length + 1)) * sizeOfWCHAR); ulsTrace.Header.Size -= unusedBuffer; ulsTrace.ULSHeader.Size -= unusedBuffer; } if (hTraceLog != 0) NativeMethods.TraceEvent(hTraceLog, ref ulsTrace); }
private string GetServerityCompatibleString(TraceSeverity serverity) { string servertiyString = ""; switch (serverity) { case TraceSeverity.InformationEvent: case TraceSeverity.Medium: case TraceSeverity.Monitorable: case TraceSeverity.Verbose: servertiyString = "information"; break; case TraceSeverity.WarningEvent: servertiyString = "warning"; break; case TraceSeverity.CriticalEvent: servertiyString = "critical"; break; case TraceSeverity.Exception: case TraceSeverity.Unexpected: servertiyString = "error"; break; default: servertiyString = "unspecified"; break; } return(servertiyString); }
[TestMethod]//2 public void LogToOperationsTest_WithExceptionMsg2() { /*public void LogToOperations(Exception exception, string additionalMessage, int eventId)*/ string strExceptionMsg = "Custom Exception Message by Automation code. Message No " + DateTime.Now.Ticks.ToString(); Exception ex = new Exception(strExceptionMsg); string strMessage = "Custom Message by Automation Test Code. " + Guid.NewGuid().ToString("N"); EventLogEntryType Severity = EventLogEntryType.Error; TraceSeverity TSeverity = LogUtils.MapEventLogEntryTypesToTraceLogSeverity(Severity); SharePointLogger spLogger = new SharePointLogger();//BaseLogger is abstract so we can use the SharePointLogger spLogger.LogToOperations(ex, strMessage, EID_Default); bool isValidEL = LogUtils.ValidateEventLog(strEventSourceName, EID_Default, strMessage, strExceptionMsg, Severity); //validation for event log entry bool isValidSPL = LogUtils.ValidateSPLogs(strExceptionMsg, null, TSeverity, EID_Default); ////Validation for Splog Entries spLogger = null; ex = null; Assert.IsTrue(isValidSPL, "No entry is made in Share point Logs"); Assert.IsTrue(isValidEL, "No entry is made in Event Logs"); }
public LogMessage(string message, int eventId, TraceSeverity severity, string category) { this.Message = message; this.EventId = eventId; this.TraceSeverity = severity; this.Category = category; }
public static void Log(TraceSeverity traceSeverity, string message, Exception ex) { SPDiagnosticsCategory category = ULSLog2013.Current.Areas[PRODUCT_NAME].Categories["Error"]; ULSLog2013.Current.WriteTrace(0, category, TraceSeverity.High, ex.Message); ULSLog2013.Current.WriteTrace(0, category, TraceSeverity.High, ex.ToString()); }
/// <summary> /// Log a trace message. /// </summary> /// <param name="message">The message to log</param> /// <param name="severity">The tracing severity level</param> /// <param name="extraProperties">Additional properties to include</param> internal virtual void Trace(string message, TraceSeverity severity = TraceSeverity.Verbose, IDictionary <string, string> extraProperties = null) { foreach (var logProvider in _logProviders) { logProvider.Trace(message, severity, MergeProperties(extraProperties)); } }
public static void LogError(string categoryName, string source, string message, System.Diagnostics.EventLogEntryType type) { SPDiagnosticsCategory category = LoggingService.Current.Areas[AREA_NAME].Categories[categoryName]; string format = "Source: {0} - Type: {2} - Message: {1}"; TraceSeverity severity = TraceSeverity.Verbose; switch (type) { case System.Diagnostics.EventLogEntryType.Error: severity = TraceSeverity.Unexpected; break; case System.Diagnostics.EventLogEntryType.FailureAudit: severity = TraceSeverity.Unexpected; break; case System.Diagnostics.EventLogEntryType.Information: break; case System.Diagnostics.EventLogEntryType.SuccessAudit: severity = TraceSeverity.Verbose; break; case System.Diagnostics.EventLogEntryType.Warning: severity = TraceSeverity.Medium; break; default: break; } LoggingService.Current.WriteTrace(0, category, severity, format, source, message, type.ToString()); }
protected override void WriteToDeveloperTrace(string message, int eventId, TraceSeverity severity, string category) { this.Message = message; this.Category = category; this.EventID = eventId; this.TraceSeverity = severity; }
protected override IEnumerable <SPDiagnosticsArea> ProvideAreas() { TraceSeverity debugTraceSeverity = TraceSeverity.None; WBFarm farm = WBFarm.Local; if (farm.FarmInstance == WBFarm.FARM_INSTANCE__DEVELOPMENT_FARM) { debugTraceSeverity = TraceSeverity.High; } List <SPDiagnosticsArea> areas = new List <SPDiagnosticsArea> { new SPDiagnosticsArea(LOGGING_AREA_NAME, new List <SPDiagnosticsCategory> { new SPDiagnosticsCategory(CATEGORY__TEAMS, TraceSeverity.Monitorable, EventSeverity.Information), new SPDiagnosticsCategory(CATEGORY__RECORDS_TYPES, TraceSeverity.Monitorable, EventSeverity.Information), new SPDiagnosticsCategory(CATEGORY__TIMER_TASKS, TraceSeverity.Monitorable, EventSeverity.Information), new SPDiagnosticsCategory(CATEGORY__WORK_BOXES, TraceSeverity.Monitorable, EventSeverity.Information), new SPDiagnosticsCategory(CATEGORY__WORK_BOX_COLLECTIONS, TraceSeverity.Monitorable, EventSeverity.Information), new SPDiagnosticsCategory(CATEGORY__MIGRATION, TraceSeverity.Monitorable, EventSeverity.Information), new SPDiagnosticsCategory(CATEGORY__QUERIES, TraceSeverity.Monitorable, EventSeverity.Information), new SPDiagnosticsCategory(CATEGORY__CONFIG, TraceSeverity.Monitorable, EventSeverity.Information), new SPDiagnosticsCategory(CATEGORY__DEBUG, debugTraceSeverity, EventSeverity.Information), new SPDiagnosticsCategory(CATEGORY__GENERIC, TraceSeverity.Monitorable, EventSeverity.Information) }) }; return(areas); }
public void WriteTrace(TraceSeverity level, string message) { if (ConfigurationProvider.Settings.EnableTrace) { WriteLogEntry(GetServerityCompatibleString(level), message); } }
public void Call_TrackTrace_WithDataInTraceAndTelemetry_WithOverride(TraceSeverity severity) { const string telemetryDataKey = "A"; const string telemetryDataValue = "C"; var telemetryData = new TelemetryData { [telemetryDataKey] = telemetryDataValue }; var telemetry = new Telemetry(_client, telemetryData); const string message = "TraceMessage"; const string telemetryDataTraceKey = "A"; const string telemetryDataTraceValue = "B"; telemetryData = new TelemetryData { [telemetryDataTraceKey] = telemetryDataTraceValue }; telemetry.TrackTrace(message, severity, telemetryData); _client.Received().TrackTrace(message, severity, Arg.Is <Dictionary <string, string> >(data => data != null && data.Count == 1 && data[telemetryDataTraceKey] == telemetryDataTraceValue)); }
public static void Log(TraceSeverity traceSeverity, Exception ex) { SPDiagnosticsCategory category = ProviderLogging.Current.Areas[PRODUCT_NAME].Categories["Error"]; ProviderLogging.Current.WriteTrace(0, category, TraceSeverity.High, ex.Message); ProviderLogging.Current.WriteTrace(0, category, TraceSeverity.High, ex.ToString()); }
public static void LogException(String category, Exception exception) { const TraceSeverity tSeverity = TraceSeverity.Unexpected; const EventSeverity eSeverity = EventSeverity.Error; SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(category, tSeverity, eSeverity), tSeverity, "Error Data: {0}", new object[] { exception.ToString() }); }
public static void LogInfo(String category, String data) { const TraceSeverity tSeverity = TraceSeverity.Verbose; const EventSeverity eSeverity = EventSeverity.Verbose; SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(category, tSeverity, eSeverity), tSeverity, "Data: {0}", new object[] { data }); }
protected DiagnosticsService(string productName, string logCategory, TraceSeverity defaultTraceLevel, EventSeverity defaultEventLevel) : base(string.Format(NameFormat, productName, logCategory), SPFarm.Local) { ProductName = productName; LogCategory = logCategory; DefaultTraceLevel = defaultTraceLevel; DefaultEventLevel = defaultEventLevel; }
/// <summary> /// Writes information about an exception into the log. /// </summary> /// <param name="exception">The exception to write into the log.</param> /// <param name="additionalMessage">Additional information about the exception message.</param> /// <param name="eventId">The eventId that corresponds to the event.</param> /// <param name="severity">The severity of the exception.</param> /// <param name="category">The category to write the message to.</param> public void TraceToDeveloper(Exception exception, string additionalMessage, int eventId, TraceSeverity severity, string category) { Validation.ArgumentNotNull(exception, "exception"); Validation.ArgumentNotNull(additionalMessage, "additionalMessage"); TraceToDeveloper(BuildExceptionMessage(exception, additionalMessage), eventId, severity, category); }
public void LogMessage(ushort id, LogCategories LogCategory, TraceSeverity traceSeverity, string message, params object[] data) { if (traceSeverity != TraceSeverity.None) { SPDiagnosticsCategory category = Local.Areas[Zimbra_Area].Categories[LogCategory.ToString()]; Local.WriteTrace(id, category, traceSeverity, message, data); } }
public virtual void LogTrace(string message, int eventId, TraceSeverity severity, string categoryName) { Validation.ArgumentNotNullOrEmpty(message, "message"); SPDiagnosticsCategory category = GetCategory(categoryName); base.WriteTrace((uint)eventId, category, severity, message, null); }
protected DiagnosticsService(string productName, string logCategory, TraceSeverity defaultTraceLevel, EventSeverity defaultEventLevel) : base(string.Format(NameFormat, productName, logCategory), SPFarm.Local) { ProductName = productName; LogCategory = logCategory; DefaultTraceLevel = defaultTraceLevel; DefaultEventLevel = defaultEventLevel; }
internal static void WriteTrace(uint tag, TraceSeverity level, Guid correlationGuid, string exeName, string productName, string categoryName, string message) { const ushort sizeOfWCHAR = 2; var ulsTrace = new NativeMethods.ULSTrace(); // Pretty standard code needed to make things work ulsTrace.Header.Size = (ushort)Marshal.SizeOf(typeof(NativeMethods.ULSTrace)); ulsTrace.Header.Flags = NativeMethods.WNODE_FLAG_TRACED_GUID; ulsTrace.ULSHeader.dwVersion = NativeMethods.TRACE_VERSION_CURRENT; ulsTrace.ULSHeader.dwFlags = TraceFlags.IdAsASCII; ulsTrace.ULSHeader.Size = (ushort)Marshal.SizeOf(typeof(NativeMethods.ULSTraceHeader)); // Variables communicated to SPTrace ulsTrace.ULSHeader.Id = tag; ulsTrace.Header.Class.Level = (byte)level; ulsTrace.ULSHeader.wzExeName = exeName; ulsTrace.ULSHeader.wzProduct = productName; ulsTrace.ULSHeader.wzCategory = categoryName; ulsTrace.ULSHeader.wzMessage = message; ulsTrace.ULSHeader.correlationID = correlationGuid; // Pptionally, to improve performance by reducing the amount of data copied around, // the Size parameters can be reduced by the amount of unused buffer in the Message if (message.Length < 800) { var unusedBuffer = (ushort)((800 - (message.Length + 1)) * sizeOfWCHAR); ulsTrace.Header.Size -= unusedBuffer; ulsTrace.ULSHeader.Size -= unusedBuffer; } if (_hTraceLog != 0) { NativeMethods.TraceEvent(_hTraceLog, ref ulsTrace); } }
public Task ReportTraceAsync(string message, TraceSeverity severity, IDictionary <string, string> otherMetaData = null) { if (IsEnabled) { _client.TrackTrace(message, severity.ToAppInsightsSeverity(), otherMetaData); } return(Task.FromResult(0)); }
public void Trace(string message, int eventId, TraceSeverity severity, string category) { this.Messages.Add(message); this.Message = message; this.Category = category; this.EventID = eventId; this.Severity = severity; }
internal static void LogEvent(string subject, string body, TraceSeverity traceSeverity, EventSeverity eventSeverity, uint uid = 0) { SPDiagnosticsService diagSvc = SPDiagnosticsService.Local; diagSvc.WriteTrace(uid, new SPDiagnosticsCategory("STAFix category", traceSeverity, eventSeverity), traceSeverity, subject.ToString() + ": {0}", new object[] { body.ToString() }); }
public void WriteTrace(ushort id, FBADiagnosticsCategory fbaDiagnosticsCategory, TraceSeverity traceSeverity, string message, params object[] data) { if (traceSeverity != TraceSeverity.None) { // traceSeverity==TraceSeverity.None would cause an ArgumentException: // "Specified value is not supported for the severity parameter." SPDiagnosticsCategory category = Local.Areas[AreaName].Categories[fbaDiagnosticsCategory.ToString()]; Local.WriteTrace(id, category, traceSeverity, message, data); } }
public static void Log(TraceSeverity traceSeverity, string message, Exception ex) { SPSecurity.RunWithElevatedPrivileges( () => { var category = Current.Areas[ProductName].Categories["Error"]; Current.WriteTrace(0, category, TraceSeverity.High, ex.Message); Current.WriteTrace(0, category, TraceSeverity.High, ex.ToString()); }); }
public void TrackTrace(string message, TraceSeverity severity, Dictionary <string, string> telemetryData) { if (string.IsNullOrWhiteSpace(message)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(message)); } _telemetryClient.TrackTrace(message, ConvertToSeverityLevel(severity), telemetryData); }
protected override void WriteToDeveloperTrace(string message, int eventId, TraceSeverity severity, string category) { var messageToAdd = new LoggedMessage(); messageToAdd.Message = message; messageToAdd.EventId = eventId; messageToAdd.TraceSeverity = severity; messageToAdd.Category = category; Messages.Add(messageToAdd); }
/// <summary> /// Write log to ULS /// </summary> /// <param name="category">Name of Category</param> /// <param name="traceseverity">Trace severity</param> /// <param name="message">Message to log</param> public static void Log(SPDiagnosticsCategory category, TraceSeverity traceseverity, string message) { try { Current.WriteTrace(0, category, traceseverity, message); } catch { // ignored } }
public void Call_TrackTrace(TraceSeverity severity) { var telemetry = new Telemetry(_client); var message = "TraceMessage"; telemetry.TrackTrace(message, severity, null); _client.Received().TrackTrace(message, severity, Arg.Is <Dictionary <string, string> >(data => data == null || data.Count == 0)); }
public static void Log(string message, TraceSeverity traceSeverity, EventSeverity eventSeverity, TraceCategory category) { try { WriteTrace(category, traceSeverity, message); //LdapcpLoggingService.WriteEvent(LdapcpLoggingService.TraceCategory.LDAPCP, eventSeverity, message); } catch { // Don't want to do anything if logging goes wrong, just ignore and continue } }
public void LogMessage(ushort id, BaristaDiagnosticCategory category, TraceSeverity traceSeverity, string message, params object[] data) { if (traceSeverity == TraceSeverity.None) { return; } var cat = this[category]; Local.WriteTrace(id, cat, traceSeverity, message, data); }
protected override void WriteToDeveloperTrace(string message, int eventId, TraceSeverity severity, string category) { try { TraceLogger.Trace(message, eventId, severity, category); } catch (Exception ex) { AttemptToWriteTraceExceptionToEventLog(ex); } }
public static void LogToULS(string message, TraceSeverity traceSeverity, EventSeverity eventSeverity) { try { SPDiagnosticsCategory category = new SPDiagnosticsCategory("Zimbra Settings", traceSeverity, eventSeverity); SPDiagnosticsService ds = SPDiagnosticsService.Local; ds.WriteTrace(0, category, traceSeverity, message); } catch { } }
private string MapTraceSeverity(TraceSeverity traceSeverity) { switch (traceSeverity) { case TraceSeverity.High: return "Error"; case TraceSeverity.Medium: return "Warning"; case TraceSeverity.Verbose: default: return "Debugging"; } }
public static void WriteTrace(string categoryName, string message, TraceSeverity severity) { try { var category = Logger.Local.Areas[ADFSCertificateUpdaterLoggerAreaName].Categories[categoryName]; Logger.Local.WriteTrace(1, category, severity, message); } catch (Exception exc) { WriteTraceStandalone(TraceSeverity.Unexpected, "There was a problem writing to the trace log with our own logger: " + exc.Message); WriteTraceStandalone(severity, "Original message: " + message); } }
public static void WriteTrace(TraceSeverity traceSeverity, string message) { if (string.IsNullOrEmpty(message)) return; var service = Local; if (service == null) return; try { var category = service.Areas[AreaName].Categories[Categories.Default]; service.WriteTrace(1, category, traceSeverity, message); } catch { } }
public static void WriteTrace(string categoryName, TraceSeverity traceSeverity, string message) { // NOTE: If the given value in the severity parameter is less than the currently configured value for // the category's TraceSeverity property, the trace is not written to the log. if (string.IsNullOrEmpty(message)) return; try { LoggingService service = Local; if (service != null) { SPDiagnosticsCategory category = service.Areas[AreaName].Categories[categoryName]; service.WriteTrace(1, category, traceSeverity, message); } } catch { } }
/// <summary> /// Override this method to change the way the trace message is created. /// </summary> /// <param name="message">The message to write into the log.</param> /// <param name="eventId"> /// The eventId that corresponds to the event. This value, coupled with the EventSource is often used by /// administrators and IT PRo's to monitor the EventLog of a system. /// </param> /// <param name="severity">How serious the event is. </param> /// <param name="category">The category of the log message.</param> /// <returns>The message.</returns> protected virtual string BuildTraceMessage(string message, int eventId, TraceSeverity severity, string category) { return message; }
/// <summary> /// Safe method to trace to the sandbox. /// </summary> /// <param name="message">The message to trace</param> /// <param name="eventId">the event id to trace</param> /// <param name="severity">the sandbox severity to use</param> /// <param name="category">The category to trace under</param> private void WriteTraceMessage(string message, int eventId, TraceSeverity severity, string category) { string traceMsg = BuildTraceMessage(message, eventId, severity, category); WriteToDeveloperTrace(traceMsg, eventId, severity, category); }
/// <summary> /// Writes information about an exception into the log. /// </summary> /// <param name="exception">The exception to write into the log.</param> /// <param name="additionalMessage">Additional information about the exception message.</param> /// <param name="eventId">The eventId that corresponds to the event.</param> /// <param name="severity">The severity of the exception.</param> /// <param name="category">The category to write the message to.</param> public void TraceToDeveloper(Exception exception, string additionalMessage, int eventId, TraceSeverity severity, string category) { Validation.ArgumentNotNull(exception, "exception"); Validation.ArgumentNotNull(additionalMessage, "additionalMessage"); TraceToDeveloper(BuildExceptionMessage(exception, additionalMessage), eventId, severity, category); }
/// <summary> /// Writes a diagnostic message into the trace log, with specified <see cref="TraceSeverity"/>. /// </summary> /// <param name="message">The message to write into the log.</param> /// <param name="eventId">The eventId that corresponds to the event.</param> /// <param name="severity">The severity of the exception.</param> /// <param name="category">The category to write the message to.</param> public void TraceToDeveloper(string message, int eventId, TraceSeverity severity, string category) { Validation.ArgumentNotNull(message, "message"); WriteTraceMessage(message, eventId, severity, category); }
public virtual void LogTrace(string message, int eventId, TraceSeverity severity, string categoryName) { Validation.ArgumentNotNullOrEmpty(message, "message"); SPDiagnosticsCategory category = GetCategory(categoryName); base.WriteTrace((uint)eventId, category, severity, message, null); }
public static void LogError(string errorMessage, TraceSeverity traceSeverity) { SPDiagnosticsCategory category = Current.Areas[AreaName].Categories["SPMin"]; Current.WriteTrace(0, category, traceSeverity, errorMessage); }
/// <summary> /// Logs to the ULS. /// </summary> /// <param name="categoryId"></param> /// <param name="traceSeverity">The trace severity.</param> /// <param name="message">The message.</param> /// <param name="args">The message arguments.</param> protected virtual void InnerLog(CategoryId categoryId, TraceSeverity traceSeverity, string message, params object[] args) { //SPSecurity.RunWithElevatedPrivileges( // () => // { if (_innerLogger == null) { _innerLogger = new InnerLogger(Name); } SPDiagnosticsCategory category = _innerLogger.Areas[_innerLogger.Name].Categories[categoryId.ToString()]; _innerLogger.WriteTrace(0, category, traceSeverity, message, args); //}); }
/// <summary> /// Actually controls the writing. Calls to WriteEvent ALSO writes to the ULS log. That's why the public logging methods /// all use TraceSeverity.None. /// </summary> private void WriteLog(SPDiagnosticsCategory category, TraceSeverity trcSeverity, EventSeverity evtSeverity, string message) { //uint catId = (uint)category; //SPDiagnosticsCategory diagCat = MyLogger.Local.Areas[DiagnosticsAreaName].Categories[catId]; StackTrace stackTrace = new StackTrace(); StackFrame stackFrame = stackTrace.GetFrame(2); MethodBase methodBase = stackFrame.GetMethod(); message = string.Format("{0}.{1} : {2}", methodBase.DeclaringType.Name, methodBase.Name, message); if (evtSeverity != EventSeverity.None) { //Problem - event source might not be registered on Server, and the app pool might not be able to create it. //Therefore, catch the exception, and write it into the logs. Nothing gets written to the Windows log, //but at least it's somewhat handled. try { base.WriteEvent(0, category, evtSeverity, message); } catch (Exception ex) { base.WriteTrace(0, category, TraceSeverity.Unexpected, string.Format("Unable to write to event log {0} : {1}", ex.GetType().ToString(), ex.Message)); // If there was an error writing to the event log, make sure the tracelog is written to instead. switch (evtSeverity) { case EventSeverity.Error: trcSeverity = TraceSeverity.Unexpected; break; case EventSeverity.Warning: trcSeverity = TraceSeverity.Monitorable; break; case EventSeverity.Information: trcSeverity = TraceSeverity.High; break; } } } if (trcSeverity != TraceSeverity.None) { base.WriteTrace(0, category, trcSeverity, message); } }
public static void WriteTraceStandalone(TraceSeverity severity, string message) { var cat = new SPDiagnosticsCategory("Standalone logging", TraceSeverity.Verbose, EventSeverity.None); var cats = new List<SPDiagnosticsCategory>(); cats.Add(cat); var area = new SPDiagnosticsArea("FedRolesCP", cats); SPDiagnosticsService.Local.WriteTrace(2, cat, severity, message); }
private void WriteImpl(TraceSeverity level, Payload payload) { EventDescriptor descriptor = new EventDescriptor(0, 0, 0, (byte)level, 0, 0, 0); using (EVENT_DATA_DESCRIPTOR data = new EVENT_DATA_DESCRIPTOR(payload)) using (DataDescriptorWrapper wrapper = new DataDescriptorWrapper(data)) { bool fResult = WriteEvent(ref descriptor, 1, wrapper.Ptr); if (!fResult) Console.WriteLine("Failed to call WriteEvent for real payload {0}", Marshal.GetLastWin32Error()); } }
private void Write(TraceFlags flags, uint id, TraceSeverity level, string exeName, string area, string category, string message) { Payload payload = new Payload(); payload.Size = (ushort)Marshal.SizeOf(typeof(Payload)); payload.dwVersion = TRACE_VERSION_CURRENT; payload.Id = id; payload.TimeStamp = DateTime.Now.ToFileTime(); payload.wzExeName = exeName; payload.wzProduct = area; payload.wzCategory = category; // If the message is smaller than 800 characters, no need to break it up. if (message == null || message.Length <= 800) { payload.wzMessage = message; payload.dwFlags = flags; WriteImpl(level, payload); return; } // For larger messages, break it into 800 character chunks. for (int i = 0; i < message.Length; i += 800) { int cchRemaining = Math.Min(800, message.Length - i); payload.wzMessage = message.Substring(i, cchRemaining); if (i == 0) payload.dwFlags = TraceFlags.TRACE_FLAG_START | flags; else if (i + 800 < message.Length) payload.dwFlags = TraceFlags.TRACE_FLAG_MIDDLE | flags; else payload.dwFlags = TraceFlags.TRACE_FLAG_END | flags; WriteImpl(level, payload); } }
public void Write(uint id, TraceSeverity level, string exeName, string area, string category, string message) { Write(TraceFlags.None, id, level, exeName, area, category, message); }
/// <summary> /// Override this method to implement how to write to a trace message. /// </summary> /// <param name="message">The message to write into the log.</param> /// <param name="eventId"> /// The eventId that corresponds to the event. This value, coupled with the EventSource is often used by /// administrators and IT PRo's to monitor the EventLog of a system. /// </param> /// <param name="severity">How serious the event is. </param> /// <param name="category">The category of the log message.</param> protected abstract void WriteToDeveloperTrace(string message, int eventId, TraceSeverity severity, string category);
/// <summary> /// Write a diagnostic message into the trace log, with default severity for the category. /// </summary> /// <param name="message">The message to write into the log.</param> /// <param name="severity">The severity of the exception.</param> public void TraceToDeveloper(string message, TraceSeverity severity) { Validation.ArgumentNotNull(message, "message"); WriteTraceMessage(message, DefaultEventId, severity, null); }
public static void WriteTrace(string categoryName, TraceSeverity traceSeverity, string format, params object[] arg) { WriteTrace(categoryName, traceSeverity, string.Format(format, arg)); }
private SPDiagnosticsCategory newSPDiagnosticsCategory(string p, TraceSeverity traceSeverity, EventSeverity eventSeverity) { throw new NotImplementedException(); }
/// <summary> /// Logs to the ULS. /// </summary> /// <param name="traceSeverity">The trace severity.</param> /// <param name="message">The message.</param> /// <param name="args">The message arguments.</param> protected virtual void InnerLog(TraceSeverity traceSeverity, string message, params object[] args) { try { SPDiagnosticsService.Local.WriteTrace( 0, new SPDiagnosticsCategory(this.CategoryName, TraceSeverity.Medium, EventSeverity.Information), traceSeverity, this.Name + " - " + message, args); } catch (TypeInitializationException) { // Failed to initialize local diagnostics service. Swallow exception and simply fail to log. } catch (PlatformNotSupportedException) { // We're running this code outside of a proper x64 process meant for SharePoint (for some reason) } }
public DefaultTraceSeverityAttribute(TraceSeverity severity) { this.Severity = severity; }
public static void WriteTrace(string categoryName, string message, TraceSeverity severity) { var category = ULSLogger.Local.Areas[ULSLoggerAreaName].Categories[categoryName]; ULSLogger.Local.WriteTrace(1, category, severity, message); //WriteTraceStandalone(severity, message); }
public static void WriteTrace(Categories Category, TraceSeverity Severity, string message) { Local.WriteTrace(1337, Local.GetCategory(Category), Severity, message); }
public void Trace(string message, int eventId, TraceSeverity severity, string category) { DiagnosticsService diagnosticService = DiagnosticsService.Local; diagnosticService.LogTrace(message, eventId, severity, category); }