fix logging to database