---
title: "Custom Logger Plug-in"
url: https://docs.zeroc.com/ice/3.8/plugins/custom-logger-plug-in
language: csharp
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# Custom Logger Plug-in

Programming language: C#. Other languages: [C++](https://docs.zeroc.com/ice/3.8/plugins/custom-logger-plug-in/cpp.md), [Java](https://docs.zeroc.com/ice/3.8/plugins/custom-logger-plug-in/java.md), [JavaScript](https://docs.zeroc.com/ice/3.8/plugins/custom-logger-plug-in/js.md), [MATLAB](https://docs.zeroc.com/ice/3.8/plugins/custom-logger-plug-in/matlab.md), [PHP](https://docs.zeroc.com/ice/3.8/plugins/custom-logger-plug-in/php.md), [Python](https://docs.zeroc.com/ice/3.8/plugins/custom-logger-plug-in/python.md), [Ruby](https://docs.zeroc.com/ice/3.8/plugins/custom-logger-plug-in/ruby.md), [Swift](https://docs.zeroc.com/ice/3.8/plugins/custom-logger-plug-in/swift.md).

When you create a communicator in your own code, install a custom logger by setting `InitializationData.logger`.

A logger plug-in installs a custom logger through configuration, during communicator initialization. Use a logger plug-in when you don't create the communicator yourself, for example in an IceBox service, or when you want to install a custom logger without changing any source code.

Adding a logger plug-in factory to `InitializationData.pluginFactories` works too, but it is more work for the same result as setting `InitializationData.logger`.

## Installing a Custom Logger

Ice provides [`Ice.LoggerPlugin`](https://code.zeroc.com/ice/3.8/api/csharp/api/Ice.LoggerPlugin.html), a plug-in that installs a logger into the communicator. The communicator takes ownership of the logger and disposes it when the communicator is destroyed.

Assuming you wrote a `CustomLogger` class that implements `Ice.Logger`, create a plug-in factory that returns a `LoggerPlugin` for your logger:

```csharp
namespace ClearSky;

public class CustomLoggerPluginFactory : Ice.PluginFactory
{
    public string pluginName => "CustomLogger";

    public Ice.Plugin create(
        Ice.Communicator communicator,
        string name,
        string[] args) =>
        new Ice.LoggerPlugin(communicator, new CustomLogger());
}
```

Then, package your `CustomLogger` implementation and `CustomLoggerPluginFactory` in a .NET assembly, and configure your communicator to load it at runtime. For example:

```config
Ice.Plugin.CustomLogger=CustomLogger.dll:ClearSky.CustomLoggerPluginFactory
```

## See Also

- [Custom Loggers](https://docs.zeroc.com/ice/3.8/administration/logger-facility/custom-loggers/csharp.md)
- [The Per-Process Logger](https://docs.zeroc.com/ice/3.8/administration/logger-facility/per-process-logger/csharp.md)
- [Plug-in Facility](https://docs.zeroc.com/ice/3.8/plugins/plug-in-facility/csharp.md)
- [Ice.Plugin.\*](https://docs.zeroc.com/ice/3.8/property-reference/ice-plugin-properties/csharp.md)
