Is there a way to add custom logger for API calls made through Semantic Kernel? #6714
-
We would like to have our custom logger log events for api calls made through semantic kernel (OpenAI, plugins/tools, etc). We do have dependency calls logged in our infrastructure, but we'd like to have custom logging in the code so we can have more control over it. Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
dmytrostruk
Jun 14, 2024
Replies: 1 comment 6 replies
-
@prajwalpyakurelMS Could you please specify which SK language you are using? This will help us to provide related examples. Thanks! |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@prajwalpyakurelMS You can use
HttpClientHandler
and it should work correctly, but I think for your scenarioDelegatingHandler
is a recommended way, because you can create a chain of delegating handlers where each handler could be responsible for logging, authentication. retry policies etc, whileHttpClientHandler
sits at the end of this chain and performs actual HTTP communication. This applies to HTTP communication in ASP.NET Web API, but you can use the same strategy in your app:https://learn.microsoft.com/en-us/aspnet/web-api/overview/advanced/http-message-handlers