gordon-cs / gordon-360-api

The 360° Gordon Experience
12 stars 7 forks source link

Log API requests for future machine learning features #940

Open russtuck opened 1 year ago

russtuck commented 1 year ago

I did a little searching for best practices in handling .NET logs. Here are some notes on what I found (with references at the bottom).

  1. They were all focused on using logs to debug errors in production. That's great, but it's not what we're doing here. Logging for debugging might include this, but would also include other things.

  2. Logging to a database is one of the top 3 options. Another is logging to a separate service that other things can listen to if they want the logs. And of course the other is log files.

We could adopt one of the log saving systems recommended in the references below, but then we'd also need to figure out how to get the data into a machine learning system. Or we can simply save it into the DB, where it's also easy to query it for ML.

My vote is to start logging to the database, and see how it goes. If the DB shows signs of stress as a result, we can disable it and then try another option.

References: https://michaelscodingspot.com/logging-in-dotnet/ https://stackify.com/csharp-logging-best-practices/ https://raygun.com/blog/c-sharp-logging-best-practices/

Originally posted by @russtuck in https://github.com/gordon-cs/gordon-360-api/issues/968#issuecomment-1648785314

russtuck commented 6 months ago

1036 is a great first step, but it doesn't log all the needed data, and doesn't save it long enough to be useful.