Is it better to log to file or database?

前端 未结 5 1023
醉梦人生
醉梦人生 2021-01-30 22:21

We\'re still using old Classic ASP and want to log whenever a user does something in our application. We\'ll write a generic subroutine to take in the details we want to log.

5条回答
  •  余生分开走
    2021-01-30 23:13

    Looking at the responses, I think the answer may actually be both.

    If it's a user error that's likely to happen during expected usage (e.g. user enters an invalid email etc.), that should go into a database to take advantage of easy queries.

    If it's a code error that shouldn't happen (can't get username of a logged in user), that should be reserved for a txt file.

    This also nicely splits the errors between non-critical and critical. Hopefully the critical error list stays small!

    I'm creating a quick prototype of a new project right now, so I'll stick with txt for now.

    On another note, email is great for this. Arguably you could just email them to a "bug" account and not store them locally. However this shares the database risk of bad connections.

提交回复
热议问题