Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not seeing custom properties #11

Closed
softsolutionsau opened this issue Jan 5, 2022 · 4 comments
Closed

Not seeing custom properties #11

softsolutionsau opened this issue Jan 5, 2022 · 4 comments

Comments

@softsolutionsau
Copy link

Hi there Matthais,

Firstly, thank you so much for putting this package together, its going to be magnificent as soon as I can get it working! :)

I have done exactly as you have described in the README, except I have included app.UseAppInsightsHttpBodyLogging(); outside of my if (env.IsDevelopment()). I am not using any configuration options (default setup only).

When I look at my App Insights, I do not see the ResponseBody/RequestBody custom properties:
Running on Azure:
image
Running on Local:
image

Any ideas what I might be doing wrong? Your help would be very much appreciated!

Thanks again,
Shai

@matthiasguentert
Copy link
Owner

Dear Shai, thanks for reaching out!

I can see from your screenshot, that you have POSTed to Account/Login which resulted in a status code of 200.

By default, only, failure status codes (4xx, 5xx) and POST, PUT, PATCH verbs are getting logged (see BodyLoggerOptions.cs for details). If you'd also like to log a status code of 200 you'd have to add it to the list of HttpCodes while registering the service

using Azureblue.ApplicationInsights.RequestLogging;

var builder = WebApplication.CreateBuilder(args);

// ...
builder.Services.AddAppInsightsHttpBodyLogging(o => 
{
    o.HttpCodes.Add(StatusCodes.Status200OK);
});

// ... 
var app = builder.Build(); 

// ... 
app.UseAppInsightsHttpBodyLogging(); 

Please let me know if that solved your issue!

@softsolutionsau
Copy link
Author

Oh wow, I didn't notice that we were only looking failure codes. That's great, but I still have the issue. Below is a failed attempt at the same endpoint. I must be doing something silly, but I just can't seem to find it...sorry to be a pain.

image

@matthiasguentert
Copy link
Owner

matthiasguentert commented Jan 5, 2022

Hm, then I guess the call to app.UseAppInsightsHttpBodyLogging(); is happening very late in the middleware-configuration-part of your Startup.cs / Program.cs and that it gets short-circuited before it can reach the logger.

Please put the call to app.UseAppInsightsHttpBodyLogging(); as early as possible in your list of middleware components. The order they occur matters. You might also want to have a look here: Middleware order

@softsolutionsau
Copy link
Author

Sir, you are a legend, that is exactly what it was. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants