I am developing a simple web service with Sinatra/Thin on Windows
In my app, I have the following to enable logging to a file:
Dir.mkdir('log') unless File.exists?('log')
use Rack::CommonLogger, File.new('log/access.log', 'w')
When the server starts up, the file is created. However, nothing is written to the file until I shut down the server.
On the other hand, when I use Logger, like this:
logger = Logger.new('log/access.log', 10, 1024000)
use Rack::CommonLogger, logger
it does not even write entries to the log file, except for a line that says:
# Logfile created on 2013-02-13 11:23:45 +0200 by logger.rb/31641
What I need is:
- Log entries to be written immediately
- To be able to Logger for the log rotation feature