public static void ConfigureLogger(LogOptions options, IEnumerable <LogMessage> initialLogMessages = null)
        {
            LoggerFactory.AddSerilog(new LoggerConfiguration()
                                     .MinimumLevel.Is(options.LogLevel)
                                     .Enrich.FromLogContext()
                                     .WriteTo.Console()
                                     .CreateLogger());

            if (options.LogToFile)
            {
                // log on the lowest level to the log file
                var logFilesPath = Path.Combine(options.OutputPath, "logs");
                LoggerFactory.AddFile(logFilesPath + "/log-{Date}.txt", LogLevel.Trace);
            }

            if (initialLogMessages != null)
            {
                var logger = LoggerFactory.CreateLogger("InitialLogging");

                foreach (var logMessage in initialLogMessages)
                {
                    // Create the generic variant of the method to make sure any consumer can use typeof(TState)
                    _logMethodInfo.MakeGenericMethod(logMessage.StateType)
                    .Invoke(
                        logger,
                        new[] { logMessage.LogLevel, logMessage.EventId, logMessage.State, logMessage.Exception, logMessage.Formatter });
                }
            }
        }
        public static void ConfigureLogger(LogOptions options, IEnumerable <LogMessage> initialLogMessages = null)
        {
            LoggerFactory.AddSerilog(new LoggerConfiguration()
                                     .MinimumLevel.Is(options.LogLevel)
                                     .Enrich.FromLogContext()
                                     .WriteTo.Console()
                                     .CreateLogger());

            if (options.LogToFile)
            {
                // log on the lowest level to the log file
                var logFilesPath = Path.Combine(options.OutputPath, "logs");
                LoggerFactory.AddFile(logFilesPath + "/log-{Date}.txt", LogLevel.Trace);
            }

            if (initialLogMessages != null)
            {
                var logger = LoggerFactory.CreateLogger("InitialLogging");

                foreach (var logMessage in initialLogMessages)
                {
                    logger.Log(logMessage.LogLevel, logMessage.EventId, logMessage.State, logMessage.Exception, logMessage.Formatter);
                }
            }
        }
Exemple #3
0
        public static void ConfigureLogger(LogOptions options, IEnumerable <LogMessage> initialLogMessages = null)
        {
            LoggerFactory.AddSerilog(new LoggerConfiguration().MinimumLevel.Is(options.LogLevel).Enrich.FromLogContext().WriteTo.Console().CreateLogger());

            if (options.LogToFile)
            {
                // log on the lowest level to the log file
                var logFilesPath = Path.Combine(options.OutputPath, "logs");
                LoggerFactory.AddFile(logFilesPath + "/log-{Date}.txt", MSLogLevel.Trace);
            }

            if (initialLogMessages != null)
            {
                var logger = LoggerFactory.CreateLogger("InitialLogging");

                foreach (var logMessage in initialLogMessages)
                {
                    logger.Log(logMessage.LogLevel, logMessage.EventId, logMessage.State, logMessage.Exception, logMessage.Formatter);
                }
            }

            // When stryker log level is debug or trace, set LibGit2Sharp loglevel to info
            if (options.LogLevel < LogEventLevel.Information)
            {
                var libGit2SharpLogger = LoggerFactory.CreateLogger(nameof(LibGit2Sharp));
                GlobalSettings.LogConfiguration = new LogConfiguration(LibGitLogLevel.Info, (level, message) => libGit2SharpLogger.Log(LogLevelMap[level], message));
            }
        }
Exemple #4
0
        public static void ConfigureLogger(LogOptions options)
        {
            LoggerFactory.AddSerilog(new LoggerConfiguration()
                                     .MinimumLevel.Is(options.LogLevel)
                                     .Enrich.FromLogContext()
                                     .WriteTo.Console()
                                     .CreateLogger());

            if (options.LogToFile)
            {
                // log on the lowest level to the log file
                LoggerFactory.AddFile("StrykerLogs/log-{Date}.txt", LogLevel.Trace);
            }
        }
Exemple #5
0
        public static void ConfigureLogger(LogOptions options)
        {
            LoggerFactory.AddSerilog(new LoggerConfiguration()
                                     .MinimumLevel.Is(options.LogLevel)
                                     .Enrich.FromLogContext()
                                     .WriteTo.Console()
                                     .CreateLogger());

            if (options.LogToFile)
            {
                // log on the lowest level to the log file
                var logFilesPath = Path.Combine(options.OutputPath, "logs");
                LoggerFactory.AddFile(logFilesPath + "/log-{Date}.txt", LogLevel.Trace);
            }
        }