Method and system for automatically injecting operation log collection based on request header and medium

CN122909116APending Publication Date: 2026-10-13SHENZHEN STREAMING VIDEO TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611164034.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-31
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

[0005]针对现有技术存在的日志服务代码大量侵入业务逻辑,业务与日志深度耦合,在运行业务逻辑时,对应的日志服务代码也会被动的重复运行,极大增加了数据处理量的问题,本申请主要提供一种基于请求头自动注入的用户操作日志采集方法、系统及介质,以解决该技术问题

Benefits of technology

[0009]本申请的技术方案可以达到的有益效果是:本申请通过API网关解析并提取用户发起的原始HTTP业务操作请求中的用户身份信息并注入原始HTTP业务操作请求的请求头中、以及采用AOP切面拦截方法采集日志信息的方式,简化了多租户身份传递过程中重复识别的数据处理过程,无需在业务代码中显式书写及调用日志服务代码,极大的减少了多次书写日志服务代码的代码量及数据处理量,在启动日志采集服务时,不干预其他业务的正常运行,从而解决了现有技术方案的日志服务代码大量侵入业务逻辑,业务与日志深度耦合,在运行业务逻辑时,对应的日志服务代码也会被动的重复运行,极大增加了数据处理量的问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122909116A_ABST
    Figure CN122909116A_ABST
Patent Text Reader

Abstract

The application discloses a user operation log collection method and system based on automatic injection of request headers and a medium, and belongs to the technical field of log collection. The method comprises the following steps: converting user identity information into an identity header and injecting the identity header into a request header of an original HTTP business operation request by an API gateway to generate a target HTTP business operation request; calling an AOP aspect interception method by a business processing server to extract and verify the identity header from the target HTTP business operation request; in the case of passing the verification, the AOP aspect interception method triggers log collection logic to generate log information, wherein the log collection logic is independent of a business operation process corresponding to the target HTTP business operation request. Through the method, the application solves the problem that log service codes greatly invade business logic, and when the business logic is operated, the corresponding log service codes are also passively repeatedly run, greatly increasing the data processing amount, and the data processing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of log collection technology, and in particular to a method, system and medium for collecting user operation logs based on automatic injection of request headers. Background Technology

[0002] In enterprise-level web applications or cloud platform systems, user operation logs are a critical data source for audit trails, behavioral analysis, security compliance, and troubleshooting. In large and complex web application scenarios, such as IoT platforms, video surveillance systems, and smart hardware management platforms, these web applications have a large number of business interfaces and require granular log collection in multi-tenant, multi-application environments.

[0003] Traditional user operation log collection methods involve explicitly writing logging logic within each business interface, such as manually adding log service code after adding, editing, or deleting data. This approach has several problems: the log service code heavily intrudes into business logic, resulting in deep coupling between business logic and logging. When business logic runs, the corresponding log service code is passively and repeatedly executed, significantly increasing data processing volume. Furthermore, adjusting the log service code for a particular business function requires modifying each corresponding log service, greatly increasing the maintenance burden. Additionally, traditional logging methods rely on manual standardization, making them prone to errors due to human negligence, such as missing logs, incomplete log fields, or inconsistent log formats. Moreover, when business functions in web applications are adjusted, the corresponding logging logic is often overlooked, affecting audit effectiveness and data accuracy.

[0004] Therefore, there is an urgent need for a non-intrusive, automated, and highly reliable method for collecting user operation logs, which can eliminate the coupling between business logic and logs at the architectural level and efficiently collect user operation logs. Summary of the Invention

[0005] To address the problem that existing technologies suffer from log service code heavily intruding into business logic, resulting in deep coupling between business logic and logs, and the corresponding log service code being passively and repeatedly executed when business logic is running, which greatly increases the amount of data processing, this application mainly provides a user operation log collection method, system, and medium based on automatic injection of request headers to solve this technical problem.

