How can I change the log-level at runtime without restarting or
creating
new forks?
I was thinking of having a controller that - with proper authentication-
allows a user to set the log level of a specific server, i.e. the server
the controller resides on.
Because we are in a threaded environment changing the log level of one
thread would not affect the others (correct me if I am wrong) so I was
thinking I write the new log level to a file.
To not waste time reading the file on each log request I was thinking
about
setting a “global” persistent-across-requests variable that has the time
of
the last check and if more than 10s elapsed it reads the file again and
sets the log level to the value in the file, if this is a valid one.
The usecase is that let’s say 20 servers are running and an API call may
return corrupted data or has a huge performance spike. So now I want to
turn on a logging level that shows me i.e. the queries that were
executed,
and if that does not help, show even more data that is saved on “debug”
level. When there are no problems I want to restrict the logging to
“error” so no unnecessary logging takes place and wastes cpu/space.
Any thoughts on this method or if there is a better one?