Add support of logging and running in background (daemon).