This is another question that really requires you to be much more specific about what exactly you require, before anyone can supply a useful answer. At the generic level of the question as you have posed it, pretty much every commercial PLC has some kind of diagnostic provision, but invariably, it is up to you to understand what that provision is and to make use of it. So, for example, some
PLCs will automatically run interrupt routines on the occurrence of faults, but it is up to you to set those routines up and to fill them with useful code. Another common facility is diagnostic bits and words that can tell you all manner of things about what is going on in the PLC as it executes the code, but again it is up to you to be aware of those bits and words and to make use of them in the most telling way. That is about as much as I can say at the generic level of your question.