无法将超过4096个字节写入自定义IIS日志字段 [英] Cant write more than 4096 bytes into custom IIS log field

查看:149
本文介绍了无法将超过4096个字节写入自定义IIS日志字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据此文档可以将Windows Server 2016上的IIS 10配置为写入自定义字段,只要"自定义字段中添加的数据总量不能超过65,536字节"

According to this documentation you can configure IIS 10 on Windows Server 2016 to write custom fields as long as "The total amount of data added in custom fields cannot exceed 65,536 bytes"

我已经配置了一个自定义字段,将Header中的cookie和服务器变量中的另一个cookie写入日志,这很好用.

I have configured a custom field to write the cookies from Header and another from the server variable into the logs and this works just fine.

但是无论我将maxCustomFieldLength设置为什么值,都只会将4096字节写入日志.

But only 4096 bytes are written to the log no matter what value I put in maxCustomFieldLength.

当我在Cookie中发送8k数据时,我:

When I send 8k of data in the cookies and I:

  1. 将maxCustomFieldLength设置为4096,我在日志文件中仅获得2048个字节.
  2. 将maxCustomFieldLength增加到65536,我在日志文件中只得到4096个字节.

我已经使用fiddler验证了浏览器请求正在发送完整的8k cookie值,并且它们没有在客户端将其值截断为4096.

I have verified using fiddler that the browser requests are sending the full 8k cookies value and that they are not truncating the value to 4096 at the client.

有什么主意,为什么IIS会将cookie值截断为4096,而不是将maxCustomFieldLength大于4096?

Any ideas why IIS is truncating the cookies value to 4096 and not respecting maxCustomFieldLength greater than 4096?

推荐答案

现在已经对此进行了广泛的研究,这是我发现将所有Cookie记录为<的标准IIS日志文件时的唯一方法. 4k是要编写一个自定义HttpModule:

Having done extensive research into this now, the only way I have found to get all the cookies logged to the standard IIS log files when they are < 4k is to write a custom HttpModule that:

  1. 加入Begin_Request
  2. 从请求标题中读取原始cookie字符串
  3. 将其拆分为大块< 4k(将整个cookie保留为整个项目,名称和值)
  4. 将这些块写入自定义请求标头
  5. 使用大量新的自定义字段配置IIS,以将新的请求标头放到iis日志中

这篇关于无法将超过4096个字节写入自定义IIS日志字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