C
C#3w ago
hutoanhill

Looking for a logging solution

Working on ASP.NET program.
I have a lot of stuff i want to do for logging. First off i want to log every time an endpoint is accessed, who accessed it, when it was accessed what info was passed to the api and the datatype that the endpoint returned. Then there's all the stuff i see in the command line. i would also like to log this stuff. finally i want to be able to query some kind of database of the logs to get data about what's going on, so ideally logs have types and all that jazz. Anyone know any pre existing solutions for this?
30 Replies
hutoanhill
hutoanhill3w ago
what discord died....
Jimmacle
Jimmacle3w ago
ASP.NET specifically or ASP.NET Core?
hutoanhill
hutoanhill3w ago
i swear there was body text...' ASP.NET core? i think...
Jimmacle
Jimmacle3w ago
so you can use the built in logging framework and configure it more to capture what you need
hutoanhill
hutoanhill3w ago
quick question can you see the body of my post?
Jimmacle
Jimmacle3w ago
yes that's how i know you're asking about ASP.NET Core
hutoanhill
hutoanhill3w ago
no like the inital post
hutoanhill
hutoanhill3w ago
No description
hutoanhill
hutoanhill3w ago
No description
Jimmacle
Jimmacle3w ago
see above message
hutoanhill
hutoanhill3w ago
werid... i cant see the body of my own post... there it is.
Jimmacle
Jimmacle3w ago
so you already have a logging framework built in, you can add middleware to log more information about the request and response, then as far as a searchable log database goes you'd want a log aggregeator like seq or something similar
hutoanhill
hutoanhill3w ago
yes i am using core.
Jimmacle
Jimmacle3w ago
the stuff that shows up in your console is already coming through the logging system, it's just not configured to be written anywhere except the console most likely
hutoanhill
hutoanhill3w ago
something like this? app.UseMiddleware<ApiLoggingMiddleware>();
Jimmacle
Jimmacle3w ago
more or less
hutoanhill
hutoanhill3w ago
should ApiLoggingMiddleware be implimenting an interface?
Jimmacle
Jimmacle3w ago
it should be implemented in a way that lets you use it as middleware
hutoanhill
hutoanhill3w ago
the issue is i want to save it in such a way i can easily query it, like in a json object or somthing.
Jimmacle
Jimmacle3w ago
yes, structured logging to seq or a similar aggregator will let you do that
hutoanhill
hutoanhill3w ago
um... hows that
Jimmacle
Jimmacle3w ago
look at the docs on writing middleware i personally replace the microsoft logging with serilog and use its sinks to send the logs to seq
hutoanhill
hutoanhill3w ago
i did have serilog working, but it was just writeing to a txt file, not what i wanted.
Jimmacle
Jimmacle3w ago
serilog can write to tons of different targets https://github.com/serilog/serilog/wiki/provided-sinks
hutoanhill
hutoanhill3w ago
thxx
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
hutoanhill
hutoanhill3w ago
this looks huge
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX3w ago
If you have no further questions, please use /close to mark the forum thread as answered
hutoanhill
hutoanhill2w ago
i swear i will come back to this eventualy :)
Want results from more Discord servers?
Add your server