[0006] To achieve the above objectives, the first technical solution adopted in this application is as follows: This application provides a user operation log collection method based on automatic injection of request headers, comprising: an API gateway parsing the original HTTP business operation request initiated by the user to extract the user's identity information; the API gateway converting the user identity information into an identity header and injecting it into the request header of the original HTTP business operation request to generate a target HTTP business operation request; a business processing server calling an AOP aspect interception method to extract and verify the identity header from the target HTTP business operation request; and, if the verification passes, the AOP aspect interception method triggers log collection logic to generate log information, wherein the log collection logic is independent of the business operation process corresponding to the target HTTP business operation request.

[0007] The second technical solution adopted in this application is: This application provides a user operation log collection system based on automatic injection of request headers, which includes a processor and a memory storing computer programs / instructions. The processor is configured to execute a user operation log collection method based on automatic injection of request headers in technical solution one when running the computer programs / instructions.

[0008] The third technical solution adopted in this application is: This application provides a computer-readable storage medium storing a computer program / instruction, which is operated to execute a user operation log collection method based on automatic injection of request headers in technical solution one.

[0009] The beneficial effects of the technical solution of this application are as follows: This application simplifies the data processing process of repeated identification during multi-tenant identity transmission by parsing and extracting user identity information from the original HTTP business operation request initiated by the user through the API gateway and injecting it into the request header of the original HTTP business operation request, and by using the AOP aspect interception method to collect log information. It eliminates the need to explicitly write and call log service code in the business code, greatly reducing the amount of code and data processing involved in writing log service code multiple times. When starting the log collection service, it does not interfere with the normal operation of other businesses, thus solving the problem that the log service code of the existing technical solution intrudes heavily into the business logic, resulting in deep coupling between business and logs. When running business logic, the corresponding log service code will also be passively and repeatedly run, greatly increasing the amount of data processing.

[0010] Furthermore, this application generates log information by filling the collected log parameters into a log template with a preset log format, which can unify the log format and adjust the log format uniformly when adjusting the log term template, thereby reducing maintenance costs. Attached Figure Description

[0011] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0012] Figure 1 This is a schematic flowchart of a specific implementation of a user operation log collection method based on automatic injection of request headers according to this application; Figure 2 This is a schematic flowchart of one embodiment of a user operation log collection method based on automatic injection of request headers according to this application; Figure 3 This is a schematic structural diagram of a specific implementation of a user operation log collection system based on automatic request header injection according to this application; Figure 4 This is a schematic structural diagram of a specific embodiment of a computer-readable storage medium according to this application.

[0013] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0014] The preferred embodiments of this application will now be described in detail with reference to the accompanying drawings, so that the advantages and features of this application can be more easily understood by those skilled in the art, thereby providing a clearer and more definite definition of the scope of protection of this application.

[0015] 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..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.

[0016] Below, for reference Figures 1 to 4This document provides a detailed description of the technical solutions of this application and how they solve the aforementioned technical problems, using specific embodiments. The specific embodiments described below can be combined to form new embodiments. Identical or similar ideas or processes described in one embodiment may not be repeated in other embodiments.

[0017] Figure 1 The diagram shows a schematic flowchart of a specific implementation of a user operation log collection method based on automatic injection of request headers according to this application.

[0018] like Figure 1 As shown, in one specific embodiment of this application, a user operation log collection method based on automatic injection of request headers includes step S101, in which the API gateway parses the original HTTP business operation request initiated by the user to extract the user's user identity information.

[0019] In one specific embodiment of this application, the API gateway is an Application Programming Interface Gateway; API stands for Application Programming Interface Gateway. HTTP stands for HyperText Transfer Protocol, which is a common language and set of rules used by browsers and servers to communicate with each other. It specifies the format in which clients should request data and the format in which servers should return data, such as web pages, images, and interface data. The original HTTP business operation request initiated by the user is a business operation request initiated by the user in an enterprise-level web application or cloud platform system, including operations such as adding, querying, editing, modifying, and deleting. The user identity information includes tenant number, application number, employee number, employee name, and other information.

