【发布时间】:2022-12-27 21:15:38
【问题描述】:
Could somebody describe how achieve those goal: I have http client with methods. Sometimes server start send strange data, and I need to capture request and response. Injecting logger to every method in httpClient sounds awful. I need this log sometimes and amount of log information can be huge. So i need to switch logging for precise httpclient method capture data i.e. for a day and turn off log's without recompiling application. What I'm thought I can register delegate handler which get as option data from appsettings json where I store something which can identify my methods that should be logged. I think somebody already did that. And maybe I can use ready-made solution. If not I can't completely invent a way how map data from appsettings.json to info that delegate handler has. I mean what way i should store in example full URL or maybe some another data on what i can identify what type of http request sended.
【问题讨论】:
标签: c# http delegates .net-7.0