Cant write more than 4096 bytes into custom IIS lo

2020-05-06 18:04发布

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"

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.

enter image description here

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

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

  1. set maxCustomFieldLength to 4096 I only get 2048 bytes in the log file.
  2. increase maxCustomFieldLength to 65536, I only get 4096 bytes in the log file.

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.

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

1条回答
何必那么认真
2楼-- · 2020-05-06 18:53

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. hooks into Begin_Request
  2. reads the raw cookies string from the Request Headers
  3. splits it into chunks < 4k (preserving entire cookies as whole items, name and value)
  4. write the chunks into custom request headers
  5. configure IIS with a bunch of new custom fields to drop the new request headers into the iis logs
查看更多
登录 后发表回答