您将无法获得额外的数据。
您的典型示例来自一个名为的私有方法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资源字符串是收到标头 {{{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
所有的努力和记忆都被浪费了。
When SR.GetString
参与日志记录,您将面临数据被截断的风险。了解发生这种情况的唯一方法是检查装配体或.Net 参考源 http://referencesource.microsoft.com/#System/net/System/Net/_Connection.cs,2557
The 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;
}