A method, device and application for front-end log batch collection and transmission

By creating a log package storage queue on the front end and adopting a batch sending strategy, the problem of too frequent front-end log sending is solved, server pressure and network resource usage are reduced, important log loss is avoided, and system performance and user experience are improved.

CN115296973BActive Publication Date: 2024-10-22北京清研兰亭科技有限公司
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202210488384.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-06
Publication Date
2024-10-22
Estimated Expiration
2042-05-06

AI Technical Summary

Technical Problem

Front-end logs are sent too frequently, resulting in increased server pressure, waste of network resources, and loss of important logs.

Method used

The method of collecting and sending log packets in batches is adopted. By creating a log packet storage queue on the front end, using the first-in-first-out queue structure, log packets are sent regularly, and a retransmission mechanism is introduced to avoid loss.

Benefits of technology

It reduces the frequency of log sending, reduces network bandwidth usage and server pressure, avoids the loss of key information, and improves system performance and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115296973B_ABST
    Figure CN115296973B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of Internet technology, and discloses a method, device and application for front-end log batch collection and transmission, wherein the method for front-end log batch collection and transmission comprises: creating a log package storage queue at the front end; constructing log storage logic; and constructing log transmission logic. The present invention reduces the frequency of log transmission and the number of http connections, thereby reducing the occupation of network bandwidth; extracting the same information in the log, reducing the log volume, and reducing the occupation of network resources; standardizing the log structure reduces the resource occupation during server processing, and reduces the server pressure; introducing a failed retransmission mechanism avoids the loss of key information; and at the same time reduces the number of http request connections of terminal devices, reducing energy consumption, which is particularly important in mobile terminals; reducing the number of server requests, alleviating server pressure, and improving server processing efficiency; reducing the number of network http requests, saving public network resources, and effectively avoiding the loss of key logs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of Internet technology, and in particular relates to a method, device and application for front-end log batch collection and transmission. Background Art

[0002] Front-end logs refer to the records generated by client devices stored on the server, including logs generated by user operation behaviors, logical errors, network anomalies, etc. In today's Internet industry, front-end logs play an irreplaceable role in product optimization, user behavior analysis, system error troubleshooting and recovery, and system performance optimization. At the same time, the front-end logs have high concurrency and have extremely high requirements for bandwidth and stability. At present, the front-end log collection method is that the terminal device sends each log generated to the server immediately, and the back-end stores the logs. Although the function implementation logic is simple and the timeliness of the front-end logs is guaranteed, the frequent sending of logs leads to an increase in the number of http connections, which squeezes the bandwidth of business-related requests, increases the pressure on server data processing, and greatly increases the power consumption of terminal devices. In the face of a complex network environment, the loss of important logs is also inevitable. Therefore, it is urgent to design a new front-end log batch collection and sending device.

[0003] Through the above analysis, the problems and defects of the existing technology are: the front-end logs are sent too frequently, which increases the pressure on the server and wastes network resources. At the same time, the power consumption of terminal devices increases, which increases costs; in the face of complex network environments, the loss of important logs is inevitable. Summary of the invention

[0004] In view of the problems existing in the prior art, the present invention provides a method, device and application for collecting and sending front-end logs in batches.

[0005] The present invention is implemented in this way: a method for collecting and sending front-end logs in batches comprises the following steps:

[0006] Step 1: Create a log package storage queue on the front end;

[0007] The log package in the queue structure is first-in-first-out, which ensures the timeliness of the front-end log and avoids log accumulation. The log package contains business information such as the front-end log unit array, device information, and logical processing information such as the retransmission flag.

[0008] Step 2: Build the log storage logic;

[0009] After the front-end log is generated, if the tail log package in the log package queue is not in the sending state and the length of the log unit array in the log package does not reach the threshold, data will continue to be stored in the log unit array of the current log package until the log package sending conditions are met. Otherwise, a new log package is inserted into the log package queue and the newly generated log is stored in the log package.

[0010] Step 3: Build the logic for sending log packages.

