How to use rethrow and log the exception message in main?

Hi,

Can anyone suggest how to log exception message in try block using rethrow?
Please upload the Sample code if possible.

Thanks