Refactoring based on OPEN CLOSE PRINCIPLE- C# I have some code to write Error Logs to different places like Console/SignalR Messages/Text File.

The code is as follows:-

public class Logger
    {
    public void WriteToLog(string message, LogType logType)
    {
        switch (logType)
        {
            case LogType.Console:
                Console.WriteLine(message);
                break;

            case LogType.SignalR:
                // Code to send message to SignalR Hub
                break;

            case LogType.File:
                // Code to write in .txt file
                break;
        }
    }
}


Where my LogType is a simple Enum as below:-

public enum LogType
{
    Console,
    SignalR,
    File
}


But, when I think of Open-Close Principle, I am not getting optimal solution for it.

Edit:

I need to refactor my code as per open close principle. I need to optimize it, so that I don't need to Modify WriteToLog method once any LogType gets added.
You should create an interface from which you can make many implementations, e.g. an ILogger interface with Warning, Error methods etc.
Then you would create an implementation per logging type (one for console, one for SignalR etc). You could then inject the ILogger into any type that requires it (or another approach is to use a static field and resolve the logger through a static log manager type).
You might also want to consider a library such as Common.Logging which already provides an interface and several implementations already available, e.g. NLog, log4net etc.
Another consideration is whether you wish to mix business logic and logging code. Other alternatives are an AOP approach (PostSharp is one option) or semantic logging.