# Interface IExceptionLogger (4.4.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [4.4.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.IExceptionLogger)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/4.3.1/Google.Cloud.Diagnostics.AspNetCore.IExceptionLogger)

    public interface IExceptionLogger

A generic exception logger.

## Namespace

[Google.Cloud.Diagnostics.AspNetCore](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore)

## Assembly

Google.Cloud.Diagnostics.AspNetCore.dll

## Methods

### Log(Exception, HttpContext)

    void Log(Exception exception, HttpContext context = null)

Logs an exception that occurred.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `exception` | `https://learn.microsoft.com/dotnet/api/system.exception` The exception to log. Must not be null. |
| `context` | `https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.http.httpcontext` Optional, the current HTTP context. If unset the current context will be retrieved automatically. |

### LogAsync(Exception, HttpContext, CancellationToken)

    Task LogAsync(Exception exception, HttpContext context = null, CancellationToken cancellationToken = default(CancellationToken))

Asynchronously logs an exception that occurred.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `exception` | `https://learn.microsoft.com/dotnet/api/system.exception` The exception to log. Must not be null. |
| `context` | `https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.http.httpcontext` Optional, the current HTTP context. If unset the current context will be retrieved automatically. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` Optional, The token to monitor for cancellation requests. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A task representing the asynchronous operation. |