C
C#3mo 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
hutoanhillOP3mo ago
what discord died....
Jimmacle
Jimmacle3mo ago
ASP.NET specifically or ASP.NET Core?
hutoanhill
hutoanhillOP3mo ago
i swear there was body text...' ASP.NET core? i think...
Jimmacle
Jimmacle3mo ago
so you can use the built in logging framework and configure it more to capture what you need
hutoanhill
hutoanhillOP3mo ago
quick question can you see the body of my post?
Jimmacle
Jimmacle3mo ago
yes that's how i know you're asking about ASP.NET Core
hutoanhill
hutoanhillOP3mo ago
no like the inital post
hutoanhill
hutoanhillOP3mo ago
No description
hutoanhill
hutoanhillOP3mo ago
No description
Jimmacle
Jimmacle3mo ago
see above message
hutoanhill
hutoanhillOP3mo ago
werid... i cant see the body of my own post... there it is.
Jimmacle
Jimmacle3mo 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
hutoanhillOP3mo ago
yes i am using core.
Jimmacle
Jimmacle3mo 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
hutoanhillOP3mo ago
something like this? app.UseMiddleware<ApiLoggingMiddleware>();
Jimmacle
Jimmacle3mo ago
more or less
hutoanhill
hutoanhillOP3mo ago
should ApiLoggingMiddleware be implimenting an interface?
Jimmacle
Jimmacle3mo ago
it should be implemented in a way that lets you use it as middleware
hutoanhill
hutoanhillOP3mo 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
Jimmacle3mo ago
yes, structured logging to seq or a similar aggregator will let you do that
hutoanhill
hutoanhillOP3mo ago
um... hows that
Jimmacle
Jimmacle3mo 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
hutoanhillOP3mo ago
i did have serilog working, but it was just writeing to a txt file, not what i wanted.
Jimmacle
Jimmacle3mo ago
serilog can write to tons of different targets https://github.com/serilog/serilog/wiki/provided-sinks
hutoanhill
hutoanhillOP3mo ago
thxx
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
hutoanhill
hutoanhillOP3mo ago
this looks huge
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX3mo ago
If you have no further questions, please use /close to mark the forum thread as answered
hutoanhill
hutoanhillOP3mo ago
i swear i will come back to this eventualy :)
Want results from more Discord servers?
Add your server