---
title: Log into .Net Diagnostics Trace
slug: cms-11/dev-docs/logging-into-net-diagnostics-trace-legacy
docTags: 
createdAt: 2026-07-22T19:45:19.315Z
---

There are two built-in logger factories for writing log messages from the Optimizely Log API to .NET Diagnostics Trace; the `EPiServer.Logging.TraceLoggerFactory` and the `EPiServer.Logging.TraceSourceLoggerFactory`.

:::hint{type="info"}
**Note**
In Optimizely Digital Experience Platform (DXP), Optimizely logs are redirected into .NET Diagnostic Trace, as long as the code uses the Optimizely logging abstraction `EPiServer.Logging.LogManager`. If you are using log4net and deploying in Optimizely DXP, replace `log4net` with `EPiServer.Logging`. See also [Logging](docId\:IzGRBkFLL7Vrgpvhjtk5l)  for more information on switching logging APIs.
:::

## EPiServer.Logging.TraceLoggerFactory

The `EPiServer.Logging.TraceLoggerFactory` logger redirects log messages to diagnostics trace.

| Optimizely log level               | maps to                                    |
| ---------------------------------- | ------------------------------------------ |
| Optimizely Critical and Error Log  | system diagnostics trace error level       |
| Optimizely Warning Log API         | system diagnostics trace warning level     |
| Optimizely Information Log API     | system diagnostics trace Information level |
| Optimizely Debug and Trace Log API | not logged                                 |

You enable `EPiServer.Logging.TraceLoggerFactory` like this:

```xml
<appSettings>
  <add key="episerver:LoggerFactoryType" 
       value="EPiServer.Logging.TraceLoggerFactory, EPiServer.Framework" />
</appSettings>
```

Or from the **episerver.framework** section like this:

```xml
<episerver.framework loggerFactoryType="EPiServer.Logging.TraceLoggerFactory, EPiServer.Framework">
```

## EPiServer.Logging.TraceSourceLoggerFactory

The `EPiServer.Logging.TraceSourceLoggerFactory` redirects log messages to diagnostics trace source. In this implementation, each logger name has its source switch trace.

| Optimizely log level                 | maps to                                           |
| ------------------------------------ | ------------------------------------------------- |
| Optimizely Critical Log API level    | system diagnostics trace source critical level    |
| Optimizely Error Log API level       | system diagnostics trace source error level       |
| Optimizely Warning Log API level     | system diagnostics trace source warning level     |
| Optimizely Information Log API level | system diagnostics trace source Information level |
| Optimizely Debug and Trace Log API   | system diagnostics Verbose                        |

You can enable the `EPiServer.Logging.TraceSourceLoggerFactory` like this:

```xml
<appSettings>
  <add key="episerver:LoggerFactoryType" 
       value="EPiServer.Logging.TraceSourceLoggerFactory, EPiServer.Framework" />
</appSettings>
```

Or from the `<episerver.framework>` section like this:

```xml
<episerver.framework loggerFactoryType="EPiServer.Logging.TraceSourceLoggerFactory, EPiServer.Framework">
```

By default, the logging level is set to the **Error**. If you need to log lower levels than the Error level, configure it in the `<system.diagnostics>` section like this:

```xml
<system.diagnostics>
  <sources>
    <source name="logger name" 
            switchName="logger name" 
            switchType="System.Diagnostics.SourceSwitch"/>
  </sources>
  <switches>
    <add name="logger name" 
         value="Verbose" />
  </switches>
</system.diagnostics>
```

## Register Logger Factory with configuration

To register a logger factory with configuration, you need to add the logger factory type in the `<appSettings>` section:

```xml
<appSettings>
  <add key="episerver:LoggerFactoryType" 
       value="the custom logger factory type" />
</appSettings>
```

Or from `<episerver.framework>` section:

```xml
<episerver.framework loggerFactoryType="the custom logger factory type">
```

:::hint{type="info"}
**Note**
The `<appsetting>` section value always has a higher priority than the `<episerver.framework>` section value.
:::
