fix tracetemplate detection logic and logging (fix #1386)