[0020] In one specific embodiment of this application, an API gateway is used to parse the original HTTP business operation request initiated by the user in order to extract the user's identity information, including obtaining the identity token in the original HTTP business operation request and parsing it to obtain the user's identity information.

[0021] In this embodiment, the identity token refers to the JWT (JSON Web Token) information in the business operation request initiated by the user. User identity information, such as tenant number, application number, employee number, and employee name, is parsed from the JSON identity token to provide the user's identity information for subsequent identity transfer and identity verification.

[0022] like Figure 1As shown, in one specific embodiment of this application, a user operation log collection method based on automatic injection of request headers includes step S102, in which the API gateway converts user identity information into an identity header and injects it into the request header of the original HTTP business operation request to generate a target HTTP business operation request.

[0023] In one specific embodiment of this application, after obtaining the user identity information, the user identity information is automatically converted into an identity header in a preset format, and then the identity header is added to the custom field part of the request header of the original HTTP business operation request to generate a target HTTP business operation request; then the target HTTP business operation request is sent to the backend of the enterprise-level web application or cloud platform system to quickly identify the user identity information in the HTTP request, which facilitates subsequent analysis and processing.

[0024] By using the configuration method of this embodiment, this application fills the user's identity information into the corresponding position of the request header of the HTTP business operation request, forming the target HTTP business operation request corresponding to this business operation request, which can provide an identity information basis for subsequent identity transmission and identity verification.

[0025] In one specific embodiment of this application, after the target HTTP business operation request is sent to the backend of an enterprise-level web application or cloud platform system, the business processing server in the backend, such as a business controller, is responsible for receiving and processing the target HTTP business operation request, identifying the parameter information in the target HTTP business operation request, determining the purpose of the target HTTP business operation request, and then determining the corresponding service based on the purpose. The target HTTP business operation request is then passed to the corresponding service for relevant data analysis and processing. For example, if the purpose of the target HTTP business operation request is identified as collecting log information, the target HTTP business operation request is passed to the service corresponding to the backend AOP aspect interception method to execute the data analysis process therein and collect the log information corresponding to the target HTTP business operation request.

[0026] By adopting the configuration method of this embodiment, this application simplifies the process of multi-tenant identity information transmission, reduces the amount of data processing in the process of user identity information transmission, and helps to improve the data processing speed in the identity recognition stage.

[0027] like Figure 1As shown, in one specific embodiment of this application, a user operation log collection method based on automatic injection of request headers includes step S103, in which the business processing server calls the AOP aspect interception method to extract and verify the identity header from the target HTTP business operation request; if the verification is successful, the AOP aspect interception method triggers the log collection logic to generate log information, wherein the log collection logic is independent of the business operation process corresponding to the target HTTP business operation request.

[0028] In one specific embodiment of this application, the AOP aspect interception method is an aspect-oriented programming (AOP) interception method. AOP stands for Aspect-Oriented Programming. That is, after receiving the standard request header, the log collection logic executed using the AOP aspect interception method is independent of the business operation process corresponding to the target HTTP business operation request. This achieves automated collection of user operation logs without intruding on business code, eliminating deep coupling between business logic and logs at the architectural level, reducing the data processing volume of enterprise-level web applications or cloud platform systems, and lowering the maintenance burden.

[0029] In one specific embodiment of this application, verifying the identity header includes: if the identity header extracted from the target HTTP business operation request is complete, the verification passes; if the identity header extracted from the target HTTP business operation request is incomplete, the verification fails and a warning log is recorded.

[0030] In this embodiment, during the execution of the AOP aspect-based interception method, after parsing the identity header from the target HTTP business operation request, it is determined whether the identity header is complete. If the identity fields in the identity header are complete, the identity header verification passes, and then the subsequent data processing process is executed. That is, the AOP aspect-based interception method triggers the log collection logic to generate log information. The log collection logic is independent of the business operation process corresponding to the target HTTP business operation request. If some fields in the identity header are missing, the verification fails, the log collection process of the AOP aspect-based interception method is directly skipped, the corresponding warning log is recorded directly, and the subsequent process of pushing the log information to the message queue is skipped.

