How can I get the LogCat before my phone restarts? Recently my phone keeps on restarting randomly through the day, and I would like to trace what is the cause for that.

I tried this app https://play.google.com/store/apps/details?id=org.jtb.alogrec but it doesn't seem to work in Android 6 (It creates the file but it doesn't write anything)

Any ideas on how can I get the logcat or how can I identify the problem?
If the reboots are caused by kernel panics (sometimes the case), you can get the last_kmsg file. It's located at /proc/last_kmsg. This file gets reset every time you restart your phone, so you'll have to grab it soon after a reboot.

Look at the bottom of the file to see why the phone is rebooting. If it's a normal shutdown from an app, it may point to the app that initiated the shutdown. If it's a kernel panic, hopefully it'll tell you what's happening.