When I router reboot automatically. How to find error message.
I am not sure that I understand your question very well. When you say router reboot automatically am I correct in assuming that you mean that software error forces the router to reload? If that is the question then one potential answer is that the router may have created a crashinfo file when it rebooted and the error message may be in the crashinfo file. If it is a software forced reboot there may also be some helpful information in the show version output or in the output of show stacks.
Or your question may be that when the router reloads any messages in the syslog buffer are gone and you want to see what message the router logged before the crash. If that is the question then a potential answer could be to send the syslog messages to a syslog server so that you can look up messages about an event after the event has happened. Or another alternative (if you do not have a syslog server) might be to put a PC on the console of the router. The syslog messages would still be in the screen buffer on the PC and you might be able to scroll back and see them.
If these are not the answers that you are looking for then perhaps you can clarify your question a bit.