logging and connection to database