C # Trace truncates long messages

In C #, I turned on tracing and the network trace source.

    <?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  <system.diagnostics>
    <sources>
      <source name="System.Net" tracemode="includehex" maxdatasize="1024">
        <listeners>
          <add name="System.Net"/>
        </listeners>
      </source>
    </sources>
    <switches>
      <add name="System.Net" value="Verbose"/>
    </switches>
    <sharedListeners>
      <add name="System.Net"
        type="TraceTest.StringWriterTraceListener, TraceTest"
        initializeData="myfile.log"
      />
    </sharedListeners>
    <trace autoflush="true" indentsize="4" />    
  </system.diagnostics>
</configuration>

But longer messages are truncated (long, like 12Kb / 30 lines, not for long, like 1GB!), So I get into a situation where only some of the most dangerous headers are logged.

How to fix it?

Or do you know a book or some resource that explains .Net tracing and debugging in great detail?

Log Example:

            System.Net Information: 0 : [1204] Connection#63291458 - Received headers
        {
        Transfer-Encoding: chunked
        Connection: keep-alive
        Keep-Alive: timeout=10
        Content-Type: text/html; charset=windows-1251
        Date: Mon, 04 Jul 2016 17:50:33 GMT
        Set-Cookie: uid=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0,uid=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/,uid=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; domain=.zamunda.net,pass=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0,pass=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/,pass=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; domain=.zamunda.net,bitbucketz=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0,bitbucketz=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/,bitbucketz=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; domain=.zamunda.net,cats=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0,cats=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/,cats=deleted;
expires=...}.

This is one message, the method Writeis somehow TraceListenercalled whit, which is one message as a parameter that is truncated ("...".) At the end)

Also, cookies are badly written and almost undetectable, but I can live with it ...

Yes, unfortunately, in addition to interfering with System.dll or using some odd and complex type inheritance, there is nothing to do.

+4
1

.

ParseResponseData, :

Logging.PrintInfo(Logging.Web, this, SR.GetString("net_log_received_headers", new object[]
    {
        this.m_ResponseData.m_ResponseHeaders.ToString(true)
    }));

SR GetString . net_log_received_headers - Received {{{0}}}. ILSpy :

public static string GetString(string name, params object[] args)
{
    SR sR = SR.GetLoader();
    if (sR == null)
    {
        return null;
    }
    string @string = sR.resources.GetString(name, SR.Culture);
    if (args != null && args.Length != 0)
    {
        for (int i = 0; i < args.Length; i++)
        {
            string text = args[i] as string;
            if (text != null && text.Length > 1024)
            {
                args[i] = text.Substring(0, 1021) + "...";
            }
        }
        return string.Format(CultureInfo.CurrentCulture, @string, args);
    }
    return @string;
}

:

if (text != null && text.Length > 1024)
{
    args[i] = text.Substring(0, 1021) + "...";
}

, , 1024 .

ResponseHeaders / , SR.GetString, .

SR.GetString , . , , - .NET Reference Source

maxdatasize , Dump Logging. , , , :

int maxDumpSizeSetting = Logging.GetMaxDumpSizeSetting(traceSource);
if (length > maxDumpSizeSetting)
{
    Logging.PrintLine(traceSource, TraceEventType.Verbose, 0, string.Concat(new string[]
    {
        "(printing ",
        maxDumpSizeSetting.ToString(NumberFormatInfo.InvariantInfo),
        " out of ",
        length.ToString(NumberFormatInfo.InvariantInfo),
        ")"
    }));
    length = maxDumpSizeSetting;
}
+3

All Articles