-Documentation
This commit is contained in:
@@ -340,11 +340,11 @@ or a property's object properties or collection items using
|
|||||||
|
|
||||||
<section>
|
<section>
|
||||||
<title>TraceWriter</title>
|
<title>TraceWriter</title>
|
||||||
<content><para>The Json.NET serializer supports logging using the <codeEntityReference>T:Newtonsoft.Json.Serialization.ITraceWriter</codeEntityReference>
|
<content><para>The Json.NET serializer supports logging and debugging using the
|
||||||
interface. By assigning a trace writer you can debug what is happening inside the Json.NET serializer when
|
<codeEntityReference>T:Newtonsoft.Json.Serialization.ITraceWriter</codeEntityReference> interface.
|
||||||
serializing and deserializing JSON.</para>
|
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>
|
<para>Read more about TraceWriters here: <externalLink>
|
||||||
<linkText>Debug with Serialization Tracing</linkText>
|
<linkText>Debugging with Serialization Tracing</linkText>
|
||||||
<linkUri>SerializationTracing.htm</linkUri>
|
<linkUri>SerializationTracing.htm</linkUri>
|
||||||
<linkTarget>_self</linkTarget>
|
<linkTarget>_self</linkTarget>
|
||||||
</externalLink></para>
|
</externalLink></para>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<topic id="SerializationTracing" revisionNumber="1">
|
<topic id="SerializationTracing" revisionNumber="1">
|
||||||
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
<introduction>
|
<introduction>
|
||||||
<para>The Json.NET serializer supports logging using the <codeEntityReference>T:Newtonsoft.Json.Serialization.ITraceWriter</codeEntityReference>
|
<para>The Json.NET serializer supports logging and debugging using the
|
||||||
interface. By assigning a trace writer you can debug what is happening inside the Json.NET serializer when
|
<codeEntityReference>T:Newtonsoft.Json.Serialization.ITraceWriter</codeEntityReference> interface.
|
||||||
serializing and deserializing JSON.</para>
|
By assigning a trace writer you can debug what happens inside the Json.NET serializer when serializing and deserializing JSON.</para>
|
||||||
</introduction>
|
</introduction>
|
||||||
<section>
|
<section>
|
||||||
<title>ITraceWriter</title>
|
<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" />
|
<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
|
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
|
above, and <codeEntityReference>T:Newtonsoft.Json.Serialization.DiagnosticsTraceWriter</codeEntityReference> which writes messages to any
|
||||||
System.Diagnostics.TraceListeners your application is using.</para>
|
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="SerializingJSONFragments" visible="True" title="Serializing Partial JSON Fragments" />
|
||||||
<Topic id="ConditionalProperties" visible="True" title="Conditional Property Serialization" />
|
<Topic id="ConditionalProperties" visible="True" title="Conditional Property Serialization" />
|
||||||
<Topic id="ContractResolver" visible="True" title="Serialization using ContractResolver" />
|
<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>
|
||||||
<Topic id="LINQtoJSON" visible="True" title="LINQ to JSON">
|
<Topic id="LINQtoJSON" visible="True" title="LINQ to JSON">
|
||||||
<Topic id="ParsingLINQtoJSON" visible="True" title="Parsing JSON" />
|
<Topic id="ParsingLINQtoJSON" visible="True" title="Parsing JSON" />
|
||||||
|
|||||||
@@ -98,6 +98,19 @@ namespace Newtonsoft.Json.Tests.Documentation
|
|||||||
get { return TraceLevel.Verbose; }
|
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)
|
private LogLevel GetLogLevel(TraceLevel level)
|
||||||
{
|
{
|
||||||
switch (level)
|
switch (level)
|
||||||
@@ -114,18 +127,6 @@ namespace Newtonsoft.Json.Tests.Documentation
|
|||||||
return LogLevel.Trace;
|
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
|
#endregion
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user