[0011] When inserting a new log into the log packet queue, it detects whether the number of logs in the log packet at the head of the log packet queue reaches the threshold. If so, the log packet is sent. To ensure the timeliness of the front-end log, a global timer is added. When the set time threshold is reached, the log packet at the head of the log packet queue is sent to the server.

[0012] Furthermore, the log packet in step 1 includes a log packet ID, a user ID, a device ID, a log unit array, a sending status flag, and a retransmission flag.

[0013] The log package ID is used to ensure the uniqueness of the server log storage. The log package may be sent due to the network environment. The terminal may time out but the server successfully stores the log. At this time, the terminal will retransmit the log package. The server uses this ID to avoid repeated storage.

[0014] User ID is used to distinguish different user identities;

[0015] The device ID is used to distinguish the device currently used by the user;

[0016] The log unit array is used to store multiple logs and realize batch sending of logs;

[0017] The sending status flag includes two states: sending and sending completed. The sending state indicates that the current log package has been sent through the network, but has not yet received feedback from the server; the sending completed state indicates whether the current log package is being transmitted over the network. If it is not being transmitted, if the length of the log unit array in the log package does not reach the threshold, a new log can still be stored;

[0018] Retransmission flag, integer, default value is 0. If the log packet fails to be sent due to network and server reasons, the flag will be incremented by 1. When the number of retransmissions reaches the threshold, the current log packet will be discarded.

[0019] Furthermore, the storage logic of the log in step 2 includes:

[0020] (1) Determine whether there is a log packet queue. If not, create a log packet queue and insert the log packet. If yes, directly execute the step of determining whether the log packet queue is empty.

[0021] (2) If it is determined that the log packet queue is not empty, determine whether the length of the log unit array in the log packet at the end of the queue reaches a threshold; if it is determined that the log packet queue is empty, create a new log packet and insert it into the log packet queue;

[0022] (3) If it is determined that the length of the log unit array does not reach the threshold, determine whether the log packet is being sent; if it is determined that the length of the log unit array reaches the threshold, create a new log packet and insert it into the log packet queue;

[0023] (4) If it is determined that the log packet is being sent, a new log packet is created and inserted into the log packet queue; if it is determined that the log packet is not being sent, a new log unit is inserted into the log unit array of the log packet.

[0024] Furthermore, the log package is stored in a first-in-first-out queue mode, and the log package is sent to the server via http; the log package specifically includes:

[0025] The log package ID is generated by a random algorithm when a new log package is generated. After each log package is sent to the server, the server detects whether the current log package has been received in the log storage system. For the log packages that have been stored, the server will no longer store them and directly send an HTTP response.

[0026] Log package sending flag, Boolean type, used to indicate that the current log package has been sent to the Internet and has not yet received a response from the server, to avoid repeated sending of log packages;

[0027] The number of times the current log package is sent. If the log package fails to be sent due to network timeout, network abnormality, or server abnormality, the number of failed sending increases by 1 each time. When the threshold is reached, the log package will be deleted to avoid server crashes due to the current log package abnormality.

[0028] Log unit array, including timestamp, log type, log description and other structured data;

[0029] Wherein, the timestamp is used to record the generation time of the log;

[0030] The user ID is used to record the user associated with the log;

[0031] The device ID is used to record the device associated with the log;

[0032] The log type is used to facilitate the server to classify and process logs, thereby improving the server processing efficiency;

[0033] The log description and object type are used to record detailed information of the log.

[0034] Furthermore, the log sending logic in step 3 includes the following two relatively independent logics:

[0035] Independent scheduled task detection is used to automatically trigger log sending when the timing threshold is reached. When the user may not trigger the operation generated by the log unit for a long time, the front-end log is actively sent to the server;

[0036] Active insertion after each log unit is generated is used to send the log unit to the server in time when the number of log units in the log package reaches the threshold, ensuring that the log is sent to the server this morning.

[0037] Furthermore, the log sending logic in step 3 includes:

[0038] (1) Start the scheduled task;

[0039] (2) performing the timing detection and waiting for the log unit insertion steps simultaneously;

