Added optional file logging