Open log only once and fallback to stdout when unable to open

Make QFile static to avoid opening and closing it for every log
message which will be rather slow.

Also, if it's not possible to open the log file fallback to
stdout to avoid losing log messages.
This is useful in test mode which runs as normal user.
Merge pull request #152 from plfiorini/log

Open log only once and fallback to stdout when unable to open