[0040] (3) After executing the timing detection step, determine whether the trigger time interval value is reached; if not, return to the timing detection step; if so, execute step (4); after executing the waiting log unit insertion step, insert the log unit and execute step (4);

[0041] (4) Determine whether the network connection is normal. If not, return to step (2); if so, determine whether the sending flag is FALSE; if not, return to step (2); if so, execute step (5);

[0042] (5) Determine whether the number of times the log packet is sent reaches the threshold. If so, delete the current log packet; if not, send the log packet, set the sending flag to TRUE, and wait for the server to return;

[0043] (6) Determine whether the result returned by the server is correct; if not, increase the number of log white-sending times by 1, set the sending flag to FALSE, and return to step (2); if so, delete the current log package and return to step (2).

[0044] Another object of the present invention is to provide a device for front-end log batch collection and transmission using the method for front-end log batch collection and transmission, the device for front-end log batch collection and transmission comprising:

[0045] The storage queue creation module is used by the front end to create a log package storage queue;

[0046] Storage logic building module, used to build log storage logic;

[0047] The sending logic building module is used to build the log sending logic.

[0048] Another object of the present invention is to provide a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the method for batch collection and sending of front-end logs.

[0049] Another object of the present invention is to provide a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the method for collecting and sending front-end logs in batches.

[0050] Another object of the present invention is to provide an information data processing terminal, which is used to implement the device for batch collection and transmission of front-end logs.

[0051] In combination with the above technical solutions and the technical problems solved, please analyze the advantages and positive effects of the technical solutions to be protected by the present invention from the following aspects:

[0052] First, in view of the technical problems existing in the above-mentioned prior art and the difficulty of solving the problems, the technical solutions to be protected by the present invention and the results and data during the research and development process are closely combined to analyze in detail and deeply how the technical solutions of the present invention solve the technical problems, and some creative technical effects brought about after solving the problems. The specific description is as follows:

[0053] The present invention reduces the frequency of log sending, reduces the number of HTTP connections, and reduces the occupation of network bandwidth; the same information in the log is extracted, the log volume is reduced, and the occupation of network resources is further reduced; the standardization of the log structure reduces the resource occupation during server processing and reduces the server pressure; the introduction of the failure retransmission mechanism avoids the loss of key information.

[0054] Second, considering the technical solution as a whole or from the perspective of the product, the technical effects and advantages of the technical solution to be protected by the present invention are described in detail as follows:

[0055] The present invention reduces the number of HTTP request connections of terminal devices and reduces energy consumption, which is particularly important in mobile terminals; reduces the number of server requests, relieves server pressure, and improves server processing efficiency; reduces the number of network http requests, saves public network resources, and effectively avoids the loss of key logs.

[0056] Third, as auxiliary evidence of the creativity of the claims of the present invention, it is also reflected in the expected benefits and commercial value of the technical solution of the present invention after transformation: from the product perspective, the present invention greatly improves the efficiency of developers in terms of product optimization, user behavior analysis, system error troubleshooting and recovery, system performance optimization, etc. From the user perspective, the present invention saves user traffic, reduces log bandwidth occupancy, improves software response speed, improves user experience, reduces power consumption, and improves the battery life of mobile devices. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0058] Figure 1 It is a schematic diagram of the log packet queue structure provided by an embodiment of the present invention.

[0059] Figure 2 It is a schematic diagram of the structure of a single log package provided by an embodiment of the present invention.

[0060] Figure 3 It is a flow chart of the log storage logic provided by an embodiment of the present invention.

[0061] Figure 4 The figure is a flow chart of sending a log package provided by an embodiment of the present invention.

[0062] Figure 5 It is a flow chart of a method for batch collection and sending of front-end logs provided by an embodiment of the present invention.

[0063] Figure 6 It is a structural block diagram of a device for front-end log batch collection and transmission provided by an embodiment of the present invention;

[0064] Figure 7 This is a log integrity comparison diagram provided by an embodiment of the present invention.

[0065] In the figure: 1. Storage queue creation module; 2. Storage logic construction module; 3. Sending logic construction module. DETAILED DESCRIPTION

