The other messages indicate a number of excellent issues when debugging. I have some personal opinions about debugging that may be of interest.
1. Don't assume anything is correct. Normally it is the thing you assume to be correct that will make you search for days/weeks. Use a careful process of elimination to determine where the problem exists, such as checking lights on sensors/inputs/programming software for electrical problems, expected operation modes, etc.
2. If you understand the program you are debugging, follow the sequence of operation and determine where it deviates from the expected. Trace this problem to where it deviates and fix the problem.
3. Remember that what you see on the screen in PLC programing software is not instantaneous, and events with a short period are rarely displayed. Find ways to track fast events, such as latches.
4. The worst approach to fixing problems is trial and error. If you don't know what has caused the problem, semi-random program changes are very inefficient and often result in unreliable patches.
5. The best method to reduce debugging is to carefully design the program before writing any code. A corollary is that the best debuggers are those who get a lot of practice because they start programming without planning.
6. Learn what a kludge is and only apply it when necessary.
7. Design and build programs in sections/modules if possible so that they may be added/tested in sections. This reduces the scope of errors to smaller sections of the program, and therefore easier to locate.
8. Finally, a good programmer may be able to debug well, but they know enough to minimize it through careful program design.