I have worked probably 1,000 night shifts as a physician.
There are people for whom it is easy to stay up all night, and there are people for whom it is so painful it is impossible. I am somewhere in the middle. Because of this, and because I have to remain alert and ready for emergencies through the night, and with the advantage of understanding some physiology, I have watched myself, and experimented, and found certain techniques that work for me. These are not guaranteed to work for you, of course.
1. Hydration. My impression is that one cause of fogginess overnight is not getting adequate circulation to the brain. One cause of reduced circulation is dehydration, which is easy to develop overnight. We sweat when we work and we drink caffeine which may act as a diuretic. Lots of water seems to help.
2. Compression stockings on the legs. These push blood back toward the body, and keep the blood circulating. They also seem to prevent leg cramps.
3. Vitamin D: Living in the dark, we have to make sure we get enough of this vitamin, which is a steroid hormone actually, made in the skin by sunlight. With no sun, you have to take a pill. At least 2000 units a day.
4. Coenzyme Q10. I have no data on this, but this seems to increase energy.
5. Sleep in a room that is absolutely dark. Any daylight coming in through the windows, or any artificial light, reduces the effectiveness of sleep.
6. Avoid carbohydrates overnight. There is nothing that more reliably puts me to sleep than two pieces of pizza at 2 a.m. Small protein meals.
7. Sleep time is sacred. Make sure your family or roommates understand that waking you up at 11 a.m. is like you waking them up at 3 a.m. People have a really tough time understanding this.
8. Spend a day a week in total relaxation, if you can. Let yourself sleep or stay awake whenever you want. Obviously if you have children this is a problem but maybe your significant other can help. You won't get enough sleep during the days after your shifts and you have to catch up sometime.
9. Exercise before the night shift. Even walking around the block for 15 minutes makes a difference.
10. Judicious use of caffeine. Some caffeine is OK, especially during the really difficult hours (3 to 5 a.m. for me). But too much will dehydrate you, and you can crash from it after a few hours.
These are the things I have found after years of self-observation, and trial and error. I hope they help you.