improve logfile selection; add logfilename to output