Application exception handling and logging

- Added application exception handling and logging functionality.