A good article is written on this at Effective logging practices ease enterprise development.
The crux is:
- Know the need of logging.
- Understand the options available and which suits you best (varies with Platform/OS/etc)
- Plan the strategy in advance before implementation.
- Keep reviewing and make the changes.