[0066] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0067] In view of the problems existing in the prior art, the present invention provides a method, device and application for front-end log batch collection and transmission. The present invention is described in detail below with reference to the accompanying drawings.

[0068] 1. Explanatory Examples In order to enable those skilled in the art to fully understand how to implement the present invention, this section provides an illustrative example that expands and describes the technical solution of the claims.

[0069] like Figure 1As shown, a schematic diagram of the log package queue structure provided by an embodiment of the present invention is shown. The log packages are stored in a first-in-first-out queue mode to ensure that the earliest collected logs are sent to the server as soon as possible.

[0070] Figure 2 Schematic diagram of a single log package structure provided by an embodiment of the present invention. Figure 1 A subunit of the log packet queue in the log packet queue. The log packet is sent to the server via http.

[0071] 201, the log package ID is generated by a random algorithm when a new log package is generated. After each log package is sent to the server, the server detects whether the current log package has been received in the log storage system, and does not store the already stored log package, but directly sends an HTTP response.

[0072] 202, user ID is used to distinguish different user identities.

[0073] 203, the device ID is used to distinguish the device currently used by the user.

[0074] 204, the sending status flag includes two states: sending and sending completed. The sending state indicates that the current log package has been sent through the network, but has not yet received feedback from the server; the sending completed state indicates whether the current log package is being transmitted over the network. If it is not being transmitted, if the length of the log unit array in the log package does not reach the threshold, a new log can still be stored.

[0075] 205, retransmission flag, integer, default value is 0. If the log packet fails to be sent due to network and server reasons, the flag will be incremented by 1. When the number of retransmissions reaches the threshold, the current log packet will be discarded to avoid server crash due to abnormal current log packet.

[0076] 206, log unit array, including structured data such as timestamp, log type, and log description.

[0077] like Figure 3 As shown, in the process of log storage logic provided by the embodiment of the present invention, the insertion operation S301 of the unit log is Figure 4 Flow chart of sub-steps of operation step S402.

[0078] like Figure 4 As shown, in the process of sending a log package provided by an embodiment of the present invention, the sending trigger logic of the log package includes S401 and S402, and the two sets of logic are relatively independent.

[0079] S401, independent scheduled task detection, automatically triggers log sending once the timing threshold is reached. The significance of this operation design is that the user may not trigger the operation generated by the log unit for a long time. This operation can actively send the front-end log to the server to ensure the timeliness of the front-end log.

[0080] S402, active insertion after each log unit is generated. The significance of this operation design is to send the log unit to the server in time once the number of log units in the log package reaches the threshold, so as to ensure that the log is sent to the server as soon as possible.

[0081] like Figure 5 As shown, an embodiment of the present invention provides a method for collecting and sending front-end logs in batches, comprising the following steps:

[0082] S501, the front end creates a log package storage queue;

[0083] The log package in the queue structure is first-in-first-out, which ensures the timeliness of the front-end log and avoids log accumulation. The log package contains business information such as the front-end log unit array, device information, and logical processing information such as the retransmission flag.

[0084] S502, constructing log storage logic;

[0085] After the front-end log is generated, if the tail log package in the log package queue is not in the sending state and the length of the log unit array in the log package does not reach the threshold, data will continue to be stored in the current log package until the log package sending conditions are met. Otherwise, a new log package is inserted into the log package queue and the newly generated log is stored in the log package.

[0086] S503, construct the sending logic of the log package.

[0087] When inserting a new log into the log packet queue, it detects whether the number of logs in the log packet at the head of the log packet queue reaches the threshold. If so, the log packet is sent. To ensure the timeliness of the front-end log, a global timer is added. When the set time threshold is reached, the log packet at the head of the log packet queue is sent to the server.

[0088] In the embodiment of the present invention, the log packet in step S501 includes a log packet ID, a user ID, a device ID, a log unit array, a sending status flag, and a retransmission flag.

