public NLogTracerWriterTests()
        {
            // setup writer under test
            _writer = new NLogTraceWriter();

            // setup debug logging target
            _debugTarget = new DebugTarget { Layout = "${message}" };
            SimpleConfigurator.ConfigureForTargetLogging(_debugTarget, LogLevel.Info);
        }
Exemple #2
0
        public static void Register(HttpConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            var traceWriter = new NLogTraceWriter();

            configuration.Services.Replace(typeof(ITraceWriter), traceWriter);
        }
        public NLogTracerWriterTests()
        {
            // setup writer under test
            _writer = new NLogTraceWriter();

            // setup debug logging target
            _debugTarget = new DebugTarget {
                Layout = "${message}"
            };
            SimpleConfigurator.ConfigureForTargetLogging(_debugTarget, LogLevel.Info);
        }
        public WebApiRequestRendererTests()
        {
            EnsureLayoutRendersSetup.Please();

            // setup writer under test
            _writer = new NLogTraceWriter();

            // setup debug logging target
            _debugTarget = new DebugTarget { Layout = "${message}" };
            SimpleConfigurator.ConfigureForTargetLogging(_debugTarget, LogLevel.Info);
        }
        public WebApiTraceRendererTests()
        {
            EnsureLayoutRendersSetup.Please();

            // setup writer under test
            _writer = new NLogTraceWriter();

            // setup debug logging target
            _debugTarget = new DebugTarget {
                Layout = "${message}"
            };
            SimpleConfigurator.ConfigureForTargetLogging(_debugTarget, LogLevel.Info);
        }
Exemple #6
0
 public static string SerializeJson(object obj)
 {
     try
     {
         ITraceWriter traceWriter = new NLogTraceWriter();
         var          sett        = new JsonSerializerSettings();
         sett.TypeNameHandling = TypeNameHandling.All;
         sett.TraceWriter      = traceWriter;
         var res = JsonConvert.SerializeObject(obj, sett);
         Debug.WriteLine(traceWriter);
         return(res);
     }
     catch (Exception e)
     {
         return("");
     }
 }
Exemple #7
0
        /// <summary>
        /// Registers the <see cref="ITraceWriter"/> implementation to use
        /// for this application.
        /// </summary>
        /// <param name="configuration">The <see cref="HttpConfiguration"/> in which
        /// to register the trace writer.</param>
        public static void Register(HttpConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            //SystemDiagnosticsTraceWriter traceWriter =
            //    new SystemDiagnosticsTraceWriter()
            //    {
            //        MinimumLevel = TraceLevel.Info,
            //        IsVerbose = false
            //    };

            var traceWriter = new NLogTraceWriter();

            configuration.Services.Replace(typeof(ITraceWriter), traceWriter);
        }