Others have answered the question well and pointed to some good example code.
Coding it yourself is fairly simple. The strategy generally is:
- catch appropriate signals
- launch a separate crash reporter app that lives inside your application's bundle
- the crash reporter app then finds the latest crash log entry for your app and sends it to you via whatever method you desire (POST, email, etc)