Added trace switch to control log output.(nw)