Conver logdir to logfile

Make it possible to specify the file where the logs will be written.
Also put the parameter logfile only the commands that are relevant to
it.