[0089] The log package ID is used to ensure the uniqueness of the server log storage. The log package may be sent due to the network environment. The terminal may time out but the server successfully stores the log. At this time, the terminal will retransmit the log package. The server uses this ID to avoid repeated storage.

[0090] User ID is used to distinguish different user identities;

[0091] The device ID is used to distinguish the device currently used by the user;

[0092] The log unit array is used to store multiple logs and realize batch sending of logs;

[0093] The sending status flag includes two states: sending and sending completed. The sending state indicates that the current log package has been sent through the network, but has not yet received feedback from the server; the sending completed state indicates whether the current log package is being transmitted over the network. If it is not being transmitted, if the length of the log unit array in the log package does not reach the threshold, a new log can still be stored;

[0094] Retransmission flag, integer, default value is 0. If the log packet fails to be sent due to network and server reasons, the flag will be incremented by 1. When the number of retransmissions reaches the threshold, the current log packet will be discarded.

[0095] In the embodiment of the present invention, the log storage logic in step S502 includes:

[0096] (1) Determine whether there is a log package queue. If not, create a log package queue and determine whether the log package queue is empty. If so, directly execute the step of determining whether the log package queue is empty.

[0097] (2) If it is determined that the log packet queue is not empty, determine whether the length of the log unit array reaches a threshold; if it is determined that the log packet queue is empty, create a new log packet and insert it into the log packet queue;

[0098] (3) If it is determined that the length of the log unit array does not reach the threshold, determine whether the log packet is being sent; if it is determined that the length of the log unit array reaches the threshold, create a new log packet and insert it into the log packet queue;

[0099] (4) If it is determined that the log packet is being sent, a new log packet is created and inserted into the log packet queue; if it is determined that the log packet is not being sent, a log unit is created and inserted into the log unit array of the log packet.

[0100] In the embodiment of the present invention, the log package is stored in a first-in-first-out queue mode, and the log package is sent to the server via http; the log package specifically includes:

[0101] The log package ID is generated by a random algorithm when a new log package is generated. After each log package is sent to the server, the server detects whether the current log package has been received in the log storage system. For the log packages that have been stored, the server will no longer store them and directly send an HTTP response.

[0102] Log package sending flag, Boolean type, used to indicate that the current log package has been sent to the Internet and has not yet received a response from the server, to avoid repeated sending of log packages;

[0103] The number of times the current log package is sent. If the log package fails to be sent due to network timeout, network abnormality, or server abnormality, the number of failed sending increases by 1 each time. When the threshold is reached, the log package will be deleted to avoid server crashes due to the current log package abnormality.

[0104] Log unit array, including timestamp, log type, log description and other structured data;

[0105] Wherein, the timestamp is used to record the generation time of the log;

[0106] The user ID is used to record the user associated with the log;

[0107] The device ID is used to record the device associated with the log;

[0108] The log type is used to facilitate the server to classify and process logs, thereby improving the server processing efficiency;

[0109] The log description and object type are used to record detailed information of the log.

[0110] In the embodiment of the present invention, the log sending logic in step S503 includes the following two sets of relatively independent logics:

[0111] Independent scheduled task detection is used to automatically trigger log sending when the timing threshold is reached. When the user may not trigger the operation generated by the log unit for a long time, the front-end log is actively sent to the server;

[0112] Active insertion after each log unit is generated is used to send the log unit to the server in time when the number of log units in the log package reaches the threshold, ensuring that the log is sent to the server this morning.

[0113] In the embodiment of the present invention, the log sending logic in step S503 includes:

[0114] (1) Start the scheduled task;

[0115] (2) performing the timing detection and waiting for the log unit insertion steps simultaneously;

[0116] (3) After executing the timing detection step, determine whether the trigger time interval value is reached; if not, return to the timing detection step; if so, execute step (4); after executing the waiting log unit insertion step, insert the log unit and execute step (4);

[0117] (4) Determine whether the network connection is normal. If not, return to step (2); if so, determine whether the sending flag is FALSE; if not, return to step (2); if so, execute step (5);

[0118] (5) Determine whether the number of times the log packet is sent reaches the threshold. If so, delete the current log packet; if not, send the log packet, set the sending flag to TRUE, and wait for the server to return;

