Log file sending method, device and client
By setting a fixed log file storage size in the client and creating target log files within a time interval, the problem of invalid log information transmitted by the client is solved, achieving accurate transmission of log information and rapid problem location.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-05
- Publication Date
- 2026-03-31
AI Technical Summary
The log information transmitted from the client to the server contains a large amount of invalid information, which increases the amount of data transmitted and makes it difficult to quickly find online problems.
In the client, the storage size of each log file is set to a fixed value, and the target log file is created when the time difference between log time intervals is less than a preset value. Only log information belonging to that time interval is transmitted to avoid transmitting invalid information.
It achieves accurate transmission of log information, saves transmission bandwidth, and enables the server to quickly find online problems during client operation.
Smart Images

Figure CN115576908B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of Internet technology, and in particular to a method, apparatus and client for sending log files. Background Technology
[0002] With the continuous development of Internet technology, clients often transmit stored log information to servers, making it easier for servers to find online problems that occur during the actual operation of clients.
[0003] However, the log information transmitted from the client to the server often contains a large amount of invalid log information, which increases the amount of log information transmitted and is not conducive to quickly finding online problems. Summary of the Invention
[0004] To solve the above-mentioned technical problems, or at least partially solve them, this disclosure provides a log file sending method, apparatus, and client.
[0005] In one aspect, this disclosure provides a log file sending method, which is applied to a client, wherein the storage size of each log file in the client is set to a fixed value.
[0006] The method includes:
[0007] Receive log request information from the server. The log request information includes the user identifier and the log time range.
[0008] When the time difference between log time intervals is less than or equal to a preset value, a target log file is created. The preset value corresponds to the time difference that is less than a fixed value.
[0009] Write the log information within the time interval from the log file of the user corresponding to the user identifier to the target log file;
[0010] Send the target log file to the server.
[0011] Using the method provided in the first aspect, with the storage capacity of each log file in the client set to a fixed value, the client receives log request information from the server, including the user identifier and the log time interval. When the time difference within the log time interval is less than or equal to a preset value, the client can create a target log file. The target log file is created when the time difference is less than the fixed value. Log information within the log time interval is then written from the log file of the user corresponding to the user identifier to the target log file. The client can then send the target log file to the server, causing the server to perform corresponding operations based on the target log file. Thus, the client transmits log information belonging to the user and within the log time interval to the server in a time-based manner, rather than transmitting log information belonging to the client but outside the log time interval in a single log file-based manner. This achieves accurate log information retrieval, saves log information transmission bandwidth, and allows the server to save time spent filtering log information, which is beneficial for the server to promptly identify online problems occurring during client operation.
[0012] In one possible design, the method also includes:
[0013] After confirming that the target log file has been successfully sent, delete the target log file.
[0014] In one possible design, log information within a specific time interval is written from the log file of the user corresponding to the user identifier to the target log file, including:
[0015] The log files of the user corresponding to the user identifier are traversed line by line to identify individual log entries within the log time interval. These individual log entries are then written sequentially to the target log file until all log files of the user corresponding to the user identifier have been traversed.
[0016] In one possible design, the method also includes:
[0017] When the time difference of the log time interval is greater than a preset value, the log file to which the log information belongs within the log time interval is obtained from the log file of the user corresponding to the user identifier. The storage size of each log file to which the log information belongs within the log time interval is a fixed value, and the log file to which the log information belongs within the log time interval is sent to the server.
[0018] In one possible design, the preset value is less than 1 / 2 of the time difference corresponding to the fixed value.
[0019] Secondly, this disclosure provides a log file sending device applied to a client, wherein the storage size of each log file in the client is set to a fixed value.
[0020] The device includes:
[0021] The receiving module is used to receive log request information from the server. The log request information includes the user identifier and the log time range.
[0022] The creation module is used to create a target log file when the time difference between log time intervals is less than or equal to a preset value, where the preset value is less than a fixed value corresponding to the time difference.
[0023] The writing module is used to write log information within the log time interval from the log file of the user corresponding to the user identifier to the target log file;
[0024] The sending module is used to send the target log file to the server.
[0025] In one possible design, the device also includes:
[0026] The delete module is used to delete the target log file after confirming that the target log file has been successfully sent.
[0027] In one possible design, the writing module is specifically used to iterate through the target information line by line in the log file of the user corresponding to the user identifier, determine the individual log information within the log time interval, and write the individual log information within the log time interval sequentially into the target log file until the log file of the user corresponding to the user identifier has been completely traversed.
[0028] In one possible design, the sending module is also used to retrieve the log file to which the log information belongs within the log time interval from the log file of the user corresponding to the user identifier when the time difference of the log time interval is greater than a preset value, wherein the storage size of each log file to which the log information belongs within the log time interval is a fixed value, and to send the log file to which the log information belongs within the log time interval to the server.
[0029] In one possible design, the preset value is less than 1 / 2 of the time difference corresponding to the fixed value.
[0030] The log file sending apparatus provided in the second aspect and its various possible designs above can be referred to for the beneficial effects of the first aspect and its various possible implementations above, and will not be repeated here.
[0031] Thirdly, this disclosure provides a client, including: a memory and a processor; the memory is used to store program instructions; the processor is used to invoke the program instructions in the memory to cause the client to execute the log file sending method in the first aspect and any possible design of the first aspect.
[0032] Fourthly, this disclosure provides a computer storage medium including computer instructions that, when executed on an electronic device, cause the electronic device to perform the log file sending method of the first aspect and any possible design of the first aspect.
[0033] Fifthly, this disclosure provides a computer program product that, when run on a computer, causes the computer to execute the log file sending method of the first aspect and any possible design of the first aspect.
[0034] In a sixth aspect, this disclosure provides a chip system applied to an electronic device including a display, a memory, and a sensor; the chip system includes a processor; when the processor executes computer instructions stored in the memory, the electronic device executes the first aspect and the log file sending method in any possible design of the first aspect. Attached Figure Description
[0035] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0036] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 A schematic diagram of a communication system provided in an embodiment of this disclosure;
[0038] Figure 2 Signaling interaction diagram of the log file sending method provided in the embodiments of this disclosure;
[0039] Figure 3 A schematic diagram of the structure of the log file sending device provided in the embodiments of this disclosure;
[0040] Figure 4 This is a schematic diagram of the structure of a log file sending device provided in an embodiment of this disclosure. Detailed Implementation
[0041] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0042] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0043] Please see Figure 1 , Figure 1 This is a schematic diagram of a communication system provided in an embodiment of this disclosure. Figure 1 As shown, the communication system provided in this disclosure may include a server and a client, and the server and the client can communicate with each other.
[0044] Considering the relatively long development cycle and complex application scenarios of client-side features, log files can be stored in the client to address online issues that arise during client operation. Each log entry in the log file carries the write time and content, allowing the client to easily retrieve log files within the time range sent by the server and upload them to the server.
[0045] Each log file has a fixed storage size, such as 20MB. This means that clients can write log information to a single log file. When the storage size of a log file exceeds the fixed value, the client stops writing subsequent log information to that file and instead creates a new log file, allowing subsequent log information to be written to the new file.
[0046] The client can implement the log file sending method disclosed herein through applications (APPs), public accounts, web pages, etc. on electronic devices. Electronic devices can be mobile phones, tablets, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), smart TVs, smart screens, high-definition TVs, 4K TVs, smart speakers, smart projectors, etc. This disclosure does not impose any restrictions on the specific type of electronic device.
[0047] This disclosure does not limit the type of operating system used in electronic devices. Examples include Android, Linux, Windows, and iOS.
[0048] Based on the foregoing description, this disclosure will use examples to illustrate... Figure 1Taking the client and server as examples, and with reference to the accompanying diagrams and application scenarios, the log file sending method provided in this disclosure is described in detail.
[0049] Please see Figure 2 , Figure 2 This is a signaling interaction diagram of the log file sending method provided in an embodiment of this disclosure. For example... Figure 2 As shown, the log file sending method provided in this disclosure may include:
[0050] S101. The server sends a log request message to the client, which includes the user identifier and the log time range.
[0051] The log request information is used to request the client to send log information from the log file of the user corresponding to the user identifier, within the log time interval, to the server. The user identifier is used to identify the corresponding user. The log time interval is used to identify the time range corresponding to the time point when the log information was written. This disclosure does not limit the specific implementation of the log request information, user identifier, and log time interval.
[0052] S102. When the time difference in the log time interval is less than or equal to the preset value, the client creates the target log file.
[0053] After receiving the log request information, the client can compare the time difference between the log time interval with the preset value.
[0054] The preset value represents the maximum amount of log information transmitted, and the preset value is less than the time difference corresponding to the fixed value. This disclosure does not limit the specific value of the preset value.
[0055] In some embodiments, the preset value is less than 1 / 2 of the time difference corresponding to the fixed value.
[0056] For example, suppose the storage size of a single log file in the client is 20MB, and the time difference corresponding to the storage size of a single log file in the client is 20 minutes. When the log information within the log time interval belongs to a log file of the user corresponding to the user identifier, the preset value can be set to 5 minutes. Therefore, when the time difference of the log time interval is less than or equal to the preset value, the client can determine that the amount of log information transmitted is small. Thus, the client can create a new target file as the target log file, such as a file marked as log.txt, to facilitate accurate writing of log information. This disclosure does not limit parameters such as the storage size and storage location of the target log file. In some embodiments, the storage size of the target log file is less than a fixed value.
[0057] S103. The client writes the log information within the log time interval from the log file corresponding to the user identifier to the target log file.
[0058] Based on the user identifier, the client can determine the log file of the user corresponding to that user identifier. The client then determines whether the write time of the log information in the log file of the user corresponding to the user identifier is within the log time interval.
[0059] When the log information is written within the log time interval, the client can determine that the log information belongs to the log time interval and write the log information within the log time interval to the target log file.
[0060] S104. The client sends the target log file to the server.
[0061] S105. The server performs corresponding operations based on the target log file.
[0062] If the log information within the log time interval belongs to a single log file corresponding to a user ID, the client will not send the entire single log file to the server. If the log information within the log time interval belongs to multiple log files corresponding to a user ID, the client will not send all multiple log files to the server.
[0063] In this disclosure, the client can send the target log file to the server based on time, realizing the accurate transmission of log information based on time. This avoids the transmission of a large amount of invalid log information retrieved based on a single log file, saving the bandwidth of transmitting log information. This enables the server to perform corresponding operations such as error correction, error checking, or problem investigation based on the target log file, which is conducive to quickly finding online problems that occur during client operation and avoids a lot of search effort being wasted on invalid log information.
[0064] S106. After confirming that the target log file has been successfully sent, the client deletes the target log file.
[0065] Given that the target log file is created temporarily, the client can delete it after confirming that the target log file has been successfully sent. This helps to promptly free up the client's storage space, allowing the client to repurpose it.
[0066] This disclosure does not limit the specific implementation method by which the client determines that the target log file has been successfully sent. In some embodiments, after receiving the target log file, the server may send an identifier to the client indicating that the target log file has been successfully received. Upon receiving this identifier, the client can determine that the target log file has been successfully sent. This identifier may be represented using numbers, letters, characters, or other similar methods.
[0067] It should be noted that step S106 is optional, and the execution order of steps S105 and S106 is not important.
[0068] The log file sending method disclosed herein, with the storage capacity of each log file on the client set to a fixed value, allows the client to receive log request information from the server, including a user identifier and a log time interval. When the time difference within the log time interval is less than or equal to a preset value, the client can create a target log file. The target log file is created when the time difference is less than the fixed value. Log information within the log time interval is written from the log file of the user corresponding to the user identifier to the target log file. The client can then send the target log file to the server, enabling the server to perform corresponding operations based on the target log file. Thus, the client transmits log information belonging to the user and falling within the log time interval to the server in a time-based manner, rather than transmitting log information belonging to the client but not falling within the log time interval in a single log file-based manner. This achieves accurate log information retrieval, saves bandwidth during log transmission, and allows the server to save time filtering log information, facilitating the server's timely identification of online issues occurring during client operation.
[0069] In step S102, when the time difference between log time intervals is greater than a preset value, the client can determine that the amount of log information transmitted is large. Therefore, the client does not need to create a target log file. Here, "large amount of log information transmitted" can be understood as the amount of log information the client needs to transmit to the server far exceeding the amount of information in a single invalid log file transmitted by the client to the server.
[0070] Therefore, the client can retrieve the log files containing log information within a specific time interval from the log files corresponding to the user's identifier. Each log file within this time interval has a fixed storage size, and the client sends these log files to the server. In other words, the client sends all individual log files to the server. This also allows the client to transmit target information belonging to the user and falling within a target time interval, using individual log files as the unit of measurement.
[0071] Based on the description of the above embodiments, the client can obtain the target log file in various ways. In some embodiments, the client can iterate through the target information line by line in the log file of the user corresponding to the user identifier, determine the individual log information within the log time interval, and write the individual log information within the log time interval sequentially into the target log file until the log file of the user corresponding to the user identifier has been completely traversed.
[0072] For example, this disclosure provides a log file sending apparatus.
[0073] Please see Figure 3 , Figure 3 This is a schematic diagram of the log file sending device provided in an embodiment of the present disclosure. The log file sending device of the present disclosure can be installed in a client, where the storage capacity of each log file is set to a fixed value. The client can be installed in an electronic device to achieve the above-mentioned functionality. Figures 1-2 The log file sending method in this embodiment corresponds to the client's operation.
[0074] like Figure 3 As shown, the log file sending device 100 provided in this disclosure may include: a receiving module 101, a creation module 102, a writing module 103, and a sending module 104.
[0075] The receiving module 101 is used to receive log request information from the server. The log request information includes a user identifier and a log time range.
[0076] Module 102 is used to create a target log file when the time difference between log time intervals is less than or equal to a preset value, where the preset value is less than the time difference corresponding to a fixed value.
[0077] The writing module 103 is used to write log information within the log time interval from the log file of the user corresponding to the user identifier to the target log file;
[0078] The sending module 104 is used to send the target log file to the server.
[0079] Please see Figure 4 , Figure 4 This is a schematic diagram of the structure of a log file sending device provided in an embodiment of this disclosure. Figure 4 As shown, the log file sending device 100 provided in this disclosure... Figure 3 Based on the structure shown, the device may also include:
[0080] The deletion module 105 is used to delete the target log file after confirming that the target log file has been successfully sent.
[0081] In some embodiments, the writing module 103 is specifically used to traverse the target information line by line in the log file of the user corresponding to the user identifier, determine the single log information within the log time interval, and write the single log information within the log time interval sequentially into the target log file until the log file of the user corresponding to the user identifier has been completely traversed.
[0082] In some embodiments, the sending module 104 is further configured to, when the time difference of the log time interval is greater than a preset value, obtain the log file to which the log information in the log time interval belongs from the log file of the user corresponding to the user identifier, wherein the storage size of each log file to which the log information in the log time interval belongs is a fixed value, and send the log file to which the log information in the log time interval belongs to the server.
[0083] In some embodiments, the preset value is less than 1 / 2 of the time difference corresponding to the fixed value.
[0084] The log file sending device provided in this disclosure can execute the above method embodiments. Its specific implementation principle and technical effects can be found in the above method embodiments, and will not be repeated here.
[0085] For example, this disclosure provides a client including: one or more processors; a memory; and one or more computer programs; wherein the one or more computer programs are stored in the memory; and when the one or more processors execute the one or more computer programs, the client causes the client to implement the log file sending method of the preceding embodiments.
[0086] For example, this disclosure provides a chip system applied to an electronic device including a display, a memory, and a sensor; the chip system includes a processor; when the processor executes computer instructions stored in the memory, the electronic device executes the log file sending method of the preceding embodiments.
[0087] For example, this disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, causes an electronic device to implement the log file sending method of the preceding embodiments.
[0088] For example, this disclosure provides a computer program product that, when run on a computer, causes the computer to execute the log file sending method described in the preceding embodiments.
[0089] In the above embodiments, all or part of the functionality can be implemented by software, hardware, or a combination of software and hardware. When implemented using software, it can be implemented wholly or partially in the form of a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this disclosure is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0090] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0091] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A log file sending method characterized by, The method is applied to a client, a storage amount of each log file in the client is set as a fixed value, and the method comprises: receiving log request information from a server, the log request information comprising a user identifier and a log time interval; when a time difference value of the log time interval is less than or equal to a preset value, creating a target log file, the preset value being less than a time difference value corresponding to the fixed value; writing log information in the log time interval into the target log file from a log file of a user corresponding to the user identifier; sending the target log file to the server; or when the time difference value of the log time interval is greater than the preset value, obtaining a log file to which log information in the log time interval belongs from the log file of the user corresponding to the user identifier, a storage amount of each log file in the log file to which the log information in the log time interval belongs being the fixed value, and sending the log file to which the log information in the log time interval belongs to the server; wherein the time difference value of the log time interval less than or equal to the preset value indicates that an invalid data amount of a complete log file corresponding to the log time interval is greater than a transmission amount of the log information in the log time interval; the time difference value of the log time interval greater than the preset value indicates that the transmission amount of the log information in the log time interval is greater than the invalid data amount of the complete log file corresponding to the log time interval. The method further comprises:
2. The method of claim 1, wherein, after determining that the target log file is sent successfully, deleting the target log file. writing the log information in the log time interval into the target log file from the log file of the user corresponding to the user identifier comprises:
3. The method of claim 1, wherein, performing line-by-line traversal on the log information in the log file of the user corresponding to the user identifier, determining single log information in the log time interval, and sequentially writing the single log information in the log time interval into the target log file until the log file of the user corresponding to the user identifier is completely traversed. writing the log information in the log time interval into the target log file from the log file of the user corresponding to the user identifier comprises:
4. The method of claim 2, wherein, performing line-by-line traversal on the log information in the log file of the user corresponding to the user identifier, determining single log information in the log time interval, and sequentially writing the single log information in the log time interval into the target log file until the log file of the user corresponding to the user identifier is completely traversed. The preset value is less than 1 / 2 of the time difference value corresponding to the fixed value.
5. The method according to any one of claims 1 to 4, characterized in that, The device is applied to a client, a storage amount of each log file in the client is set as a fixed value, and the device comprises:
6. A log file transmitting apparatus characterized by comprising: a receiving module configured to receive log request information from a server, the log request information comprising a user identifier and a log time interval; a creating module configured to, when a time difference value of the log time interval is less than or equal to a preset value, create a target log file, the preset value being less than a time difference value corresponding to the fixed value; The writing module is configured to write log information in the log time interval into the target log file from a log file corresponding to a user identified by the user identifier; The sending module is configured to send the target log file to the server; Alternatively, The sending module is further configured to, when the time difference of the log time interval is greater than the preset value, acquire a log file to which log information in the log time interval belongs from a log file corresponding to a user identified by the user identifier, and send the log file to which the log information in the log time interval belongs to the server, wherein a storage amount of each log file in the log file to which the log information in the log time interval belongs is the fixed value. The time difference of the log time interval being less than or equal to the preset value indicates that an invalid data amount of a complete log file corresponding to the log time interval is greater than a transmission amount of the log information in the log time interval. The time difference of the log time interval being greater than the preset value indicates that the transmission amount of the log information in the log time interval is greater than the invalid data amount of the complete log file corresponding to the log time interval.
7. A client comprising: One or more processors; Memory; and one or more computer programs; wherein the one or more computer programs are stored in the memory; characterized in that the one or more processors, when executing the one or more computer programs, cause the client to implement the log file sending method according to any one of claims 1-5.
8. A computer storage medium, characterized in that The computer program product comprises computer instructions, which, when executed on an electronic device, cause the electronic device to perform the log file sending method according to any one of claims 1-5.
9. A computer program product, characterised in that, The computer program product, when executed on a computer, causes the computer to perform the log file sending method according to any one of claims 1-5.
Citation Information
Patent Citations
Client log collection method and device, storage medium and electronic equipment
CN109710490A
Log file processing method and device, computer equipment and storage medium
CN112148518A