title: Dynamically change the LogDevice of Ruby Logger
body: <p>Is it possible to dynamically change the <code>LogDevice</code> of Ruby <code>Logger</code>?</p>
  
  <p>If so, it would allow for some un-obtrusive changes to my existing codebase.</p>
  
  <p>Currently Ruby <code>Logger</code> uses <code>StringIO</code> as the <code>LogDevice</code>:</p>
  
  <pre><code>@logDevice = StringIO.new("", "r+")
  @log = Logger.new(@logDevice) // a reference to this is used by many objects
  // both are instance vars
  
  ...
  
  @log.info('some log') // Logging activity
  
  ...
  
  // Before program ends, transmit logs to a server
  </code></pre>
  
  <p>Can <code>LogDevice</code> be dynamically changed to continue logging to a file?
  (dynamic change because initially the filename is not known.)</p>
  
  <p>Or if log device cannot be change can the <code>StringIO</code> object start writing to a file?</p>
  
  <p>Instead of doing the above, I could write to a temporary log file, but wanted to check if the above can be done because it would be a less obstrusive change to the existing codebase.</p>