[0031] By employing a fault-tolerant design mechanism for missing identity headers, this application can avoid invalid log collection and push processes, thereby improving the accuracy and reliability of log information recorded in the message queue.

[0032] In one embodiment of this application, the log collection logic of a user operation log collection method based on automatic request header injection includes: collecting log parameters from the operation business corresponding to the business operation type in the target HTTP business operation request, and filling them into a log template with a preset log format to generate log information, wherein the log information is structured log information. Through the setting method of this embodiment, this application can unify the log collection format, solving the problem that existing log recording relies on manual standardization and is prone to omissions, incomplete fields, or inconsistent formats due to negligence. This facilitates querying corresponding log information in a unified log format, making audit tracing easier.

[0033] In one embodiment of this application, the log template includes at least one log term template with a predetermined log format. Log parameters are collected from the operation business corresponding to the business operation type in the target HTTP business operation request and filled into the log template with the preset log format to generate log information. This includes: matching a corresponding selected log term template from at least one log term template according to the business operation type in the target HTTP business operation request, and filling the selected log term template with log parameters. Through this embodiment, this application can select a selected term template matching the business operation type from multiple log term templates based on the business operation type in the target HTTP business operation request, and combine them into a log template corresponding to the current target HTTP business operation request. This allows for dynamic adjustment of the log template when the log term template changes or when it needs to be combined into a log template corresponding to the business operation type, facilitating unified log template updates and aiding in the application of current logging logic and audit trails.

[0034] In one embodiment of this application, at least one log entry template conforms to the encoding rules of internationalized entry templates, and when the internationalized entry template is updated, at least one log entry template is updated synchronously accordingly.

[0035] In this embodiment, the internationalized term template is equipped with a term encoding mechanism and supports multilingual output. When the internationalized term template is updated, the term template of this application is also updated synchronously, ensuring that the log term collection format of this application is always consistent with the internationalized log term format. This makes the final unified log format determined by this application support international standards, which can significantly improve the consistency of log format. When querying log information, it helps to quickly locate and find the target log, shorten the investigation time, and facilitate audit tracing. Moreover, the log format design of this application can be applied to people of various languages, which facilitates internationalization work.

[0036] In one specific embodiment of this application, one way to match the corresponding selected log term template from at least one log term template according to the business operation type in the target HTTP business operation request and fill the selected log term template with log parameters is as follows: the log term template is set with placeholders corresponding to different terms. By replacing the corresponding placeholders with log parameters, the dynamic log parameters are filled into the selected log template. After the filling is completed, structured log information is obtained, and the collection of user operation logs for this round is completed.

[0037] Through the configuration method of this embodiment, this application can complete the collection of corresponding log information by dynamically replacing the placeholders in the log term template with log parameters, and quickly collect the corresponding log information.

[0038] In one specific embodiment of this application, log parameters are collected from the operation business corresponding to the business operation type and filled into a log template with a preset log format to generate log information. This includes: determining the target operation business that carries the annotation specified by the AOP aspect interception method and corresponds to the business operation type; collecting log parameters from the target operation business and filling them into a log template with a preset log format to generate log information.

[0039] As an example, the annotation is specified as @BusinessLogRecord. The specified annotation can be adjusted according to actual business needs.

[0040] Specifically, add the corresponding annotation to the business code that needs to collect logs, so that when the AOP aspect interception method is executed, the annotation can be listened to. With the help of the annotation, the corresponding log term parameters of the target business can be collected non-intrusively, and the log term parameters can be filled into the term template to obtain structured log information.

[0041] With the configuration method of this embodiment, when adding code corresponding to a new business scenario, this application does not need to write detailed log collection code in the code of that business scenario. It only needs to add a corresponding specified annotation to connect to the preset AOP aspect interception method and collect the log information of that business scenario. This can reduce the amount of code written and significantly improve the adaptation speed between business code and log service code, and has good scalability.

