コード例 #1
0
        public void Setup()
        {
            var conf = LogQuickConfig.SetupFileAndConsole("./logs/ServiceFactoryTests.log");

            loggerFactory = LoggerFactory.Create(builder =>
            {
                builder.AddNLog(conf);
                builder.SetMinimumLevel(LogLevel.Trace);
            });
        }
コード例 #2
0
        public void UseMicrosoftJsonTest()
        {
            var conf = LogQuickConfig.SetupFileAndConsole("./logs/LogQuickConfigTests.log");

            loggerFactory = LoggerFactory.Create(builder =>
            {
                builder.AddNLog(conf);
                builder.SetMinimumLevel(LogLevel.Trace);
            });

            var someObject = new { AboOl = true, aString = "string", AiNt = 12, anull = (string)null };

            var mlog = loggerFactory.CreateLogger <LogQuickConfigTests>();

            mlog.LogTrace("trace microsoft logger default = {@someObject}", someObject);

            LogQuickConfig.UseMicrosoftJson();
            mlog.LogTrace("trace microsoft logger msjson  = {@someObject}", someObject);

            LogQuickConfig.UseNewtonsoftJson();
            mlog.LogTrace("trace microsoft logger newton  = {@someObject}", someObject);
        }
コード例 #3
0
        public void SetupFileAndConsoleTest()
        {
            var conf = LogQuickConfig.SetupFileAndConsole("./logs/LogQuickConfigTests.log");

            loggerFactory = LoggerFactory.Create(builder =>
            {
                builder.AddNLog(conf);
                builder.SetMinimumLevel(LogLevel.Trace);
            });

            var someObject = new { abool = true, astring = "string", aint = 12 };

            var mlog = loggerFactory.CreateLogger <LogQuickConfigTests>();

            mlog.LogTrace("trace microsoft logger {someObject}", someObject);
            mlog.LogDebug("debug microsoft logger {someObject}", someObject);
            mlog.LogInformation("info microsoft logger {someObject}", someObject);

            nlog.Trace("trace nlog {someObject}", someObject);
            nlog.Debug("debug nlog {someObject}", someObject);
            nlog.Info("info nlog {someObject}", someObject);
        }