New function to activate or deactivate query logging