[0042] In one specific embodiment of this application, a user operation log collection method based on automatic request header injection further includes asynchronously pushing log information to a message queue. Asynchronous pushing helps reduce thread blocking and resource consumption.

[0043] In one specific embodiment of this application, asynchronously pushing log information to a message queue includes: determining whether the log information has been successfully pushed asynchronously; if not, recording an error log; if so, the log push is complete for use in the business middleware log query.

[0044] Specifically, during the asynchronous push of log information to the message queue, the system checks whether the push was successful. If the push fails, an error log is recorded, and the user operation log collection result is returned. Since the log information construction and asynchronous push processes do not block performance, they do not affect the execution of corresponding business processes in enterprise-level web applications or cloud platform systems. If the log information push is successful, the log push is complete, and the user operation log collection result is returned. Furthermore, the user operation logs pushed to the message queue can be used for log querying in the business middleware of enterprise-level web applications or cloud platform systems.

[0045] By setting up an asynchronous fault tolerance mechanism for log information push failures, this application can ensure that the performance of enterprise-level web applications or cloud platform systems is not blocked during the asynchronous push process, thereby not affecting the execution of corresponding business processes in enterprise-level web applications or cloud platform systems and ensuring the continuity of corresponding business processes.

[0046] Combination Figure 1 The corresponding specific implementation methods and embodiments of this application simplify the data processing process of repeated identification during multi-tenant identity transmission by automatically injecting user identity information into the request header through the API gateway and collecting logs using the AOP aspect interception method. It eliminates the need to explicitly write and call log service code in the business code, greatly reducing the amount of code and data processing involved in writing log service code multiple times. When starting the log collection service, it does not interfere with the normal operation of other businesses, thereby solving the problem of log service code heavily intruding into business logic, deep coupling between business and logs, and the problem of the corresponding log service code being passively and repeatedly running when running business logic, which greatly increases the amount of data processing.

[0047] Furthermore, this application can unify the log format by filling the collected log parameters into a log template with a preset log format, and can quickly and uniformly adjust the log format when adjusting the log term template, thereby reducing maintenance costs.

[0048] In one specific embodiment of this application, the business processing server calls the AOP aspect interception method, including: when the configuration switch of the AOP aspect interception method is enabled, the business processing server calls the AOP aspect interception method to execute the log collection logic; when the configuration switch of the AOP aspect interception method is disabled, the business processing server directly executes the logic corresponding to the operation business.

[0049] As an example, the configuration switch is a switch set in Nacos (Dynamic Naming and Configuration Service) with the name platform_custom_enable_user_log, to dynamically control its start and stop.

[0050] In one specific embodiment of this application, a configuration switch is set before employing the AOP aspect interception method to manually or automatically control whether the AOP aspect interception method is executed to collect user operation logs. When the configuration switch is on, the AOP aspect interception method is executed to collect user operation logs; when the configuration switch is off, the execution process of the AOP aspect interception method is skipped, the corresponding business logic is executed directly, and the corresponding log collection results are returned.

[0051] By setting a configuration switch before executing the AOP aspect interception method, this application can flexibly control whether to collect user operation logs without restarting the service during the operation of the relevant service, reducing the waiting time for restart and helping to improve the operating efficiency of the corresponding business service.

[0052] Figure 2 The diagram shows a schematic flowchart of one embodiment of a user operation log collection method based on automatic request header injection according to this application.

[0053] like Figure 2 As shown in a specific embodiment of this application, the specific implementation process of a user operation log collection method based on automatic injection of request headers includes: In step S201, the API gateway parses the original HTTP business operation request initiated by the user to extract the user's identity information.

[0054] In step S202, the API gateway converts the user's identity information into an identity header and injects it into the request header of the original HTTP business operation request to generate the target HTTP business operation request.

[0055] By setting the target HTTP business operation request, this application can standardize user identity information, simplify business code, and eliminate the backend's need to parse the JSON identity token after it is transmitted to the backend. At the same time, it reduces the repeated transmission and identification of user identity information during the transmission process, making it easier to quickly transmit and identify user identity information.

