Home >Backend Development >PHP Tutorial >Linux Notes (67) - Detailed explanation of nginx log files
Log file format
Open nginx default configuration file nginx.conf
us Use the log_format directive to specify the format of the log file. Everything starting with $ is a variable. The meaning of these variables is as follows:
Then we pass access_log directive to specify the location of the log file
The variables in the red box in the above picture can be defined by yourself
If you want the above configuration to work, remove the # sign in front
If you want to turn off the log function, use access_log off
log file Cutting
In order to facilitate management, we often need to separate the logs according to time, such as one log file per day, so what should we do?
Manual cutting
Enter the logs directory and rename access.log
<code>mv access.<span>log</span><span>2016</span>-<span>3</span>-<span>4</span>.<span>log</span></code>
After renaming, nginx cannot find the log file, so we use the kill command to pass a signal to the main process of nginx and let it restart Log
Check the official document and find the signal to reopen the log
Use the kill command
Then nginx will reopen the log
Automatic cutting
We can write the above operation into a script, and then Use crontab to execute this script on time every day for log cutting, then automatic cutting will be completed.
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });The above introduces Linux Notes (67) - Detailed explanation of nginx log files, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.