How to Only Log API Calls?

It seems the request logger is somewhat zealous in what it tries to log all requests coming in, which creates a mass of entries very quickly when loading the OpenAPI/Swagger documentation. Even just loading the main page creates several entries. As we are only interested in logging actual API calls, how can we ignore the “noise?”

My configuration is:

ExcludeRequestDtoTypes = new System.Type[] { null, typeof(OpenApiSpecification), typeof(RequestLogs)}

but, null requests are still attempting to be logged (confirmed in the debugger that the code is proceeding even if request type is null). Further, I am now also getting requests of type AspNetRequest (this wasn’t happening a few weeks ago - I assume some change on your side).

I can of course add AspNetRequest to my list of Excludes, but that doesn’t solve for nulls. Additionally, if the request types will be changing, perhaps it isn’t ideal to ask all of us that only want to log API requests to maintain our own exclude lists that facilitate that.

Can you provide more information how do you call your services to generate “null” request type which are logged by RequestLogger?

Hitting f5 on the project loads the default service stack site page. Then, clicking the “Swagger UI” link there takes us to the swagger page. Those two activities result in many many log entries. With the version of SS published today, it seems all15+ requests are of type AspNetRequest. As of the previous version there was a mix, including null requests and OpenApiSpecification.

I’ve added a LimitToServiceRequests option to RequestLogsFeature which defaults to true so it should only Log Service Requests by default.

This change is available from v4.5.13 that’s now available on MyGet.

1 Like