Show / Hide Table of Contents

Class ErrorReportingExceptionLogger

Google Cloud Error Reporting System.Web.Http.ExceptionHandling.ExceptionLogger.

Inheritance
System.Object
System.Web.Http.ExceptionHandling.ExceptionLogger
ErrorReportingExceptionLogger
Implements
System.Web.Http.ExceptionHandling.IExceptionLogger
System.IDisposable
Inherited Members
System.Web.Http.ExceptionHandling.ExceptionLogger.System.Web.Http.ExceptionHandling.IExceptionLogger.LogAsync(System.Web.Http.ExceptionHandling.ExceptionLoggerContext, System.Threading.CancellationToken)
System.Object.ToString()
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Google.Cloud.Diagnostics.AspNet
Assembly: Google.Cloud.Diagnostics.AspNet.dll
Syntax
public sealed class ErrorReportingExceptionLogger : ExceptionLogger, IExceptionLogger, IDisposable
Remarks

Reports unhandled exceptions to Google Cloud Error Reporting. Docs: https://cloud.google.com/error-reporting/docs/

Examples
public static void Register(HttpConfiguration config)
{
  // Add a catch all for the uncaught exceptions.
  string projectId = "[Google Cloud Platform project ID]";
  string serviceName = "[Name of service]";
  string version = "[Version of service]";
  // Add a catch all for the uncaught exceptions.
  config.Services.Add(typeof(IExceptionLogger),
      ErrorReportingExceptionLogger.Create(projectId, serviceName, version));
}

Methods

Create(String, String, ErrorReportingOptions)

Creates an instance of ErrorReportingExceptionLogger using credentials as defined by GetApplicationDefaultAsync().

Can be used when running on Google App Engine or Google Compute Engine. The Google Cloud Platform project to report errors to will detected from the current platform.

Declaration
public static ErrorReportingExceptionLogger Create(string serviceName, string version, ErrorReportingOptions options = null)
Parameters
Type Name Description
System.String serviceName

An identifier of the service, such as the name of the executable or job. May be null.

System.String version

Represents the source code version that the developer provided. May be null.

ErrorReportingOptions options

Optional, error reporting options.

Returns
Type Description
ErrorReportingExceptionLogger

Create(String, String, String, ErrorReportingOptions)

Creates an instance of ErrorReportingExceptionLogger using credentials as defined by GetApplicationDefaultAsync().

Declaration
public static ErrorReportingExceptionLogger Create(string projectId, string serviceName, string version, ErrorReportingOptions options = null)
Parameters
Type Name Description
System.String projectId

The Google Cloud Platform project ID. Must not be null.

System.String serviceName

An identifier of the service, such as the name of the executable or job. May be null.

System.String version

Represents the source code version that the developer provided. May be null.

ErrorReportingOptions options

Optional, error reporting options.

Returns
Type Description
ErrorReportingExceptionLogger

Dispose()

Declaration
public void Dispose()
Implements
System.IDisposable.Dispose()

Log(ExceptionLoggerContext)

Declaration
public override void Log(ExceptionLoggerContext context)
Parameters
Type Name Description
System.Web.Http.ExceptionHandling.ExceptionLoggerContext context
Overrides
System.Web.Http.ExceptionHandling.ExceptionLogger.Log(System.Web.Http.ExceptionHandling.ExceptionLoggerContext)

LogAsync(ExceptionLoggerContext, CancellationToken)

Declaration
public override Task LogAsync(ExceptionLoggerContext context, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Web.Http.ExceptionHandling.ExceptionLoggerContext context
System.Threading.CancellationToken cancellationToken
Returns
Type Description
System.Threading.Tasks.Task
Overrides
System.Web.Http.ExceptionHandling.ExceptionLogger.LogAsync(System.Web.Http.ExceptionHandling.ExceptionLoggerContext, System.Threading.CancellationToken)

ShouldLog(ExceptionLoggerContext)

Declaration
public override bool ShouldLog(ExceptionLoggerContext context)
Parameters
Type Name Description
System.Web.Http.ExceptionHandling.ExceptionLoggerContext context
Returns
Type Description
System.Boolean
Overrides
System.Web.Http.ExceptionHandling.ExceptionLogger.ShouldLog(System.Web.Http.ExceptionHandling.ExceptionLoggerContext)
Back to top