Log transmission method and device, electronic equipment and storage medium
By using a preset format file to record device identifiers and compressing them before uploading during log transmission, the security risks and bandwidth consumption issues of the SYSLOG method are resolved, achieving efficient and secure log transmission.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- WUHAN SIPU TECH CO LTD
- Filing Date
- 2026-03-20
- Publication Date
- 2026-07-14
AI Technical Summary
The existing SYSLOG method has security risks in log transmission, difficulty in identifying device identifiers, and consumes a lot of bandwidth, which affects network performance.
Device identification information is recorded in a preset format file, and the logs are compressed and uploaded when the maximum number of entries is reached. The HTTPS protocol is used to encrypt the transmission, ensuring that the logs are transmitted in an orderly and efficient manner.
It improves the security and reliability of log transmission, reduces bandwidth consumption, and ensures accurate identification of device identifiers and correct association between logs and devices.
Smart Images

Figure CN122395041A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer network security technology, and in particular to a log transmission method, apparatus, electronic device and storage medium. Background Technology
[0002] Application Control Gateway (ACG) devices generate a large number of logs during network operation, which are crucial for network situational awareness and log auditing. Currently, ACG devices primarily use the SYSLOG method to send logs out; however, this method has significant drawbacks. SYSLOG transmits logs in plaintext, making them vulnerable to theft and tampering during transmission, posing a significant security risk. Furthermore, in NAT networking environments, address translation makes it difficult for cloud platforms to effectively identify the logs of each ACG device. Moreover, SYSLOG typically sends logs one by one, consuming considerable bandwidth and impacting network performance.
[0003] Therefore, a new log transmission method is urgently needed to solve the above problems. Summary of the Invention
[0004] In view of this, this application provides a log transmission method, apparatus, electronic device, and storage medium, which can improve the security and reliability of log transmission and reduce the bandwidth consumption of log transmission.
[0005] A first aspect of this application provides a log transmission method, comprising: obtaining log upload request information issued by a cloud platform, wherein the log upload request information includes at least a maximum number of log entries to be uploaded and an upload address; when a new log is generated by an application control gateway device, writing the newly generated log into a preset format file, wherein the preset format file records identification information of the application control gateway device; when it is detected that the number of logs in the preset format file is equal to the maximum number of log entries to be uploaded, compressing the preset format file to obtain a first target compressed file; and uploading the first target compressed file to the cloud platform according to the upload address.
[0006] In one possible implementation, the log upload request information further includes the log upload type; before writing the newly generated log into the preset format file, it further includes: detecting whether the log is a target log that needs to be uploaded based on the log upload type; writing the newly generated log into the preset format file includes: if the log is detected to be the target log, writing the target log into the preset format file.
[0007] In one possible implementation, writing the target log into the preset format file includes: concatenating the fields of the target log and storing them on a linked list; traversing the linked list at preset intervals to obtain the log content; and concatenating the current time and the identification information into the log content and recording it into the preset format file.
[0008] In one possible implementation, the log upload requirement information further includes an upload cycle; after the log content is concatenated with the current time and the identification information and recorded in the preset format file, the method further includes: determining the next reporting time of the application control gateway device based on the upload cycle; detecting in real time whether the difference between the current time and the next reporting time is less than or equal to a preset threshold; if the difference is detected to be less than or equal to the preset threshold, moving the preset format file to the upload directory of the application control gateway device; when the current time reaches the next reporting time, compressing the preset format file in the upload directory to obtain a second target compressed file; and uploading the second target compressed file to the cloud platform according to the upload address.
[0009] In one possible implementation, the log upload request information further includes an enable switch; the step of writing the newly generated log to a preset format file when the application control gateway device generates a new log includes: when the enable switch is detected to be on, writing the log to the preset format file when the application control gateway device generates a new log.
[0010] In one possible implementation, the preset format file is a CSV file, and the target compressed file is a ZIP compressed file; the step of uploading the target compressed file to the cloud platform according to the upload address includes: reporting the ZIP compressed file to the upload address of the cloud platform via the HTTPS protocol.
[0011] In one possible implementation, after reporting the ZIP compressed file to the upload address of the cloud platform via the HTTPS protocol, the method further includes: deleting the ZIP compressed file and deleting the CSV file.
[0012] Secondly, embodiments of this application also provide a log transmission device, including: an acquisition module, a writing module, a compression module, and an upload module; the acquisition module is used to acquire log upload request information issued by a cloud platform, wherein the log upload request information includes at least the maximum number of logs to be uploaded and an upload address; the writing module is used to write newly generated logs into a preset format file when the application control gateway device generates new logs, wherein the preset format file records the identification information of the application control gateway device; the compression module is used to compress the preset format file to obtain a first target compressed file when it detects that the number of logs in the preset format file is equal to the maximum number of logs to be uploaded; the upload module is used to upload the first target compressed file to the cloud platform according to the upload address.
[0013] Thirdly, embodiments of this application also provide an electronic device, the electronic device including a processor and a memory, the memory being used to store instructions, and the processor being used to call the instructions in the memory, causing the electronic device to execute the log transmission method as described in the first aspect.
[0014] Fourthly, embodiments of this application also provide a computer-readable storage medium that stores computer instructions that, when executed on an electronic device, cause the electronic device to perform the log transmission method as described in the first aspect.
[0015] Compared with related technologies, the embodiments of this application have at least the following advantages: Since the log upload request information includes the maximum number of log entries to be uploaded, after the application control gateway device writes newly generated logs into a preset format file, it compresses the preset format file when it detects that the number of logs in the preset format file equals the maximum number of log entries to be uploaded, and uploads the resulting first target compressed file to the cloud platform. This significantly reduces the amount of data transmitted, thereby effectively reducing bandwidth consumption and mitigating the impact on network performance. Since the log upload request information also includes an upload address, the application control gateway device can upload the first target compressed file to the cloud platform according to the upload address, ensuring orderly and efficient log upload and improving the reliability and security of log transmission. Furthermore, the preset format file records the identification information of the application control gateway device, enabling the cloud platform to accurately identify the corresponding application control gateway device even in a NAT networking environment, ensuring the correct association between logs and devices.
[0016] The technical effects achieved by the second, third, and fourth aspects mentioned above are similar to those achieved by the corresponding technical means in the first aspect, and will not be repeated here. Attached Figure Description
[0017] Figure 1 A flowchart illustrating the steps of a log transmission method provided in an embodiment of this application; Figure 2 A flowchart illustrating another step of the log transmission method provided in an embodiment of this application; Figure 3 A schematic diagram illustrating the interaction logic between a cloud platform and an ACG device provided in an embodiment of this application; Figure 4 A functional block diagram of a log transmission device provided in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0018] To better understand the above-mentioned objectives, features, and advantages of this application, the application will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.
[0019] The following description sets forth many specific details to provide a full understanding of this application. The described embodiments are only some, not all, of the embodiments of this application.
[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein in the specification of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application.
[0021] It should be further noted that, in this document, 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 limitation, 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 that element.
[0022] In this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The terms "first," "second," "third," "fourth," etc. (if present) in the specification, claims, and drawings of this application are used to distinguish similar objects, not to describe a specific order or sequence.
[0023] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0024] For ease of understanding, some concepts related to the embodiments of this application are illustrated and explained by way of example.
[0025] An Application Control Gateway (ACG) device is a network security and management device that operates at a higher level of the OSI model (especially the application layer). It is primarily used for deep identification, precise control, and auditing of various application traffic within the network. It can identify thousands of common applications such as instant messaging, P2P downloads, online games, and online videos. Furthermore, it can formulate granular access control policies based on multiple dimensions, including user, time, address, and application type, achieving integrated management of bandwidth optimization, behavior auditing, and security protection.
[0026] CSV (Comma-Separated Values) files are a common file format for storing tabular data in plain text. Data fields are separated by commas, with each row representing one record. They are commonly used to exchange tabular data between different programs. Due to their simple structure and strong compatibility, CSV is widely used for importing and exporting data between spreadsheets, databases, and data analysis tools.
[0027] RESTful API: An application programming interface based on the REST (Representational State Transfer) architectural style, its core is to abstract all data and functions in the system as "resources" and operate on these resources through standard HTTP protocol methods.
[0028] URL interfaces typically refer to the service entry points provided by the backend. Clients call these interfaces by sending HTTP requests (such as GET and POST) to obtain data or perform operations.
[0029] Hardware SN (Serial Number): This is a unique identifier for a device, equivalent to a hardware "ID card number." It is assigned by the manufacturer during production to distinguish different individuals within the same model and is widely used in scenarios such as product traceability, after-sales service, warranty verification, and device management.
[0030] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating the steps of one embodiment of the log transmission method provided in this application. The order of steps in this flowchart can be changed, and some steps can be omitted, depending on different requirements.
[0031] It should be noted that the log transmission method of this application embodiment can be applied to log upload scenarios of application control gateway devices. The executing entity can be a log transmission device; for example, during the network operation of the application control gateway device, logs generated by the application control gateway device can be transmitted to the cloud platform through the log transmission device. Of course, the log transmission method can also be applied to other scenarios where application control gateway devices need to perform log transmission, and this application does not specifically limit its application transmission.
[0032] The specific process of this embodiment is as follows: Figure 1 As shown, it includes the following steps: S101, obtain the log upload request information issued by the cloud platform. The log upload request information includes at least the maximum number of logs to be uploaded and the upload address.
[0033] In some embodiments, the cloud platform has dual functions: "configuration distribution" and "log reception". When issuing instructions, it sends a request to the ACG device to upload logs; when receiving logs, it provides a specified URL interface to receive compressed log files reported by the ACG device.
[0034] S102, when the application control gateway device generates a new log, the newly generated log is written to a preset format file, wherein the preset format file records the identification information of the application control gateway device.
[0035] In some embodiments, the identification information is the hardware serial number (SN) information of the ACG device. It is understood that the identification information can also be software serial number (SN). This embodiment does not specifically limit the type of identification information; it only needs to ensure that the identification information can characterize the application control gateway device.
[0036] In some embodiments, the log upload request information further includes the log upload type; before writing the newly generated log into the preset format file, it further includes: detecting whether the log is a target log that needs to be uploaded based on the log upload type; writing the newly generated log into the preset format file includes: if the log is detected to be a target log, writing the target log into the preset format file.
[0037] In some embodiments, writing the target log into a preset format file includes: concatenating the fields of the target log and storing them on a linked list; traversing the linked list at preset intervals to obtain the log content; and concatenating the log content with the current time and identification information and recording it into the preset format file.
[0038] It should be noted that in this embodiment, each type of log is recorded in a different preset format file.
[0039] In some embodiments, the log upload request information further includes an enable switch; when the application control gateway device generates new logs, the newly generated logs are written to a preset format file, including: when the enable switch is detected to be on, the logs are written to the preset format file when the application control gateway device generates new logs.
[0040] S103, if the number of logs in the preset format file is equal to the maximum number of logs to be sent, the preset format file is compressed to obtain the first target compressed file.
[0041] In some embodiments, the maximum number of log entries to be sent can be set according to actual needs, and this embodiment does not impose a specific limitation on this. For example, the maximum number of log entries to be sent can be set to 200, 300, etc.
[0042] In some embodiments, the preset format file is a CSV file, and the first target compressed file is a ZIP file.
[0043] S104, upload the first target compressed file to the cloud platform according to the upload address.
[0044] In some embodiments, uploading the first target compressed file to the cloud platform according to the upload address includes: reporting the ZIP compressed file to the upload address of the cloud platform via the HTTPS protocol.
[0045] Specifically, the ACG device in this embodiment uses the libcurl library, based on the TCP protocol, and employs HTTPS encrypted transmission to report ZIP compressed files to a specified upload address. The HTTPS protocol ensures the security of log transmission through encryption, preventing logs from being stolen or tampered with; the TCP protocol provides a reliable transmission mechanism, ensuring that logs are reported accurately and completely. libcurl is a powerful library that supports data transmission between clients and servers via the HTTPS protocol.
[0046] Compared with related technologies, the embodiments of this application have at least the following advantages: Since the log upload request information includes the maximum number of log entries to be uploaded, after the application control gateway device writes newly generated logs into a preset format file, it compresses the preset format file when it detects that the number of logs in the preset format file equals the maximum number of log entries to be uploaded, and uploads the resulting first target compressed file to the cloud platform. This significantly reduces the amount of data transmitted, thereby effectively reducing bandwidth consumption and mitigating the impact on network performance. Since the log upload request information also includes an upload address, the application control gateway device can upload the first target compressed file to the cloud platform according to the upload address, ensuring orderly and efficient log upload and improving the reliability and security of log transmission. Furthermore, the preset format file records the identification information of the application control gateway device, enabling the cloud platform to accurately identify the corresponding application control gateway device even in a NAT networking environment, ensuring the correct association between logs and devices.
[0047] Please refer to Figure 2 , Figure 2 This is a flowchart illustrating the steps of one embodiment of the log transmission method of this application. Depending on different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted. This log transmission method can be applied to the aforementioned log transmission apparatus, but is not limited thereto, and this application embodiment does not limit it in this regard.
[0048] This embodiment is a further improvement on the aforementioned embodiment. The main improvement is that, in this embodiment, the log upload request information also includes the upload cycle. After detecting that the current time has reached the next reporting time, the compressed file will also be uploaded to the cloud platform according to the upload address. This method can further improve the reliability of log transmission.
[0049] The specific process of this embodiment is as follows: Figure 2 As shown, it includes the following steps: S201, obtain the log upload request information issued by the cloud platform. The log upload request information includes the maximum number of logs to be uploaded, upload address, log type, and upload cycle.
[0050] S202, Detect whether the log is the target log that needs to be sent based on the type of log to be sent.
[0051] S203, if the log is detected to be the target log, concatenate the fields of the target log and store them on a linked list.
[0052] S204: Traverse the linked list at preset intervals to obtain log content; concatenate the current time and identification information into the log content and record it in a preset format file.
[0053] S205, determine the next reporting time of the application control gateway device based on the reporting cycle.
[0054] S206, Real-time detection of whether the difference between the current time and the next reporting time is less than or equal to a preset threshold. If the difference is detected to be less than or equal to the preset threshold, execute S207; otherwise, execute S209.
[0055] In some embodiments, the size of the preset threshold is not specifically limited, and can be set according to actual needs.
[0056] S207, move the preset format file to the upload directory of the application control gateway device, and when the next upload time arrives, compress the preset format file in the upload directory to obtain the second target compressed file.
[0057] S208, upload the second target compressed file to the cloud platform according to the upload address.
[0058] S209, check if the number of logs in the preset format file is equal to the maximum number of logs to be sent; if the number of logs in the preset format file is equal to the maximum number of logs to be sent, execute S210; otherwise, execute S204.
[0059] S210, compress the preset format file to obtain the first target compressed file.
[0060] S211, upload the first target compressed file to the cloud platform according to the upload address.
[0061] In some embodiments, after uploading the first target compressed file or the second target compressed file to the cloud platform, the compressed file and the CSV file are also deleted.
[0062] To facilitate understanding, the following will be combined with... Figure 3 This embodiment provides a detailed explanation of how to implement log transmission for ACG devices: Please refer to Figure 3 This is a schematic diagram illustrating the interaction logic between the cloud platform and the ACG device provided in this application embodiment. The functions of the cloud platform and the ACG device are described below: The cloud platform has dual functions: "configuration distribution" and "log reception". When issuing commands, it sends log upload requirements to the ACG device (including the log type, such as "application control log", "operation log", "system log", etc.; upload period, such as 10 minutes; number of log entries in a single CSV file upload, such as 200; upload address; enable switch, such as true or false). When receiving logs, it provides a specified URL interface to receive compressed log files reported by the ACG device and parses the fields in the CSV file according to the agreed log format.
[0063] ACG device functional modules: Configure the storage module: Receive JSON requests from the cloud platform via the RESTful API interface, parse out the parameters "log type, upload address, upload period, maximum number of log entries in a single CSV file to be uploaded, and enable switch", and store them in the local configuration file.
[0064] Log recording module: Generates CSV files by classifying the logs generated by ACG devices that need to be uploaded according to "log type", with the naming rule being "log type.csv" (such as operate.csv, ips.csv, etc.). The CSV fields include "index, time, software SN, hardware SN and log content".
[0065] Compression and Reporting Module: When the "upload cycle" is reached, all CSV files are packaged and compressed into a compressed package. Using the libcurl library, based on the TCP protocol, and employing HTTPS encrypted transmission, the compressed package is uploaded to the specified upload address (e.g., https: / / xxx.example.com / xxx). After uploading, the local compressed package and CSV files are deleted.
[0066] The interaction process between ACG devices and the cloud platform is as follows: 1. Establishing a connection between the ACG device and the cloud platform: Configure the server address, server port, and logical ID information of the cloud platform. After the configuration is completed, you can send an HTTPS connection request to the cloud platform and establish a connection through interaction with the cloud platform.
[0067] 2. The cloud platform sends a JSON-formatted request to the ACG device: An example request is shown below: { "URL":"https: / / xxx.example.com / xxx", "LogType":"operate,ips,app_filter,…", "UploadTime":10, "UploadSize":200, "Enable":false } Wherein, URL is the address to upload logs; LogType is the type of log to be uploaded, with each log type separated by a comma; UploadTime is the upload period; UploadSize is the maximum number of log entries that can be written to each type of CSV file in the uploaded ZIP archive; Enable is the enable switch (true is enabled, false is disabled).
[0068] 3. ACG device parsing requests, and log upload processing: (1) Configuration parsing and storage: The ACG device parses the requests issued by the cloud platform through the Restful API interface, extracts key parameters, and stores each parameter in the configuration file.
[0069] By configuring a timer for the reporting cycle, log reporting is triggered once every certain period of time.
[0070] (2) Log collection and storage: The ACG device stores the real-time generated log content on a linked list. A timer is configured to schedule the process every second, traverse the linked list according to the log type, delink the logs and obtain the log content. The time, software SN, and hardware SN are appended to the log content and then written to a CSV file in the specified directory one by one. Each field of the log content is separated by a specified delimiter.
[0071] (3) Log compression and upload: When the reporting period is reached, each CSV file is compressed into a compressed package; using the libcurl library, an HTTPS request is sent to upload the compressed package to the specified URL; after the upload is completed, the locally uploaded log files (including zip compressed files and CSV files of all log types) are deleted.
[0072] 4. Cloud Platform Log Processing: After receiving the zip compressed file, the cloud platform decompresses it, parses the CSV file, obtains the hardware serial number to associate the device, and provides relevant personnel with data for querying and analysis.
[0073] Compared with related technologies, the embodiments of this application have at least the following advantages: Since the log upload request information includes the maximum number of log entries to be uploaded, after the application control gateway device writes newly generated logs into a preset format file, it compresses the preset format file when it detects that the number of logs in the preset format file equals the maximum number of log entries to be uploaded, and uploads the resulting first target compressed file to the cloud platform. This significantly reduces the amount of data transmitted, thereby effectively reducing bandwidth consumption and mitigating the impact on network performance. Since the log upload request information also includes an upload address, the application control gateway device can upload the first target compressed file to the cloud platform according to the upload address, ensuring orderly and efficient log upload and improving the reliability and security of log transmission. Furthermore, the preset format file records the identification information of the application control gateway device, enabling the cloud platform to accurately identify the corresponding application control gateway device even in a NAT networking environment, ensuring the correct association between logs and devices.
[0074] Based on the same idea as the log transmission method in the above embodiments, this application also provides a log transmission device that can be used to execute the above-described log transmission method. For ease of explanation, the structural schematic diagram of the log transmission device embodiment only shows the parts related to the embodiments of this application. Those skilled in the art will understand that the illustrated structure does not constitute a limitation on the device, and it may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0075] like Figure 4 As shown, the log transmission device 40 includes an acquisition module 401, a writing module 402, a compression module 403, and an upload module 404. In some embodiments, the above modules can be programmable software instructions stored in memory and executable by a processor. It is understood that in other embodiments, the above modules can also be program instructions or firmware embedded in the processor.
[0076] The acquisition module 401 is used to acquire log upload request information issued by the cloud platform, wherein the log upload request information includes at least the maximum number of logs to be uploaded and the upload address; The writing module 402 is used to write the newly generated log into a preset format file when the application control gateway device generates a new log, wherein the preset format file records the identification information of the application control gateway device; Compression module 403 is used to compress the preset format file to obtain a first target compressed file when the number of logs in the preset format file is equal to the maximum number of logs to be sent. The upload module 404 is used to upload the first target compressed file to the cloud platform according to the upload address.
[0077] The log transmission device 40 provided in the above embodiments can implement the technical solutions described in the above log transmission method embodiments. The specific implementation principles of each module or unit can be found in the corresponding content in the above log transmission method embodiments, and will not be repeated here.
[0078] Please refer to Figure 5 , Figure 5 This is a schematic diagram of an embodiment of the electronic device of this application. In this embodiment of the invention, the electronic device 500 includes a processor 501, a memory 502, and a display 503. Figure 5 Only some components of the electronic device 500 are shown, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.
[0079] In some embodiments, processor 501 may be a central processing unit (CPU), microprocessor, or other data processing chip, used to run program code stored in memory 502 or process data, such as the log transmission method of the present invention.
[0080] In some embodiments, processor 501 may be a single server or a group of servers. The server group may be centralized or distributed. In some embodiments, processor 501 may be local or remote. In some embodiments, processor 501 may be implemented on a cloud platform. In one embodiment, the cloud platform may include a private cloud, public cloud, hybrid cloud, community cloud, distributed cloud, intranet, multi-cloud, etc., or any combination thereof.
[0081] In some embodiments, memory 502 may be an internal storage unit of electronic device 500, such as a hard disk or memory of electronic device 500. In other embodiments, memory 502 may also be an external storage device of electronic device 500, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. equipped on electronic device 500.
[0082] Furthermore, the memory 502 may include both internal storage units of the electronic device 500 and external storage devices. The memory 502 is used to store application software and various types of data installed on the electronic device 500.
[0083] In some embodiments, display 503 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. Display 503 is used to display information from electronic device 500 and to display visual user applications. Components 501-503 of electronic device 500 communicate with each other via a system bus.
[0084] In one embodiment, when processor 501 executes the log transmission program in memory 502, the following steps can be implemented: Obtain log upload request information issued by the cloud platform, wherein the log upload request information includes at least the maximum number of logs to be uploaded and the upload address; When the application control gateway device generates a new log, the newly generated log is written to a preset format file, wherein the preset format file records the identification information of the application control gateway device; If the number of logs in the preset format file is equal to the maximum number of logs to be sent, the preset format file is compressed to obtain a first target compressed file. The first target compressed file is uploaded to the cloud platform according to the upload address.
[0085] It should be understood that when the processor 501 executes the log transmission program in the memory 502, in addition to the functions mentioned above, it can also perform other functions, as can be found in the description of the corresponding method embodiments above.
[0086] Furthermore, this embodiment of the invention does not specifically limit the type of electronic device 500 mentioned. Electronic device 500 can be a mobile phone, tablet computer, personal digital assistant (PDA), wearable device, laptop computer, or other portable electronic device. Exemplary embodiments of portable electronic devices include, but are not limited to, portable electronic devices running iOS, Android, Microsoft, or other operating systems. The aforementioned portable electronic device can also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the invention, electronic device 500 may not be a portable electronic device, but rather a desktop computer with a touch-sensitive surface (e.g., a touch panel).
[0087] Accordingly, this application also provides a computer-readable storage medium for storing computer-readable programs or instructions. When the programs or instructions are executed by a processor, they can implement the steps or functions of the log transmission methods provided in the above-described method embodiments.
[0088] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware (such as a processor, controller, etc.), and the computer program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.
[0089] The log transmission method, apparatus, electronic device, and computer-readable storage medium provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A log transmission method, characterized in that, Applied to an application control gateway device, the method includes: Obtain log upload request information issued by the cloud platform, wherein the log upload request information includes at least the maximum number of logs to be uploaded and the upload address; When the application control gateway device generates a new log, the newly generated log is written to a preset format file, wherein the preset format file records the identification information of the application control gateway device; If the number of logs in the preset format file is equal to the maximum number of logs to be sent, the preset format file is compressed to obtain a first target compressed file. The first target compressed file is uploaded to the cloud platform according to the upload address.
2. The log transmission method according to claim 1, characterized in that, The log upload request information also includes the log type to be uploaded; Before writing the newly generated logs to the preset format file, the method further includes: Detect whether the log is the target log that needs to be sent based on the type of log to be sent. The step of writing the newly generated logs to a preset format file includes: If the log is detected to be the target log, the target log is written to the preset format file.
3. The log transmission method according to claim 2, characterized in that, The step of writing the target log into the preset format file includes: The fields of the target log are concatenated and stored in a linked list; The linked list is traversed at preset intervals to retrieve log content; The log content is concatenated with the current time and the identification information, and then recorded in the preset format file.
4. The log transmission method according to claim 3, characterized in that, The log upload requirement information also includes the upload cycle; After concatenating the current time and the identification information into the log content and recording it into the preset format file, the method further includes: The next reporting time of the application control gateway device is determined based on the reporting cycle. Real-time detection of whether the difference between the current time and the next reporting time is less than or equal to a preset threshold; If the difference is detected to be less than or equal to the preset threshold, the preset format file is moved to the upload directory of the application control gateway device; If the current time reaches the next reporting time, the preset format file in the upload directory is compressed to obtain a second target compressed file; The second target compressed file is uploaded to the cloud platform according to the upload address.
5. The log transmission method according to claim 1, characterized in that, The log upload request information also includes an enable switch; The step of writing the newly generated log to a preset format file when the application control gateway device generates a new log includes: When the enable switch is detected to be on, the log is written to the preset format file when the application control gateway device generates a new log.
6. The log transmission method according to claim 1, characterized in that, The preset format file is a CSV file, and the first target compressed file is a ZIP compressed file; The step of uploading the first target compressed file to the cloud platform according to the upload address includes: reporting the ZIP compressed file to the upload address of the cloud platform via the HTTPS protocol.
7. The log transmission method according to claim 6, characterized in that, After reporting the ZIP compressed file to the upload address of the cloud platform via HTTPS, the process also includes: Delete the ZIP compressed file and delete the CSV file.
8. A log transmission device, characterized in that, include: The module includes an acquisition module, a writing module, a compression module, and an upload module. The acquisition module is used to acquire log upload requirement information issued by the cloud platform, wherein the log upload requirement information includes at least the maximum number of logs to be uploaded and the upload address; The writing module is used to write newly generated logs into a preset format file when the application control gateway device generates new logs, wherein the preset format file records the identification information of the application control gateway device; The compression module is used to compress the preset format file to obtain a first target compressed file when it detects that the number of logs in the preset format file is equal to the maximum number of logs to be sent. The upload module is used to upload the first target compressed file to the cloud platform according to the upload address.
9. An electronic device, the electronic device comprising a processor and a memory, characterized in that, The memory is used to store instructions, and the processor is used to invoke the instructions in the memory to cause the electronic device to execute the log transmission method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed on an electronic device, cause the electronic device to perform the log transmission method as described in any one of claims 1 to 7.