---
title: "Class LoggerBase"
slug: "sdk--stylelabs.m.sdk.models.logging.loggerbase"
abstract: ""
---
# Class LoggerBase

Base implementation of [ILogger](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.logging.ilogger.html).

The minimum log level is info by default.

## Inheritance

object

LoggerBase

[ConsoleLogger](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.models.logging.consolelogger.html)

[NullLogger](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.models.logging.nulllogger.html)

## Implements

[ILogger](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.logging.ilogger.html)

## Namespace: StylelabsStylelabs.MSdkStylelabs.M.Sdk.ModelsLogging

## Assembly: Stylelabs.M.Sdk.dll

## Syntax

```csharp
public abstract class LoggerBase : ILogger
```

## Properties

### IsDebugEnabled

Gets a value indicating whether debug-level logging is enabled.

#### Declaration

```csharp
public bool IsDebugEnabled { get; }
```

#### Property Value

| Type | Description |
| --- | --- |
| bool |  |

### IsErrorEnabled

Gets a value indicating whether error-level logging is enabled.

#### Declaration

```csharp
public bool IsErrorEnabled { get; }
```

#### Property Value

| Type | Description |
| --- | --- |
| bool |  |

### IsInfoEnabled

Gets a value indicating whether info-level logging is enabled.

#### Declaration

```csharp
public bool IsInfoEnabled { get; }
```

#### Property Value

| Type | Description |
| --- | --- |
| bool |  |

### IsWarnEnabled

Gets a value indicating whether warning-level logging is enabled.

#### Declaration

```csharp
public bool IsWarnEnabled { get; }
```

#### Property Value

| Type | Description |
| --- | --- |
| bool |  |

### MinimumLogLevel

Gets or sets the minimum enabled log level.

#### Declaration

```csharp
public virtual LogLevel MinimumLogLevel { get; set; }
```

#### Property Value

| Type | Description |
| --- | --- |
| [LogLevel](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.logging.loglevel.html) |  |

## Methods

### Debug(Func<string>)

Logs debug-level information.

#### Declaration

```csharp
public void Debug(Func<string> message)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Func<>string | message | Function that generates the log message. |

### Debug(string)

Logs debug-level information.

#### Declaration

```csharp
public void Debug(string message)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | message | Message to log. |

### DebugAsync(Func<Task<string>>)

Async version of [Debug(Func<string>)](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.logging.ilogger.html).

#### Declaration

```csharp
public Task DebugAsync(Func<Task<string>> message)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Func<>Task<>string | message | Message to log. |

#### Returns

| Type | Description |
| --- | --- |
| Task | A representing the asynchronous operation. |

### Error(Exception)

Logs error-level information.

#### Declaration

```csharp
public void Error(Exception exception)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Exception | exception | The exception that occurred. |

### Error(Func<string>, Exception)

Logs error-level information.

#### Declaration

```csharp
public void Error(Func<string> message, Exception exception = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Func<>string | message | Function that generates the log message. |
| Exception | exception | The exception that occurred. |

### Error(string, Exception)

Logs error-level information.

#### Declaration

```csharp
public void Error(string message, Exception exception = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | message | Message to log. |
| Exception | exception | The exception that occurred. |

### ErrorAsync(Func<Task<string>>, Exception)

Async version of [Error(Func<string>, Exception)](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.logging.ilogger.html).

#### Declaration

```csharp
public Task ErrorAsync(Func<Task<string>> message, Exception exception = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Func<>Task<>string | message | Function that generates the log message. |
| Exception | exception | The exception that occurred. |

#### Returns

| Type | Description |
| --- | --- |
| Task | A representing the asynchronous operation. |

### Info(Func<string>)

Logs info-level information.

#### Declaration

```csharp
public void Info(Func<string> message)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Func<>string | message | Function that generates the log message. |

### Info(string)

Logs info-level information.

#### Declaration

```csharp
public void Info(string message)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | message | Message to log. |

### InfoAsync(Func<Task<string>>)

Async version of [Info(Func<string>)](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.logging.ilogger.html).

#### Declaration

```csharp
public Task InfoAsync(Func<Task<string>> message)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Func<>Task<>string | message | Function that generates the log message. |

#### Returns

| Type | Description |
| --- | --- |
| Task | A representing the asynchronous operation. |

### LogDebug(string)

Logs debug-level information.

#### Declaration

```csharp
protected abstract void LogDebug(string message)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | message | The message to log. |

### LogError(Exception)

Logs error-level information.

#### Declaration

```csharp
protected abstract void LogError(Exception exception)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Exception | exception | The exception to log. |

### LogError(string, Exception)

Logs error-level information.

#### Declaration

```csharp
protected abstract void LogError(string message, Exception exception = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | message | The message to log. |
| Exception | exception | The exception to log. |

### LogInfo(string)

Logs info-level information.

#### Declaration

```csharp
protected abstract void LogInfo(string message)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | message | The message to log. |

### LogWarn(string)

Logs warning-level information.

#### Declaration

```csharp
protected abstract void LogWarn(string message)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | message | The message to log. |

### Warn(Func<string>)

Logs warning-level information.

#### Declaration

```csharp
public void Warn(Func<string> message)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Func<>string | message | Function that generates the log message. |

### Warn(string)

Logs warning-level information.

#### Declaration

```csharp
public void Warn(string message)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | message | Message to log. |

### WarnAsync(Func<Task<string>>)

Async version of [Warn(Func<string>)](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.logging.ilogger.html).

#### Declaration

```csharp
public Task WarnAsync(Func<Task<string>> message)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Func<>Task<>string | message | Function that generates the log message. |

#### Returns

| Type | Description |
| --- | --- |
| Task | A representing the asynchronous operation. |

## Events

### OnLog

Fires an event just before something is about to be logged.

#### Declaration

```csharp
public event EventHandler<LogEventArgs> OnLog
```

#### Event Type

| Type | Description |
| --- | --- |
| EventHandler<>[LogEventArgs](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.logging.logeventargs.html) |  |

### Implements

[ILogger](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.logging.ilogger.html)
