Testing, Debug and Deployment Tools

When you develop the apex code in a sandbox and through the developer console and logs, debug it. After Unit test of your code, then distribute it to customers using packages.

Debugging Apex : The first key is to ensure you have system.debug messages in your code. Then to output those debug messages, you can use the Debug Logs (mentioned in the previous post), or System Log in the browser. You also can look at the debug output when executing your test methods.