Adding to Harish's answers,
Logs are written in any code to find the reason for the error/warning caused by the program.
For instance, if any program is not being run, the logs comes handy in narrowing down the problem and to resolve the issues at the earliest.
Taking automatic payment run example - u have proposal and payment logs. The reasons are to find why a proposal or payment has not been happ. If such logs are not in place, user cannot find the reason and hence the solution.
<i>Pls. assign points, if useful</i>