From a28aefb51fa455bbce97dd996976dc09e4fc3a7a Mon Sep 17 00:00:00 2001 From: Bepis <36346617+bbepis@users.noreply.github.com> Date: Mon, 25 Jan 2021 02:45:50 +1100 Subject: [PATCH] Fix Logger static constructor issue --- BepInEx.Core/Logging/Logger.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/BepInEx.Core/Logging/Logger.cs b/BepInEx.Core/Logging/Logger.cs index b139c1a..48ad1ec 100644 --- a/BepInEx.Core/Logging/Logger.cs +++ b/BepInEx.Core/Logging/Logger.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; namespace BepInEx.Logging @@ -8,17 +8,25 @@ namespace BepInEx.Logging /// public static class Logger { - private static readonly ManualLogSource InternalLogSource = CreateLogSource("BepInEx"); + private static readonly ManualLogSource InternalLogSource; /// /// Collection of all log listeners that receive log events. /// - public static ICollection Listeners { get; } = new List(); + public static ICollection Listeners { get; } /// /// Collection of all log source that output log events. /// - public static ICollection Sources { get; } = new LogSourceCollection(); + public static ICollection Sources { get; } + + static Logger() + { + Sources = new LogSourceCollection(); + Listeners = new List(); + + InternalLogSource = CreateLogSource("BepInEx"); + } internal static void InternalLogEvent(object sender, LogEventArgs eventArgs) {