/// <summary> /// Writes information about an exception into the log to the sandbox. /// </summary> /// <param name="exception">The exception 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">The severity of the exception.</param> /// <param name="category">The category to write the message to.</param> public void LogToOperations(Exception exception, int eventId, SandboxEventSeverity severity, string category) { Validation.ArgumentNotNull(exception, "exception"); WriteLogMessage(BuildExceptionMessage(exception, null), eventId, severity, category); }
protected override void WriteToOperationsLog(string message, int eventId, SandboxEventSeverity severity, string category) { var messageToAdd = new LoggedMessage(); messageToAdd.Message = message; messageToAdd.EventId = eventId; messageToAdd.SandboxEventSeverity = severity; messageToAdd.Category = category; Messages.Add(messageToAdd); }
public TestLogger() { LogToOperationsStringInt32SandboxEventSeverityString = (message, eventId, eventSeverity, category) => { this.Message = message; this.EventId = eventId; this.Category = category; this.Severity = eventSeverity; }; LogToOperationsStringInt32String = (message, eventId, category) => { this.Message = message; this.EventId = eventId; this.Category = category; }; }
protected override void WriteToOperationsLog(string message, int eventId, SandboxEventSeverity severity, string category) { try { if (SharePointEnvironment.InSandbox) { WriteToOperationsLogSandbox(message, eventId, severity, category); } else { WriteToOperationsLogFullTrust(message, eventId, severity, category); } } catch (Exception ex) { // If the logging failed, throw an error that holds both the original error information and the // reason why logging failed. Dont do this if only the tracing failed. throw BuildLoggingException(message, ex); } }
public void LogToOperations(Exception exception, int eventId, SandboxEventSeverity severity, string category) { }
/// <summary> /// Translates a <see cref="SandboxEventSeverity"/> into an EventSeverity. /// SandboxEventSeverity uses same enum values. /// </summary> /// <param name="severity">The severity of the event</param> /// <returns>the equlivalent SharePoint EventSeverity value</returns> public EventSeverity GetEventSeverity(SandboxEventSeverity severity) { return((EventSeverity)((int)severity)); }
protected override void WriteToOperationsLog(string message, int eventId, SandboxEventSeverity severity, string category) { try { if (SharePointEnvironment.InSandbox) WriteToOperationsLogSandbox(message, eventId, severity, category); else WriteToOperationsLogFullTrust(message, eventId, severity, category); } catch (Exception ex) { // If the logging failed, throw an error that holds both the original error information and the // reason why logging failed. Dont do this if only the tracing failed. throw BuildLoggingException(message, ex); } }
/// <summary> /// Override this method to implement how to write to a log message for the sandbox /// </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 WriteToOperationsLog(string message, int eventId, SandboxEventSeverity severity, string category);
/// <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 WriteLogMessage(string message, int eventId, SandboxEventSeverity severity, string category) { string logMsg = BuildEventLogMessage(message, eventId, severity, category); WriteToOperationsLog(logMsg, eventId, severity, category); }
/// <summary> /// Writes the logged message to the operations log from the sandbox. /// </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> public void LogToOperations(string message, int eventId, SandboxEventSeverity severity, string category) { Validation.ArgumentNotNull(message, "message"); WriteLogMessage(message, eventId, severity, category); }
/// <summary> /// Writes an error message into the log from the sandbox. WIll /// work from outside the sandbox as well. /// </summary> /// <param name="message">The message to write</param> /// <param name="severity">How serious the event is.</param> public void LogToOperations(string message, SandboxEventSeverity severity) { Validation.ArgumentNotNull(message, "message"); WriteLogMessage(message, DefaultEventId, severity, null); }
/// <summary> /// Translates a <see cref="SandboxEventSeverity"/> into an EventSeverity. /// SandboxEventSeverity uses same enum values. /// </summary> /// <param name="severity">The severity of the event</param> /// <returns>the equlivalent SharePoint EventSeverity value</returns> public EventSeverity GetEventSeverity(SandboxEventSeverity severity) { return (EventSeverity)((int)severity); }
private void WriteToOperationsLogFullTrust(string message, int eventId, SandboxEventSeverity severity, string category) { EventLogLogger.Log(message, eventId, GetEventSeverity(severity), category); }
protected virtual void WriteToOperationsLogSandbox(string message, int eventId, SandboxEventSeverity? severity, string category) { if (SharePointLogger.canAccessSandboxLogging == -1) { if (SharePointEnvironment.ProxyInstalled(TracingOperationArgs.OperationAssemblyName, TracingOperationArgs.OperationTypeName)) { SharePointLogger.canAccessSandboxTracing = 1; } else { SharePointLogger.canAccessSandboxTracing = 0; } } if (SharePointLogger.canAccessSandboxTracing == 1) { var args = new LoggingOperationArgs(); args.Message = message; args.EventId = eventId; args.Category = category; args.Severity = (int?)severity; if (SPContext.Current != null) args.SiteID = SPContext.Current.Site.ID; else args.SiteID = null; var result = SPUtility.ExecuteRegisteredProxyOperation( LoggingOperationArgs.OperationAssemblyName, LoggingOperationArgs.OperationTypeName, args); if (result != null && result.GetType().IsSubclassOf(typeof(System.Exception))) { var ex = new LoggingException(Properties.Resources.SandboxLoggingFailed, (Exception)result); throw ex; } } }
public void LogToOperations(string message, int eventId, SandboxEventSeverity severity, string category) { }
public void LogToOperations(string message, SandboxEventSeverity severity) { }
/// <summary> /// Override this method to change the way the log message is created for the sandbox /// </summary> /// <param name="message">The message to write into the log.</param> /// <param name="eventId"> /// The event Id 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 BuildEventLogMessage(string message, int eventId, SandboxEventSeverity severity, string category) { return(message); }
/// <summary> /// Writes information about an exception into the log from the sandbox. /// </summary> /// <param name="exception">The exception to write into the log to be read by operations.</param> /// <param name="additionalMessage">Additional information about the exception message.</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">The severity of the exception.</param> /// <param name="category">The category to write the message to.</param> public void LogToOperations(Exception exception, string additionalMessage, int eventId, SandboxEventSeverity severity, string category) { Validation.ArgumentNotNull(exception, "exception"); Validation.ArgumentNotNull(additionalMessage, "additionalMessage"); WriteLogMessage(BuildExceptionMessage(exception, additionalMessage), eventId, severity, category); }
/// <summary> /// Override this method to change the way the log message is created for the sandbox /// </summary> /// <param name="message">The message to write into the log.</param> /// <param name="eventId"> /// The event Id 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 BuildEventLogMessage(string message, int eventId, SandboxEventSeverity severity, string category) { return message; }
protected override void WriteToOperationsLog(string message, int eventId, SandboxEventSeverity severity, string category) { throw new NotImplementedException(); }
protected override void WriteToOperationsLog(string message, int eventId, SandboxEventSeverity severity, string category) { ErrorMessage = message; }