[0119] (6) Determine whether the result returned by the server is correct; if not, increase the number of log white-sending times by 1, set the sending flag to FALSE, and return to step (2); if so, delete the current log package and return to step (2).

[0120] like Figure 6 As shown, the device for collecting and sending front-end logs in batches provided by an embodiment of the present invention includes:

[0121] Storage queue creation module 1, used for front-end creation of log package storage queue;

[0122] Storage logic building module 2, used to build the storage logic of logs;

[0123] The sending logic building module 3 is used to build the log sending logic.

[0124] The front end provided by the embodiment of the present invention creates a log package storage queue, and the log objects in the queue include the unique ID of the user, the ID of the device, the current log unit array ID, the log unit array, the sending status flag, and the retransmission flag. A timer is also provided, and the first log package of the log package queue is sent whenever a threshold is reached.

[0125] The user's unique ID is generated by the server to distinguish different user identities.

[0126] The device ID is generated by the front-end logic to distinguish the device currently used by the user.

[0127] The log package ID is generated by a random algorithm when a new log package is generated. After each log package is sent to the server, the server detects whether the current log package has been received in the log storage system. For the log packages that have been stored, the server will no longer store them and directly send an HTTP response.

[0128] The log unit array is used to store multiple logs and realize batch sending of logs;

[0129] The sending status flag includes two states: sending and sending completed. The sending state indicates that the current log package has been sent through the network, but has not yet received feedback from the server; the sending completed state indicates whether the current log package is being transmitted over the network. If it is not being transmitted, if the length of the log unit array in the log package does not reach the threshold, a new log can still be stored;

[0130] Retransmission flag, integer, default value is 0. If the log packet fails to be sent due to network and server reasons, the flag will be incremented by 1, and the log packet will be automatically retransmitted. When the number of retransmissions reaches the threshold, the current log packet will be discarded.

[0131] The embodiments of the present invention may be implemented by hardware, software, or a combination of software and hardware. The hardware portion may be implemented using dedicated logic; the software portion may be stored in a memory and executed by an appropriate instruction execution system, such as a microprocessor or dedicated design hardware. A person of ordinary skill in the art will appreciate that the above-mentioned devices and methods may be implemented using computer executable instructions and / or contained in a processor control code, such as a carrier medium such as a disk, CD or DVD-ROM, a programmable memory such as a read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier providing such code. The device and its modules of the present invention may be implemented by hardware circuits such as very large scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, etc., or programmable hardware devices such as field programmable gate arrays, programmable logic devices, etc., may also be implemented by software executed by various types of processors, or may be implemented by a combination of the above-mentioned hardware circuits and software, such as firmware.

[0132] 3. Evidence of the effects of the embodiments. The embodiments of the present invention have achieved some positive effects during the development or use process, and indeed have great advantages over the prior art. The following content is described in conjunction with the data, charts, etc. of the test process.

[0133] like Figure 7 As shown, the log integrity of the traditional log sending method and the present invention is compared (number of server stored logs / number of front-end sent logs×100%). The experimental data in the figure are obtained by simulating different network speeds through browsers, and multiple tests are performed under normal network speed, Fast 3G, and Slow 3G conditions.

[0134] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principle of the present invention should be covered by the protection scope of the present invention.

Claims

