> For the complete documentation index, see [llms.txt](https://docs.wisej.com/ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/ai/components/api/services/iloggerservice/wisej.ai.services.defaultloggerservice.md).

# DefaultLoggerService

Namespace: **Wisej.AI.Services**

Assembly: **Wisej.AI** (3.5.0.0)

Provides a default implementation of the [ILoggerService](/ai/components/api/services/iloggerservice.md) for logging messages and exceptions.

{% tabs %}
{% tab title="C#" %}

```csharp
public class DefaultLoggerService : ILoggerService
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class DefaultLoggerService
    Inherits ILoggerService
```

{% endtab %}
{% endtabs %}

This class implements the [ILoggerService](/ai/components/api/services/iloggerservice.md) interface, offering methods to log messages and exceptions at various trace levels.

## Constructors

### ![](/files/ptrKjmmRoQB76pvrIqh0) DefaultLoggerService()

Initializes a new instance of [DefaultLoggerService](https://docs.wisej.com/api?q=wisej.ai.services.defaultloggerservice).

## Methods

### ![](/files/ptrKjmmRoQB76pvrIqh0) Log(level, context, message, arguments)

Provides functionality to log messages at various trace levels.

| Parameter     | Type                                                                              | Description                                                                        |
| ------------- | --------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| **level**     | [TraceLevel](https://docs.microsoft.com/dotnet/api/system.diagnostics.tracelevel) | The trace level at which the message should be logged.                             |
| **context**   | [String](https://docs.microsoft.com/dotnet/api/system.string)                     | A string representing the name of the class and the method that called the logger. |
| **message**   | [String](https://docs.microsoft.com/dotnet/api/system.string)                     | The message to be logged. This parameter supports composite formatting.            |
| **arguments** | [Object\[\]](https://docs.microsoft.com/dotnet/api/system.object)                 | An array of objects to format the message with. This parameter is optional.        |

This method allows for logging messages with different severity levels, facilitating the tracking of information, warnings, and errors. Depending on the *level* specified, the method will route the message to the appropriate logging method.\
The supported trace levels are:

* [Off](https://docs.microsoft.com/dotnet/api/system.diagnostics.tracelevel.off): No logging is performed.
* [Info](https://docs.microsoft.com/dotnet/api/system.diagnostics.tracelevel.info): Logs informational messages.
* [Error](https://docs.microsoft.com/dotnet/api/system.diagnostics.tracelevel.error): Logs error messages.
* [Warning](https://docs.microsoft.com/dotnet/api/system.diagnostics.tracelevel.warning): Logs warning messages.

Here is an example of how to use the [Log](#log-level-context-message-arguments) method:

```csharp

  Log(TraceLevel.Info, "Starting process with ID {0}", processId);
  Log(TraceLevel.Warning, "Disk space is low on drive {0}", driveName);
  Log(TraceLevel.Error, "Failed to connect to server. Error: {0}", errorMessage);

```

### ![](/files/ptrKjmmRoQB76pvrIqh0) Log(level, context, exception)

Logs an exception at a specified trace level.

| Parameter     | Type                                                                              | Description                                                                        |
| ------------- | --------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| **level**     | [TraceLevel](https://docs.microsoft.com/dotnet/api/system.diagnostics.tracelevel) | The trace level at which the exception should be logged.                           |
| **context**   | [String](https://docs.microsoft.com/dotnet/api/system.string)                     | A string representing the name of the class and the method that called the logger. |
| **exception** | [Exception](https://docs.microsoft.com/dotnet/api/system.exception)               | The exception to be logged.                                                        |

This method is designed to log exceptions, allowing for a structured approach to error handling and diagnostics. The *level* parameter determines the severity of the log entry.\
Example usage of the method:

```csharp

try
{
// Code that might throw an exception
}
catch (Exception ex)
{
Log(TraceLevel.Error, ex);
}

```

## Implements

| Name                                                            | Description                                                                                                                           |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| [ILoggerService](/ai/components/api/services/iloggerservice.md) | Defines a contract for logging services that support logging messages with a specified trace level and optional formatting arguments. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wisej.com/ai/components/api/services/iloggerservice/wisej.ai.services.defaultloggerservice.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
