Monday, December 10, 2007

Merb Tidbit: Logging

Merb has it's handy built in Mongrel server, so you can easily start it up while developing with:

merb
However, you may wonder "Why isn't it generating any log files?"

Well actually it is, but the deal is they are all being output to the command line instead of being written to a file in the log/ directory. If you want to have them written to a log file, you need to start Merb up as a daemon. This is simply done like so:
merb -d
Now your logs will be written to the log/ directory. To stop the background merb process, use the -k PORT flag. For example, if you are running on port 4000 (which is the default) you would use:
merb -k 4000
You can also control the level of detail to be logged using the -l flag. Optional logging levels which can be passed with the -l flag include: DEBUG, INFO, WARN, ERROR and FATAL.

That's today's Merb tidbit. Happy Merbing!

2 comments:

  1. daemon mode '-d' doesn't work on Windows, but the -l DEBUG did what I wanted - I can see ActiveRecord's SQL output once again. Thanks!

    ReplyDelete
  2. Thanks, Justin.

    Such a simple thing but very helpful.

    ReplyDelete