If you're running your program with cron, any output (including errors) will be mailed to you (I'm guessing that you're running the program from root's crontab, since root is getting the mail).
You can redirect
your standard output and/or standard error in the crontab entry. Here's an example in sh syntax: