public NLogTracerWriterTests() { // setup writer under test _writer = new NLogTraceWriter(); // setup debug logging target _debugTarget = new DebugTarget { Layout = "${message}" }; SimpleConfigurator.ConfigureForTargetLogging(_debugTarget, LogLevel.Info); }
public static void Register(HttpConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } var traceWriter = new NLogTraceWriter(); configuration.Services.Replace(typeof(ITraceWriter), traceWriter); }
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); }
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(""); } }
/// <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); }