public static void init_logging(logConfig userConfig) { // Logging var config = new NLog.Config.LoggingConfiguration(); // Targets where to log to: File and Console //var logfile = new NLog.Targets.FileTarget("logfile") { FileName = "file.txt" }; var logconsole = new NLog.Targets.ColoredConsoleTarget("logconsole"); LogLevel userLogLevel = LogLevel.Info; if (userConfig.logLevel.ToLower() == "debug") { userLogLevel = LogLevel.Debug; } if (userConfig.logLevel.ToLower() == "warning") { userLogLevel = LogLevel.Warn; } if (userConfig.logLevel.ToLower() == "error") { userLogLevel = LogLevel.Error; } if (userConfig.logLevel.ToLower() == "fatal") { userLogLevel = LogLevel.Fatal; } // Rules for mapping loggers to targets config.AddRule(userLogLevel, LogLevel.Fatal, logconsole); // Apply config NLog.LogManager.Configuration = config; }
public logConfigWrapper() { loggerConfig = new logConfig(); }