Ubuntu server crash logging

i have an ubuntu server, i think it is 16,4 but not sure. i run unifi video on this, randomly the server just dies or crashes so i manually have to restart it. is there a way to get a log and se the reason why it turns of?
the hardware is an lenovo desktop. worked fine for a long time. i have a feeling it mabe culd be the temperature that is the reason.
but as i seed, can i make an bash script (or is there already) an that i can use to se why??

Start by looking in /var/log/ at ‘syslog’ and ‘messages’ and perhaps the UniFi logs that should be in there as well.

You can also make it easier to parse by using lnav

Lnav was awesome hehe, but i did not find anything useful. the unifi video stopped working on the 25 this month last time. and in the syslog there are only 5 rows from the 25. none interesting. the next entry in the log is when i pulled the plug on the computer and restarted it today. the computer was on, but there is a gap in all the logs between 25 about 03:00 and the 26 19:50 when i restarted it.

You can configure getting a crash dump on kernel panic (I enjoy the luxury of this being pre-configured for me so I won’t pretend to tell you how). If it isn’t already you might want to enable crashing on the system running out of memory; the system going OOM is the single most common reason I see machines lock up. Actually, now that I think about it. If the host is monitored and that monitoring has a handy graph, and OOM is the cause, you can probably watch it go OOM right up until it dies.