PHP (Professional Hypertext Preprocessor) based log collection and storage method and system

A caching system and log technology, applied in the network field, can solve problems such as the impact of database read and write capabilities, and achieve the effect of convenient collection and reduced writing pressure

CN105022822AInactive Publication Date: 2015-11-04CHENGDU STARCOR INFORMATION TECH
6 Cites 4 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Publication Date
2015-11-04
Estimated Expiration
Not applicable · inactive patent

Smart Images

  • Figure 1
    Figure 1
  • Figure 2
    Figure 2
  • Figure 3
    Figure 3
Patent Text Reader

Abstract

The present invention relates to a PHP (Professional Hypertext Preprocessor) based log collection and storage method and system. The method comprises the steps of: S1, reporting log data by a client; S2, collecting the log data and sending the log data to a Redis cache server by a log collection module; S3, storing the log data by the Redis cache server. S4, reading the log data line by line from the Redis cache server and sending the log data to a MongoDB database by a log asynchronous writing module; and S5, writing and storing the log data in the MongoDB database. According to the PHP based log collection and storage method and system, an effective log can be conveniently collected, reading and writing performances of the database are ensured to operate in a low-concurrency and low-IO-load range, and writing pressure of the storage database is reduced, so that the system can operate healthily and stably.
Need to check novelty before this filing date? Find Prior Art

Description

technical field

[0001] The invention relates to the field of network technology, in particular to a method and system for collecting and storing logs based on PHP. Background technique

[0002] Now there are generally several ways to store log data, and the common one is to store it in local files or databases. For the storage scheme of the database, when the amount of log data is huge and the concurrency is high, it will have a huge impact on the read and write capabilities of the database. Contents of the invention

[0003] The technical problem to be solved by the present invention is to provide a method and system for collecting and storing logs based on PHP.

[0004] The technical solution of the present invention to solve the above-mentioned technical problems is as follows: a method for collecting and storing logs based on PHP, comprising the following steps:

[0005] Step S1, the client reports log data;

[0006] Step S2, the log collection module collects the l...

Examples

Embodiment Construction

[0030] The principles and features of the present invention are described below in conjunction with the accompanying drawings, and the examples given are only used to explain the present invention, and are not intended to limit the scope of the present invention.

[0031] Explanation of terms involved in the present invention: PHP (foreign name: PHP: Hypertext Preprocessor, Chinese name: "hypertext preprocessor") is a general open source scripting language. Redis is an open-source, log-type, Key-Value database that is written in ANSIC language, supports network, can be memory-based or persistent, and provides APIs in multiple languages. MongoDB is a database based on distributed file storage, written in C++ language, designed to provide scalable high-performance data storage solutions for WEB applications.

[0032] figure 1 It is a flow chart of the method for collecting and storing logs based on PHP in the present invention.

[0033] like figure 1 As shown, a method for co...