Added feature: Log error and output to files