writing to stdout and to log file