title: Modifying Rails logging level per request on production server
body: <p>There is so little information about managing log levels out there, that I decided to ask this question to get your opinion on this. </p>
  
  <p>The motivation behind this question is to find out the optimal way of setting the log levels in production without restarting the app server.</p>
  
  <p>First thing that I can think about is putting a method in an <code>application_controller</code> which will check for certain url parameter existence i.e <code>log_level=debug</code> and turn that logging level if it exists for the life of the request.</p>
  
  <p>This has one drawback, which is that your user or you have to modify the url to turn on the logging. Another one might be that any underlying calls you make i.e via javascript call to you api also needs to be aware of this change and pass this <code>log_level</code> url param.</p>
  
  <p>Another thing I can think is putting a file to your Rails root directory called <code>debug_log_level</code> or something similar, then on each request start check if that file exists. When it does, checking is the filename actually containing the valid logging level, and when it does turning that logging level on.</p>
  
  <p>Drawback of this one is that you might have several instances on different boxes, so you would need to go on each box to make this change.</p>
  
  <p>Another one could be to make a call to a database and same the same flow like for file.</p>
  
  <p>Alternatively you could set an environment variable for log level, and use that to set the log level, but that would require the app server restart.</p>
  
  <p>How are you managing this in your production environment? There has to be a smarter way to do this by now, is there? </p>