[0056] Step S203: After the business controller receives the target HTTP business operation request, it determines whether the configuration switch is enabled; if not, proceed to step S204; if yes, proceed to step S205.

[0057] Step S204: Execute the corresponding operation business logic directly and return the log collection results.

[0058] Step S205: Use AOP aspect interception method to obtain the identity header in the target HTTP business operation request and determine whether the identity header is complete; if it is incomplete, proceed to step S206; if it is complete, proceed to step S207.

[0059] Step S206: Record the warning log, skip the log push process, and return the log collection result.

[0060] Step S207: Based on the operation type in the target HTTP business operation request, match the corresponding log term template from the dynamic internationalized term template; obtain the corresponding log parameters from the operation business corresponding to the operation type and fill them into the log term template to generate structured log information.

[0061] Step S208: Asynchronously push the structured log information to the message queue and determine whether the push was successful; if the push was unsuccessful, proceed to step S209; if the push was successful, proceed to step S210.

[0062] Step S209: Record the error log and return the log collection results without affecting the process of other services.

[0063] Step S210: Log push complete, log collection results returned, user operation log collection completed, and the business middle platform connects to the message queue for log querying.

[0064] As an example, the message queue can be Kafka, or other message queues can be used to facilitate unified management of log content in enterprise web applications or cloud platform systems.

[0065] In this embodiment, the log collection results returned in different steps are different, and the return values ​​corresponding to the log collection results are also different. The specific return values ​​can be adjusted according to the actual situation.

[0066] Through the configuration method of this embodiment, this application sequentially employs the following methods: gateway injection of user identity information, AOP aspect interception of services requiring log collection, dynamic matching of internationalized term templates for standard log formats, filling the log term templates with term parameters corresponding to the operational services to generate structured log information, and asynchronously pushing structured log information. This simplifies the data processing process of repeated identification during multi-tenant identity transfer, eliminating the need to explicitly write and call log service code in the business code, greatly reducing the amount of code and data processing involved in writing log service code multiple times. Simultaneously, when starting the log collection service, it does not interfere with the normal operation of other services, thus solving the problem of log service code heavily intruding into business logic, deep coupling between business and logs, and the passive repeated execution of corresponding log service code during business logic execution, which greatly increases the amount of data processing.

[0067] Furthermore, this application generates log information by filling the collected log parameters into a log template with a preset log format, which can unify the log format and adjust the log format uniformly when adjusting the log term template, thereby reducing maintenance costs.

[0068] Furthermore, the identity header missing fault tolerance mechanism and asynchronous fault tolerance mechanism set up in this application can ensure the continuity of related business and not affect the processing performance of the corresponding operation business.

[0069] Secondly, this application returns log collection results after each operation, fully recording the operation trajectory, with an operation log coverage of 100%, which meets the audit requirements.

[0070] In a specific embodiment of this application, taking the "Add AP Settings" scenario as an example, the data processing process for collecting user operation logs is as follows: First, the front-end calls the application programming interface (API) to connect with the user-initiated new operation request; the API gateway injects the user's identity information into the new operation request, generating a new target HTTP business operation request, such as user identity information _tenantId (tenant number) = 1001, _appId (application number) = 2001, _userId (employee number) = 3001, _userName (employee name) = admin; the new target HTTP business operation request is transmitted to the back-end, and the business controller of the back-end business service receives the target HTTP business operation request and transmits it to the AOP aspect interception method for analysis. The AOP aspect interception method calls the corresponding SDK to perform log collection operations.

[0071] Specifically, the software development kit (SDK) for collecting operation logs as described in this application parses identity information from the identity header in the target HTTP business operation request, verifies the integrity of the identity header, and, once the identity header verification is successful, matches the new operation term template according to the new operation in the business operation request, and fills the new operation term template with the parameter information corresponding to the business to generate structured log information, such as "Add AP setting, SSID code: WiFi-AP-001". This structured log information is then asynchronously pushed to Kafka, where it is consumed and stored in the business middleware platform for querying relevant log information.

