---
title: Log an exception remotely
summary: Forward exception details to the remote logging service.
status: draft
owner: SAIF.Core Documentation Team
last_reviewed: 2026-09-24
library: SAIF.Services.Web.Proxies
reference_type: package
operation_id: OP-WP-04
trigger: EnvironmentApi SAIFExceptionLogger (non-eligible), or package consumers
---

# Log an exception remotely

`LoggingServiceProxy.LogException` wraps the Logging SOAP service (`clsWSLoggingSoapClient`) to forward an `ApplicationExceptionDetail` to the centralized logging service, mapping each field to the wire `ErrorInfoStruct`.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-WP-04 |
| **Trigger** | EnvironmentApi's `SAIFExceptionLogger` (non-eligible in this run), or package consumers |
| **Inputs** | `SAIF.Core.Contracts.ApplicationExceptionDetail` |
| **Outputs** | A remote `WriteError` call; no return value |
| **Primary components** | `LoggingServiceProxy.LogException`, `Extensions.ToErrorInfoStruct` |
| **Entry point** | `Services/SAIF.Services.Web.Proxies/LoggingServiceProxy.cs` |

## Steps

1. Construct `LoggingServiceProxy(serviceUrl)`: guard `serviceUrl` ([WP-BR-001](../business-rules.md#wp-br-001-required-arguments-must-be-non-null-or-non-empty)), then build a default `BasicHttpBinding` client.
2. **`LogException(detail)`:** map `ApplicationExceptionDetail` to `ErrorInfoStruct` via `Extensions.ToErrorInfoStruct`:
   - `Application` → `ApplicationName`
   - `Environment` → `Environment`
   - `ExceptionDate` → `ErrorDate`
   - `Message` → `ExceptionInfo`
   - `Source` → `ExceptionSource`
   - `Machine` → `MachineName`
   - `Page` → `PageName`
   - `State` → `StateInfo`
   - `User` → `Username`
   - `ExtensionData` is set to null
3. Call wire `WriteError(eis)`.

## Process flow

The following diagram visualizes the field mapping and delegation to the wire operation.

```mermaid
flowchart TD
	Start([LogException invoked]) --> Map["Map ApplicationExceptionDetail<br>to ErrorInfoStruct"]
	Map --> Call["Call wire WriteError(eis)"]
	Call --> Ret(["Return; no result"])
```

## Failure and edge-case behavior

- A null/empty `serviceUrl` at construction throws an argument exception before any wire client is created.
- The mapping is a direct field copy with no validation; a malformed `detail` is forwarded as-is to the remote service*.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts.

## Sources
- `Services/SAIF.Services.Web.Proxies/LoggingServiceProxy.cs`
