Fixing default log file name selection

Presently, when selecting a default log file name, `filename` ends up as a dangling pointer, since the temporary `fileBuilder.str()` will be destroyed at the end of the expression - see [Notes](http://en.cppreference.com/w/cpp/io/basic_ostringstream/str#Notes). This actually causes issues on OS X, where a log file doesn't get created unless the name is explicitly specified. This patch is one way to fix the issue without having to do any explicit memory management - there might be better ones.