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

Add ${aspnet-request-posted-body} - log posted request body/payload #103

Closed
304NotModified opened this issue Feb 10, 2017 · 14 comments · Fixed by #339
Closed

Add ${aspnet-request-posted-body} - log posted request body/payload #103

304NotModified opened this issue Feb 10, 2017 · 14 comments · Fixed by #339

Comments

@304NotModified
Copy link
Member

304NotModified commented Feb 10, 2017

Render posted value

Tricky because we need to reset the inputstream and set it back?

Also limit the chars (e.g. when a file is uploaded)

@304NotModified
Copy link
Member Author

code non-core:

var originalStream = new StreamReader(HttpContext.Current.Request.InputStream);
var content = originalStream.ReadToEnd();

@304NotModified 304NotModified changed the title Add ${aspnet-postedvalue} Add ${aspnet-postedvalue} - log posted body Mar 14, 2018
@304NotModified 304NotModified changed the title Add ${aspnet-postedvalue} - log posted body Add ${aspnet-postedvalue} - log posted request body/payload Mar 14, 2018
@neoKushan
Copy link

Is there an update on this one? I came here via Google to one of the closed issues and the link in this thread is dead. Not sure?

@304NotModified
Copy link
Member Author

Nope, PR accepted ;)

I will try to find a working link...

@304NotModified
Copy link
Member Author

link updated!

@304NotModified
Copy link
Member Author

Is there an update on this one

-> #339

@304NotModified 304NotModified changed the title Add ${aspnet-postedvalue} - log posted request body/payload Add ${aspnet-request-posted-body} - log posted request body/payload Feb 11, 2019
@cbjpdev
Copy link

cbjpdev commented Mar 18, 2019

Hi, Is this feature available in NLog.Web.AspNetCore 4.8.0? I can see the code https://github.com/NLog/NLog.Web/blob/master/NLog.Web.AspNetCore/LayoutRenderers/AspNetRequestPostedBody.cs, But I am clueless how to use it?

@304NotModified 304NotModified added this to the 4.8.1 milestone Mar 18, 2019
@304NotModified
Copy link
Member Author

Hi! This is fixed for 4.8.1, but not released yet. I will try to release this, this evening. (utc +1 here)

When released, you could use ${aspnet-request-posted-body}

@cbjpdev
Copy link

cbjpdev commented Mar 18, 2019

Thank you very much.

@304NotModified
Copy link
Member Author

@cbjpdev
Copy link

cbjpdev commented Mar 19, 2019

Thanks, I applied, It works very well.

@304NotModified
Copy link
Member Author

Thanks for the confirmation 👍

@snakefoot
Copy link
Contributor

#754 has reverted this in NLog.Web ver. 5.0

@snakefoot
Copy link
Contributor

snakefoot commented Jul 25, 2022

Thanks to @bakgerman now NLog.Web.AspNetCore v5.1 re-introduces ${aspnet-request-posted-body} with help from middleware:

app.UseMiddleware<NLog.Web.NLogRequestPostedBodyMiddleware>();

It is no longer necessary to explicit call context.Request.EnableBuffering(); as it is handled by the middleware.

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

Successfully merging a pull request may close this issue.

4 participants