log errors and trace info to db

Also requires a sql import - logs.sql.