I think there is a specific module for this but can no longer figure out where I saw it ...
Maybe you're interested in disk_log or error_logger?