1. A method for collecting and sending front-end logs in batches, characterized in that: The method for collecting and sending front-end logs in batches comprises the following steps: Step 1: Create a log package storage queue on the front end; Step 2: Build the log storage logic; Step 3: Build the logic for sending log packages; The log packet in the log packet storage queue in the step 1 includes a log packet ID, a user ID, a device ID, a log unit array, a sending status flag, and a retransmission flag, and a timer is provided, and the first log packet in the log packet queue is sent whenever the timing threshold is reached; The user's unique ID is generated by the server and is used to distinguish different user identities; The device ID is generated by an algorithm and is used to distinguish the device currently used by the user; The log package ID is used to ensure the uniqueness of the server log storage. The sending of the log package may be affected by the network environment. If the terminal times out but the server successfully stores the log, the terminal will retransmit the log package. The server uses this ID to avoid repeated storage. The log unit array is used to store multiple logs and realize batch sending of logs; The sending status flag includes two states: sending and sending completed. The sending state indicates that the current log package has been sent through the network, but has not yet received feedback from the server; the sending completed state indicates whether the current log package is being transmitted over the network. If it is not being transmitted, if the length of the log unit array in the log package does not reach the array length threshold, a new log can still be stored; Retransmission flag, integer, default value is 0; if the log packet fails to be sent due to network and server reasons, the flag will be incremented by 1. When the number of retransmissions reaches the retransmission threshold, the current log packet will be discarded; The storage logic of the log in step 2 includes: Determine whether there is a log package queue. If not, create a log package queue and determine whether the log package queue is empty. If so, directly execute the step of determining whether the log package queue is empty. If it is determined that the log package queue is not empty, then determine whether the log unit array length reaches the array length threshold; if it is determined that the log package queue is empty, create a new log package and insert it into the log package queue; If it is determined that the log unit array length does not reach the array length threshold, it is determined whether the log package is being sent; if it is determined that the log unit array length reaches the array length threshold, a new log package is created and inserted into the log package queue; If it is determined that the log packet is being sent, a new log packet is created and inserted into the log packet queue; if it is determined that the log packet is not being sent, a log unit is inserted into the log unit array of the log packet; The log sending logic in step 3 includes: (1) Start the scheduled task; (2) performing the timing detection and waiting for the log unit insertion steps simultaneously; (3) After executing the timing detection step, determine whether the trigger time interval value is reached; if not, return to the timing detection step; if so, execute step (4); after executing the waiting log unit insertion step, insert the log unit and execute step (4); (4) Determine whether the network connection is normal. If not, return to step (2); if so, determine whether the sending flag is FALSE; if not, return to step (2); if so, execute step (5); (5) Determine whether the number of times the log packet is sent reaches the sending number threshold. If so, delete the current log packet; if not, send the log packet, set the sending flag to TRUE, and wait for the server to return; (6) Determine whether the result returned by the server is correct; if not, increase the number of times the log packet is sent by 1, set the sending flag position to FALSE, and return to step (2); if so, delete the current log packet and return to step (2).

2. The method for collecting and sending front-end logs in batches according to claim 1, characterized in that: The log packets are stored in a first-in-first-out queue and are sent to the server via http.

3. The method for collecting and sending front-end logs in batches according to claim 1, characterized in that: The log sending logic in step 3 includes the following two relatively independent logics: Independent scheduled task detection is used to automatically trigger log sending when the timing threshold is reached. When the user may not trigger the operation generated by the log unit for a long time, the front-end log is actively sent to the server; Active insertion after each log unit is generated is used to send the log unit to the server in time when the number of log units in the log package reaches the unit number threshold, ensuring that the log is sent to the server as soon as possible.

4. A device for front-end log batch collection and transmission using the method for front-end log batch collection and transmission as claimed in any one of claims 1 to 3, characterized in that: The device for collecting and sending front-end logs in batches includes: The storage queue creation module is used by the front end to create a log package storage queue; Storage logic building module, used to build log storage logic; The sending logic building module is used to build the log sending logic.

5. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the method for collecting and sending front-end logs in batches as described in any one of claims 1 to 3.

6. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the method for collecting and sending front-end logs in batches according to any one of claims 1 to 3.

7. An information data processing terminal, characterized in that: The information data processing terminal is used to implement the device for batch collection and transmission of front-end logs as described in claim 5.

Citation Information

Patent Citations

  • Log collection method, client, server, and electronic equipment

    CN106470123A

  • Application log gathering and sending method, device, system and log server

    CN106559241A

  • Data management method, middleware and data management system

    CN108197233A

  • Network data real-time acquisition and storage method and device based on WinPcap

    CN110445730A

  • Method for collecting and sending big data auditing logs of application delivery equipment

    CN112882808A