How does Nginxlog record user information?

Source: Internet
Author: User
My website now uses Nginx + php. Now I want to count the number of visiting users and observe the footprints of a person on the website. I don't want to use php, because every access should be recorded once. php is inefficient and I want to print it directly in nginxaccesslog. The solution I came up with is: log... now my website uses Nginx + php. Now I want to count the visiting login users and observe the footprints of a person on the website. I don't want to use php, because every access should be recorded once. php is inefficient and I want to print it directly in nginx access log.
The solution I came up with was to record the user from which each access entry came from in the log (if the user is logged on, the user ID is recorded, and a key value can be given to the user without logon, used to indicate his identity), and then combined with other content recorded in the nginx access log, you can compare the good-looking statistics report.
The problem is, I don't know how to do this record... The user's URL cannot contain his or her ID...

Reply content:

My website now uses Nginx + php. Now I want to count the number of visiting users and observe the footprints of a person on the website. I don't want to use php, because every access should be recorded once. php is inefficient and I want to print it directly in nginx access log.
The solution I came up with was to record the user from which each access entry came from in the log (if the user is logged on, the user ID is recorded, and a key value can be given to the user without logon, used to indicate his identity), and then combined with other content recorded in the nginx access log, you can compare the good-looking statistics report.
The problem is, I don't know how to do this record... The user's URL cannot contain his or her ID...

This is simple .. Make an ajax request on the page, and the URL will carry the UID. nginx will write it down, and the corresponding log will be easily extracted.

For more flexible processing of log formats, we recommend that you directly use the ngx_lua module. In this way, you can customize the log format, and the records can be directly imported into the database for processing, which is very convenient.

I don't have a clear idea, but I think nginx can be something at the http protocol level. All http-related data can be recorded, but it involves something at the ID business level, i'm afraid it is not easy to do. If you want to do this, you also need to check whether the program can work with nginx variable parameters.
In addition, the business program must output many other logs, which is inevitable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.