Click or drag to resize
SetExceptionExtensionMethodSetException Method
Sets the value of ExceptionDetails to a string representation of the provided exception. Also sets various extended properties (inner exception messages and items in Data).

Namespace: Rock.Logging
Assembly: Rock.Logging (in Rock.Logging.dll) Version: 0.9.2
Syntax
public static void SetException(
	this ILogEntry source,
	Exception exception,
	string exceptionContext = null
)

Parameters

source
Type: Rock.LoggingILogEntry
The instance of ILogEntry to set exception details for.
exception
Type: SystemException
The exception to be added to this instance of ILogEntry.
exceptionContext (Optional)
Type: SystemString
Contextual information about the exception. This value should give a developer additional information to help debug or fix the issue.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ILogEntry. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Examples
ILogger logger = LoggerFactory.GetInstance();

public void ProcessLoan(int loanNumber)
{
  try
  {
    LogEntry entry = new LogEntry("Doing Something");
    entry.ExtendedProperties.Add("LoanNumber", loanNumber);

    DoSomething(loanNumber);

    if(logger.IsInfoEnabled)
    {
      logger.Info(entry);
    }
  }
  catch (Exception ex)
  {
    if (logger.IsErrorEnabled)
    {
      entry.SetException(ex);
      logger.Error(entry);
    }
  }
}
See Also