[0072] By using this log collection method, this application does not intrude on the backend business code or affect the normal operation of the corresponding business during the log collection process. It does not require explicitly writing and calling log service code in the business code, which greatly reduces the amount of code and data processing required to write log service code multiple times. The amount of log-related code is reduced by 90%, the development time of a single interface is shortened by 30%, and the overall operating efficiency of enterprise-level web applications or cloud platform systems is improved.

[0073] Figure 3 This diagram illustrates a schematic structure of a specific implementation of a user operation log collection system based on automatic request header injection according to this application.

[0074] like Figure 3 As shown, in one specific embodiment of this application, this application provides a user operation log collection system 300 based on automatic injection of request headers, which includes a processor 310 and a memory 320 storing a computer program / instruction 41. The processor 310 is configured to execute the user operation log collection method described in any of the above embodiments or implementations when running the computer program / instruction 41.

[0075] Figure 4 A schematic structural diagram of a specific embodiment of a computer-readable storage medium according to this application is shown.

[0076] like Figure 4 As shown, in one specific embodiment of this application, this application also provides a computer-readable storage medium 40 storing a computer program / instructions 41, which is operated to perform the user operation log collection method described in any of the above embodiments or embodiments.

[0077] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0078] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0079] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.

Claims

1. A method for collecting user operation logs based on automatic injection of request headers, characterized in that, include: The API gateway parses the original HTTP business operation request initiated by the user to extract the user's identity information; The API gateway converts the user identity information into an identity header and injects it into the request header of the original HTTP business operation request to generate the target HTTP business operation request. The business processing server calls the AOP aspect interception method to extract and verify the identity header from the target HTTP business operation request; If the verification passes, the AOP aspect interception method triggers log collection logic to generate log information. The log collection logic is independent of the business operation process corresponding to the target HTTP business operation request.

2. The user operation log collection method according to claim 1, characterized in that, The log collection logic collects log parameters from the operation business corresponding to the operation type in the target HTTP business operation request, and fills them into a log template with a preset log format to generate the log information, wherein the log information is structured log information.

3. The user operation log collection method according to claim 2, characterized in that, The step of collecting log parameters from the operation business corresponding to the business operation type and filling them into a log template with a preset log format to generate the log information includes: Identify the target operation business that carries the annotation specified by the AOP aspect interception method and corresponds to the business operation type; The log parameters are collected from the target operation service and filled into a log template with a preset log format to generate the log information.

4. The user operation log collection method according to claim 2, characterized in that, The log template includes at least one log entry template with a predetermined log format, and, The step of collecting log parameters from the operation business corresponding to the operation type in the target HTTP business operation request and filling them into a log template with a preset log format to generate the log information includes: Based on the business operation type in the target HTTP business operation request, a corresponding selected log term template is matched from the at least one log term template, and the log parameters are filled into the selected log term template.

5. The user operation log collection method according to claim 4, characterized in that, The at least one log entry template conforms to the encoding rules for internationalized entry templates, and, When the internationalized term template is updated, the at least one log term template is updated synchronously accordingly.

6. The user operation log collection method according to claim 1, characterized in that, Also includes: The log information is pushed asynchronously to the message queue.

7. The user operation log collection method according to claim 1, characterized in that, The process of the business processing server calling the AOP aspect interception method includes: When the configuration switch for the AOP aspect interception method is enabled, the business processing server invokes the AOP aspect interception method.

8. The user operation log collection method according to claim 1, characterized in that, The verification of the identity header includes: If the identity header extracted from the target HTTP business operation request is complete, the verification passes. The verification fails if the identity header extracted from the target HTTP business operation request is incomplete.

9. A user operation log collection system based on automatic request header injection, comprising a processor and a memory storing computer programs / instructions, characterized in that, The processor is configured to execute the user operation log collection method as described in any one of claims 1-8 when running the computer program / instructions.

10. A computer-readable storage medium storing a computer program / instructions, characterized in that, The computer program / instructions are operated to perform the user operation log collection method as described in any one of claims 1-8.