changed logging SQL to use a statement builder