how to view cuda log in ubuntu before automatic reboot.

My pc restarts sometimes when working with gpus. how can i view the log files exactly before the automatic reboot?

Regards
milton