Catch application/System exception

Hi team,

Please help me out how to log system or application exception to log file.

Thank you
Mahaling Patil