-Documentation
This commit is contained in:
@@ -340,11 +340,11 @@ or a property's object properties or collection items using
|
||||
|
||||
<section>
|
||||
<title>TraceWriter</title>
|
||||
<content><para>The Json.NET serializer supports logging using the <codeEntityReference>T:Newtonsoft.Json.Serialization.ITraceWriter</codeEntityReference>
|
||||
interface. By assigning a trace writer you can debug what is happening inside the Json.NET serializer when
|
||||
serializing and deserializing JSON.</para>
|
||||
<content><para>The Json.NET serializer supports logging and debugging using the
|
||||
<codeEntityReference>T:Newtonsoft.Json.Serialization.ITraceWriter</codeEntityReference> interface.
|
||||
By assigning a trace writer you can debug what happens inside the Json.NET serializer when serializing and deserializing JSON.</para>
|
||||
<para>Read more about TraceWriters here: <externalLink>
|
||||
<linkText>Debug with Serialization Tracing</linkText>
|
||||
<linkText>Debugging with Serialization Tracing</linkText>
|
||||
<linkUri>SerializationTracing.htm</linkUri>
|
||||
<linkTarget>_self</linkTarget>
|
||||
</externalLink></para>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<topic id="SerializationTracing" revisionNumber="1">
|
||||
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<introduction>
|
||||
<para>The Json.NET serializer supports logging using the <codeEntityReference>T:Newtonsoft.Json.Serialization.ITraceWriter</codeEntityReference>
|
||||
interface. By assigning a trace writer you can debug what is happening inside the Json.NET serializer when
|
||||
serializing and deserializing JSON.</para>
|
||||
<para>The Json.NET serializer supports logging and debugging using the
|
||||
<codeEntityReference>T:Newtonsoft.Json.Serialization.ITraceWriter</codeEntityReference> interface.
|
||||
By assigning a trace writer you can debug what happens inside the Json.NET serializer when serializing and deserializing JSON.</para>
|
||||
</introduction>
|
||||
<section>
|
||||
<title>ITraceWriter</title>
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\TraceWriterTests.cs" region="MemoryTraceWriterExample" title="Debugging serialization using MemoryTraceWriter" />
|
||||
|
||||
<para>Json.NET has two implementations of ITraceWriter: <codeEntityReference>P:Newtonsoft.Json.Serialization.MemoryTraceWriter</codeEntityReference>
|
||||
<para>Json.NET has two implementations of ITraceWriter: <codeEntityReference>T:Newtonsoft.Json.Serialization.MemoryTraceWriter</codeEntityReference>
|
||||
which keeps messages in memory for simple debugging like the example
|
||||
above, and <codeEntityReference>T:Newtonsoft.Json.Serialization.DiagnosticsTraceWriter</codeEntityReference> which writes messages to any
|
||||
System.Diagnostics.TraceListeners your application is using.</para>
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
<Topic id="SerializingJSONFragments" visible="True" title="Serializing Partial JSON Fragments" />
|
||||
<Topic id="ConditionalProperties" visible="True" title="Conditional Property Serialization" />
|
||||
<Topic id="ContractResolver" visible="True" title="Serialization using ContractResolver" />
|
||||
<Topic id="SerializationTracing" visible="True" isSelected="true" title="Debug with Serialization Tracing" />
|
||||
<Topic id="SerializationTracing" visible="True" isSelected="true" title="Debugging with Serialization Tracing" />
|
||||
</Topic>
|
||||
<Topic id="LINQtoJSON" visible="True" title="LINQ to JSON">
|
||||
<Topic id="ParsingLINQtoJSON" visible="True" title="Parsing JSON" />
|
||||
|
||||
@@ -98,6 +98,19 @@ namespace Newtonsoft.Json.Tests.Documentation
|
||||
get { return TraceLevel.Verbose; }
|
||||
}
|
||||
|
||||
public void Trace(TraceLevel level, string message, Exception ex)
|
||||
{
|
||||
LogEventInfo logEvent = new LogEventInfo
|
||||
{
|
||||
Message = message,
|
||||
Level = GetLogLevel(level),
|
||||
Exception = ex
|
||||
};
|
||||
|
||||
// log Json.NET message to NLog
|
||||
Logger.Log(logEvent);
|
||||
}
|
||||
|
||||
private LogLevel GetLogLevel(TraceLevel level)
|
||||
{
|
||||
switch (level)
|
||||
@@ -114,18 +127,6 @@ namespace Newtonsoft.Json.Tests.Documentation
|
||||
return LogLevel.Trace;
|
||||
}
|
||||
}
|
||||
|
||||
public void Trace(TraceLevel level, string message, Exception ex)
|
||||
{
|
||||
LogEventInfo logEvent = new LogEventInfo
|
||||
{
|
||||
Message = message,
|
||||
Level = GetLogLevel(level),
|
||||
Exception = ex
|
||||
};
|
||||
|
||||
Logger.Log(logEvent);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user