logging and query template.