Linux Notes (67) - Detailed explanation of nginx log files
- Log file format
- Log file cutting
- Manual cutting
- Automatic cutting
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:
- $remote_addr and $http_x_forwarded_for are used to record the client’s IP address;
- $remote_user: used to record Client user name;
- $time_local: used to record access time and time zone;
- $request: used to record the URL and http protocol of the request;
- $status: used to record the request status; success is 200,
- $body_bytes_s ent: records the size of the body content of the file sent to the client;
- $http_referer: used to record the link accessed from that page;
- $http_user_agent: records relevant information of the client browser;
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.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



DeepSeek cannot convert files directly to PDF. Depending on the file type, you can use different methods: Common documents (Word, Excel, PowerPoint): Use Microsoft Office, LibreOffice and other software to export as PDF. Image: Save as PDF using image viewer or image processing software. Web pages: Use the browser's "Print into PDF" function or the dedicated web page to PDF tool. Uncommon formats: Find the right converter and convert it to PDF. It is crucial to choose the right tools and develop a plan based on the actual situation.

Oracle can read dbf files through the following steps: create an external table and reference the dbf file; query the external table to retrieve data; import the data into the Oracle table.

How to implement HTTP streaming in C++? Create an SSL stream socket using Boost.Asio and the asiohttps client library. Connect to the server and send an HTTP request. Receive HTTP response headers and print them. Receives the HTTP response body and prints it.

Wordpress site file access is restricted: troubleshooting the reason why .txt file cannot be accessed recently. Some users encountered a problem when configuring the mini program business domain name: �...

Implementing HTTP file upload security in Golang requires following these steps: Verify file type. Limit file size. Detect viruses and malware. Store files securely.

Running multiple PHP versions simultaneously in the same system is a common requirement, especially when different projects depend on different versions of PHP. How to be on the same...

Solve the problem of third-party interface returning 403 in Node.js environment. When we use Node.js to call third-party interfaces, we sometimes encounter an error of 403 from the interface returning 403...

Running the H5 project requires the following steps: installing necessary tools such as web server, Node.js, development tools, etc. Build a development environment, create project folders, initialize projects, and write code. Start the development server and run the command using the command line. Preview the project in your browser and enter the development server URL. Publish projects, optimize code, deploy projects, and set up web server configuration.
