Write to syslog (if running on a Unix system), redirect syslog to both a rotating logfile and a database.
The logfile is always useful for realtime monitoring using standard unix tools such as tail which can be combined with grep etc.
syslog can redirect log messages to different servers, multiple targets etc.
It is not always wise to build in database dependencies in an application, if the DB fails what happens to the logging?
How to you log DB failures if your only logging goes to the DB?