Audit log recording method and device, electronic equipment and storage medium

By using custom functions and SpringEL for annotation-based configuration parsing within the Spring framework, the problem of coupling between audit log recording and business code is solved, achieving convenient and fast access to audit logs.

CN116483791BActive Publication Date: 2026-06-23KE COM (BEIJING) TECHNOLOGY CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
KE COM (BEIJING) TECHNOLOGY CO LTD
Filing Date
2023-03-10
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

In existing technologies, audit log recording is coupled with business code, making it difficult to obtain audit logs conveniently and quickly.

Method used

By using custom functions and SpringEL within the Spring framework to parse annotation-based configurations and combining them with aspect-oriented programming techniques, we can achieve decoupled logging of event handling content.

Benefits of technology

It enables the acquisition of audit logs based on configuration, reducing the intrusion of business code and improving the convenience and speed of log acquisition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116483791B_ABST
    Figure CN116483791B_ABST
Patent Text Reader

Abstract

The application provides an audit log recording method and device, electronic equipment and a storage medium, which are applied to an application service operating system. The method comprises the following steps: determining an operation event and event processing content, wherein the event processing content is processing content corresponding to code for implementing the operation event; determining a custom function, wherein the custom function is used to determine whether an annotated configuration on the event processing content is parsed before the event processing content is executed or parsed after the event processing content is executed; boxing the custom function into a context of a Spring framework, wherein the Spring framework corresponds to the application service operating system; performing aspect interception on the event processing content to obtain the annotated configuration; parsing the annotated configuration based on the custom function to obtain a parsing result; and obtaining an audit log corresponding to the operation event based on the parsing result. The audit log corresponding to the operation event can be conveniently and quickly obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of log auditing technology, and in particular to an audit log recording method, apparatus, electronic device, and storage medium. Background Technology

[0002] Audit logging is a fundamental function of application service operating systems. Specifically, all business processes involving users are required to be logged.

[0003] As known from relevant technologies, current audit logging requires writing logging code, and this logging code is coupled with business logic, making it difficult to obtain audit logs conveniently and quickly. Therefore, finding a convenient and fast method to obtain audit logs has become a hot research topic. Summary of the Invention

[0004] This invention provides an audit log recording method, apparatus, electronic device, and storage medium, which can decouple business code and log code, and can conveniently and quickly obtain audit logs corresponding to operation events.

[0005] This invention provides an audit log recording method applied to an application service operating system. The method includes: determining an operation event and event processing content, wherein the event processing content is the processing content corresponding to the code implementing the operation event; determining a custom function, wherein the custom function is used to determine whether the annotation-based configuration on the event processing content is parsed before or after the event processing content is executed; boxing the custom function into the context of a Spring framework, wherein the Spring framework corresponds to the application service operating system; performing aspect interception on the event processing content to obtain the annotation-based configuration; parsing the annotation-based configuration based on the custom function to obtain a parsing result; and obtaining an audit log corresponding to the operation event based on the parsing result.

[0006] According to an audit log recording method provided by the present invention, the aspect interception of the event processing content specifically includes: performing aspect interception of the event processing content based on SpringAOP under the Spring framework; the parsing of the annotation-based configuration based on the custom function specifically includes: parsing the annotation-based configuration based on the custom function and SpringEL under the Spring framework.

[0007] According to an audit log recording method provided by the present invention, the step of parsing the annotation-based configuration based on the custom function and SpringEL under the Spring framework to obtain a parsing result specifically includes: classifying the annotation-based configuration based on the custom function to obtain a first annotation-based configuration and a second annotation-based configuration, wherein the first annotation-based configuration is an annotation-based configuration parsed before the execution of the event handling content, and the second annotation-based configuration is an annotation-based configuration parsed after the execution of the event handling content; before the execution of the event handling content, parsing the first annotation-based configuration based on SpringEL to obtain a first parsing result; after the execution of the event handling content, parsing the second annotation-based configuration based on SpringEL to obtain a second parsing result; and obtaining the parsing result based on the first parsing result and the second parsing result.

[0008] According to an audit log recording method provided by the present invention, after classifying the annotation-based configuration based on the custom function to obtain a first annotation-based configuration and a second annotation-based configuration, the method further includes: storing the first annotation-based configuration in a first virtual memory; storing the second annotation-based configuration in a second virtual memory; the step of parsing the first annotation-based configuration based on SpringEL to obtain a first parsing result before the execution of the event handling content specifically includes: traversing the first virtual memory and parsing the first annotation-based configuration based on SpringEL to obtain a first parsing result before the execution of the event handling content; the step of parsing the second annotation-based configuration based on SpringEL to obtain a second parsing result after the execution of the event handling content specifically includes: traversing the second virtual memory and parsing the second annotation-based configuration based on SpringEL to obtain a second parsing result after the execution of the event handling content.

[0009] According to an audit log recording method provided by the present invention, after classifying the annotation-based configuration based on the custom function to obtain a first annotation-based configuration and a second annotation-based configuration, the method further includes: obtaining a first attribute key value corresponding to the first annotation-based configuration and a first value expression string corresponding to the first attribute key value based on the first annotation-based configuration; the step of parsing the first annotation-based configuration based on SpringEL to obtain a first parsing result specifically includes: creating a first input parameter for SpringEL parsing corresponding to the first value expression string based on SpringEL; converting the first value expression string into a first expression object based on the first input parameter; calling a language function to obtain a first parsing value after parsing the first expression object, and using the first parsing value as the first parsing result.

[0010] According to an audit log recording method provided by the present invention, after classifying the annotation-based configuration based on the custom function to obtain a first annotation-based configuration and a second annotation-based configuration, the method further includes: obtaining a second attribute key value corresponding to the second annotation-based configuration and a second value expression string corresponding to the second attribute key value based on the second annotation-based configuration; the step of parsing the second annotation-based configuration based on SpringEL to obtain a second parsing result specifically includes: creating a second input parameter for SpringEL parsing corresponding to the second value expression string based on SpringEL; converting the second value expression string into a second expression object based on the second input parameter; calling a language function to obtain the second parsing value after parsing the second expression object, and using the second parsing value as the second parsing result.

[0011] According to an audit log recording method provided by the present invention, after obtaining the audit log corresponding to the operation event based on the parsing result, the method further includes: automatically wiring the bean class corresponding to the Spring framework based on Spring Boot under the Spring framework; extending the storage interface based on the bean class; and calling the storage interface to store the audit log in the storage interface.

[0012] This invention also provides an audit log recording device applied to an application service operating system. The device includes: a first module for determining an operation event and event processing content, wherein the event processing content is the processing content corresponding to the code implementing the operation event; a second module for determining a custom function, wherein the custom function is used to determine whether the annotation-based configuration on the event processing content is parsed before or after the event processing content is executed; a third module for boxing the custom function into the context of a Spring framework, wherein the Spring framework corresponds to the application service operating system; a fourth module for performing aspect interception on the event processing content to obtain the annotation-based configuration; a fifth module for parsing the annotation-based configuration based on the custom function to obtain a parsing result; and a sixth module for obtaining an audit log corresponding to the operation event based on the parsing result.

[0013] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the audit log recording method as described above.

[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the audit log recording method as described above.

[0015] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the audit log recording method as described above.

[0016] The audit log recording method, apparatus, electronic device, and storage medium provided by this invention intercept event processing content through aspect-oriented programming to obtain annotation-based configuration. Then, based on a custom function, it determines whether the annotation-based configuration of the event processing content needs to be parsed before or after the event processing content is executed, and parses the annotation-based configuration to obtain the parsing result, thereby obtaining the audit log corresponding to the operation event. This achieves the acquisition of audit logs based on a configuration-based approach, thereby decoupling business code and logging code, and enabling convenient and rapid acquisition of audit logs corresponding to operation events. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in this invention 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 invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0018] Figure 1 This is one of the flowcharts illustrating the audit log recording method provided by the present invention;

[0019] Figure 2 This is one of the flowcharts provided by the present invention for parsing annotation-based configurations based on custom functions and SpringEL to obtain the parsing results;

[0020] Figure 3 This is the second flowchart provided by the present invention, which parses annotation-based configuration based on custom functions and SpringEL to obtain the parsing results.

[0021] Figure 4 This is a flowchart illustrating the process of determining the first analytical result provided by the present invention;

[0022] Figure 5 This is a flowchart illustrating the process of determining the second analytical result provided by the present invention;

[0023] Figure 6 This is the second flowchart illustrating the audit log recording method provided by the present invention;

[0024] Figure 7 This is the third flowchart illustrating the audit log recording method provided by the present invention;

[0025] Figure 8 This is a schematic diagram of the structure of the audit log recording device provided by the present invention;

[0026] Figure 9 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0027] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0028] The audit log recording method provided by this invention can be applied to an application service operating system. The application service operating system can be used to execute operation events, and this invention can obtain audit logs related to these operation events. In another example, the audit log recording method provided by this invention can also be implemented through an SDK component. This SDK component may include Spring Boot auto-wiring beans; it may include Spring AOP aspect-based logic processing; it may include custom function context boxing, custom function encapsulation of threadLocal storage map objects; and it may also include interface extensions for operation log information storage methods. During application, only the event handling content needs to be configured to collect and store operation log information in the database, thereby decoupling business code and logging code, and thus enabling convenient and rapid acquisition of audit logs corresponding to operation events. It should be noted that the event handling content can be understood as the target method involved in the execution of Spring AOP, where the target method is the method corresponding to the business code that implements the operation event.

[0029] It should be noted that the audit log recording method provided by this invention can be applied to service operations executed by various application service operating systems. During the application process, there is no need to repeatedly develop modules related to audit log recording, thereby achieving low cost and scalability of audit log recording.

[0030] Figure 1 This is one of the flowcharts illustrating the audit log recording method provided by the present invention.

[0031] To further introduce the audit log recording method provided by this invention, the following will be combined with... Figure 1 Please provide an explanation.

[0032] In an exemplary embodiment of the present invention, the audit log recording method can be applied to an application service operating system, wherein the application service operating system can be used to execute operation events. Combined with... Figure 1 As can be seen, the audit log recording method may include steps 110 to 160, and each step will be described below.

[0033] In step 110, the operation event and the event handling content are determined, wherein the event handling content is the handling content corresponding to the code that implements the operation event.

[0034] In one embodiment, an operation event can be identified. This operation event can be considered as an operation event executed based on the application service operating system. During the execution of the operation event based on the application service operating system, relevant logs, i.e., audit logs, need to be recorded. In one example, if the operation event of operator M changing dispatcher A to dispatcher B is executed based on the application service operating system, the audit log "Operator M changes dispatcher A to dispatcher B" needs to be recorded.

[0035] In step 120, a custom function is determined, wherein the custom function is used to determine whether the annotation configuration on the event handling content is parsed before or after the event handling content is executed.

[0036] In one embodiment, a custom function can be used to determine whether annotation-based configurations on event handling content are parsed before or after the event handling content is executed. During application, the custom function can determine whether the parsing of a certain attribute configuration (corresponding to annotation-based configuration) on the event handling content needs to be performed before or after the event handling content is executed. In one example, if the custom function determines that configuration parsing occurs before the event handling content is executed, and you want to obtain the primary key ID of the newly inserted data, you need to implement a custom function to obtain the primary key ID and set this function to execute after the event handling content is executed.

[0037] In step 130, the custom function is boxed into the context of the Spring framework, which corresponds to the service operating system.

[0038] In step 140, the event handling content is intercepted by aspect to obtain annotation-based configuration.

[0039] In one embodiment, the defined custom function can be boxed into the context of the Spring framework corresponding to the service's operating system. Furthermore, aspect interception can be performed on the event handling content based on Spring AOP within the Spring framework to obtain the annotation-based configuration of the event handling content. This annotation-based configuration can include the event handling content, the logging content configured on the event handling content, and the input parameters of the event handling content.

[0040] In step 150, the annotation-based configuration is parsed based on the user-defined function to obtain the parsing result.

[0041] In one embodiment, annotation-based configuration can be parsed based on custom functions and SpringEL under the Spring framework.

[0042] Figure 2This is one of the flowcharts provided by the present invention for parsing annotation-based configurations based on custom functions and SpringEL to obtain the parsing results.

[0043] The following will combine Figure 2 This paper explains the process of parsing annotation-based configurations using custom functions and SpringEL to obtain the parsing results.

[0044] In an exemplary embodiment of the present invention, combined with Figure 2 As can be seen, based on custom functions and SpringEL, the annotation-based configuration is parsed, and the parsing results can include steps 210 to 240. Each step will be described below.

[0045] In step 210, the annotation-based configurations are classified based on the user-defined functions to obtain the first annotation-based configuration and the second annotation-based configuration.

[0046] The first annotation-based configuration is an annotation-based configuration that is parsed before the event handling content is executed, and the second annotation-based configuration is an annotation-based configuration that is parsed after the event handling content is executed.

[0047] In one embodiment, the annotation-based configuration of event handling content can be categorized based on a custom function to obtain a first annotation-based configuration that needs to be parsed before the event handling content is executed, and a second annotation-based configuration that needs to be parsed after the event handling content is executed. This embodiment effectively distinguishes between the first and second annotation-based configurations.

[0048] In step 220, before the event handling content is executed, the first annotation-based configuration is parsed based on SpringEL to obtain the first parsing result.

[0049] In step 230, after the event handling content is executed, the second annotation-based configuration is parsed based on SpringEL to obtain the second parsing result.

[0050] In step 240, the parsing result is obtained based on the first parsing result and the second parsing result.

[0051] In one embodiment, before the event handling content is executed, each first annotation-based configuration can be parsed using SpringEL to obtain a first parsing result. Furthermore, after the event handling content is executed, each second annotation-based configuration can be parsed using SpringEL to obtain a second parsing result. Then, based on the correspondence between the first and second parsing results, the first and second parsing results are combined to obtain the final parsing result. The parsing result corresponds to the audit log.

[0052] In step 160, based on the parsing results, the audit log corresponding to the operation event is obtained.

[0053] In one embodiment, audit logs corresponding to operation events can be obtained based on the parsing results. In this embodiment, audit logs are obtained through a configurable method, thereby decoupling business code and logging code, and thus enabling convenient and rapid acquisition of audit logs corresponding to operation events. During application, accessing user operation logs through a configurable method can achieve low intrusion into business code, and also enables rapid access, reducing access costs.

[0054] The audit log recording method provided by this invention intercepts event processing content using aspect recognition to obtain annotation-based configuration. Then, based on a custom function, it determines whether the annotation-based configuration needs to be parsed before or after the event processing content is executed, and parses the annotation-based configuration to obtain the parsing result, thereby obtaining the audit log corresponding to the operation event. This achieves audit log acquisition based on configuration, thereby decoupling business code and logging code, and enabling convenient and fast acquisition of audit logs corresponding to operation events.

[0055] Figure 3 This is the second flowchart provided by the present invention, which parses annotation-based configurations based on custom functions and SpringEL to obtain the parsing results.

[0056] To further introduce the audit log recording method provided by this invention, the following will be combined with... Figure 3 Please provide an explanation.

[0057] In an exemplary embodiment of the present invention, combined with Figure 3 As can be seen, based on custom functions and SpringEL, the annotation-based configuration is parsed to obtain the parsing result, which may include steps 310 to 360. Step 310 is the same as or similar to step 210, and step 360 is the same as or similar to step 240. For the specific implementation and beneficial effects, please refer to the previous description. In this embodiment, they will not be repeated. Steps 320 to 350 will be introduced below.

[0058] In step 320, the first annotation-based configuration is stored in the first virtual memory.

[0059] In step 330, the second annotation-based configuration is stored in the second virtual memory.

[0060] In one embodiment, the first annotation-based configuration can be stored in a first virtual memory, such as map1, and the second annotation-based configuration can be stored in a second virtual memory, such as map2. By storing the first and second annotation-based configurations in different virtual memories, it is easier to parse the first and second annotation-based configurations based on SpringEL, thereby obtaining comprehensive parsing results and laying the foundation for obtaining accurate audit logs.

[0061] In another example, when performing context boxing on custom functions, all custom functions can be stored in memory with the method name as the key and the function implementation class bean as the value. When the application service's operating system starts the corresponding operation service, it can be loaded, making it easier for Spring EL to retrieve the corresponding implementation class based on the function method name when resolving the function. In yet another example, ThreadLocal can also be defined. <map>The object is a map object defined in a custom function. It stores the function method name as the key and the corresponding return object as the value. This can solve the problem of having to call the function method multiple times when using multiple fields in the return object in the annotation configuration.

[0062] In step 340, before the event handling content is executed, the first virtual memory is traversed, and the first annotation-based configuration is parsed based on SpringEL to obtain the first parsing result.

[0063] In step 350, after the event handling content is executed, the second virtual memory is traversed, and the second annotation-based configuration is parsed based on SpringEL to obtain the second parsing result.

[0064] In step 360, the parsing result is obtained based on the first parsing result and the second parsing result.

[0065] In one embodiment, the first virtual memory can be traversed before the event handling content is executed, thereby ensuring that each first annotation-based configuration is parsed using Spring EL to obtain a first parsing result. Furthermore, the second virtual memory can be traversed after the event handling content is executed, thereby ensuring that each second annotation-based configuration is parsed using Spring EL to obtain a second parsing result. Then, based on the correspondence between the first and second parsing results, the first and second parsing results are combined to obtain the final parsing result. The parsing result corresponds to the audit log.

[0066] Figure 4 This is a flowchart illustrating the process of determining the first analytical result provided by the present invention.

[0067] The following will combine Figure 4 The process of determining the first analytical result is explained.

[0068] In an exemplary embodiment of the present invention, combined with Figure 4 As can be seen, determining the first analysis result may include steps 410 to 450, wherein step 410 is the same as or similar to step 210. For the specific implementation and beneficial effects, please refer to the previous description. In this embodiment, it will not be repeated. Steps 420 to 450 will be described below.

[0069] In step 420, based on the first annotation-based configuration, the first attribute key value corresponding to the first annotation-based configuration and the first value expression string corresponding to the first attribute key value are obtained.

[0070] In one embodiment, based on the first annotation-based configuration, a first attribute key value corresponding to the first annotation-based configuration and a first value expression string corresponding to the first attribute key value can be obtained. The first attribute key value and the first value expression string are corresponding. During application, by parsing the first parsing result of the first value expression string, the operation logs prior to the execution of the event handling content can be determined.

[0071] In step 430, based on SpringEL, the first input parameter corresponding to the first value expression string is created by SpringEL parsing.

[0072] In step 440, the first value expression string is converted into a first expression object based on the first input parameter.

[0073] In step 450, the language function is called to obtain the first parsed value of the first expression object, and the first parsed value is used as the first parsing result.

[0074] In one embodiment, during the parsing of the value expression string (corresponding to the first value expression string) of the attribute executed before the event handling content is executed, a MethodBasedEvaluationContext context object can be created first as the input parameter for the core parsing of Spring EL (corresponding to the first input parameter). Further, by inheriting the SpelExpressionParser class and overriding the parseExpression method to pass in the TemplateParserContext context, and by inheriting the CachedExpressionEvaluator class and calling the getExpression method to convert the first value expression string into an Expression object (corresponding to the first expression object), and then calling the getValue method to obtain the parsed value of the expression (corresponding to the first expression object), the core parsing of Spring EL expressions is achieved, i.e., the first parsing result is obtained. Through this embodiment, audit logs related to the execution of event handling content can be obtained without writing logging code, thereby decoupling business code and logging code, and thus enabling convenient and fast acquisition of audit logs corresponding to the operation event.

[0075] Figure 5 This is a flowchart illustrating the process of determining the second analytical result provided by the present invention.

[0076] The following will combine Figure 5 The process of determining the second analytical result is explained.

[0077] In an exemplary embodiment of the present invention, combined with Figure 5 As can be seen, determining the second analysis result may include steps 510 to 550, wherein step 510 is the same as or similar to step 210. For the specific implementation and beneficial effects, please refer to the previous description. In this embodiment, it will not be repeated. Steps 520 to 550 will be described below.

[0078] In step 520, based on the second annotation-based configuration, the second attribute key value corresponding to the second annotation-based configuration and the second value expression string corresponding to the second attribute key value are obtained.

[0079] In one embodiment, a second attribute key value corresponding to the second annotation-based configuration and a second value expression string corresponding to the second attribute key value can be obtained based on the second annotation-based configuration. The second attribute key value and the second value expression string are corresponding. During application, by parsing the second parsing result of the second value expression string, the operation log after the execution of the event handling content can be determined.

[0080] In step 530, based on SpringEL, a second input parameter corresponding to the second value expression string is created for SpringEL parsing.

[0081] In step 540, the second value expression string is converted into a second expression object based on the second input parameter.

[0082] In step 550, a language function is called to obtain the second parsed value after parsing the second expression object, and the second parsed value is used as the second parsing result.

[0083] In one embodiment, during the parsing of the value expression string (corresponding to the second value expression string) of the attribute executed after the event handling content is executed, a MethodBasedEvaluationContext context object can be created first as the input parameter for the core parsing of Spring EL (corresponding to the second input parameter). Further, the SpelExpressionParser class is inherited, the parseExpression method is overridden to pass in the TemplateParserContext context, and the CachedExpressionEvaluator class is inherited to call the getExpression method to convert the second value expression string into an Expression object (corresponding to the second expression object). Then, the getValue method is called to obtain the parsed value of the expression (corresponding to the second expression object), thus achieving the core parsing of Spring EL expressions, i.e., obtaining the second parsing result. Through this embodiment, audit logs related to the execution of event handling content can be obtained without writing logging code, thereby decoupling business code and logging code, and enabling convenient and quick acquisition of audit logs corresponding to the operation event.

[0084] Figure 6 This is the second flowchart of the audit log recording method provided by the present invention.

[0085] The following will combine Figure 6 The process of another audit log recording method provided by the present invention will be described.

[0086] In an exemplary embodiment of the present invention, combined with Figure 6 As can be seen, the audit log recording method may include steps 610 to 690, wherein steps 610 to 660 are the same as or similar to steps 110 to 160. For the specific implementation and beneficial effects, please refer to the previous description. In this embodiment, they will not be repeated. Steps 670 to 690 will be described below.

[0087] In step 670, Spring Boot autowiring is performed based on the Spring framework to automatically configure the corresponding bean classes of the Spring framework.

[0088] In step 680, a storage interface is extended based on the bean class.

[0089] In step 690, the storage interface is invoked to store the audit logs.

[0090] In one embodiment, a configuration class based on Spring Boot's autowiring of bean classes can be designed, allowing the extension of the bean classes to create a log information storage interface. In another embodiment, other methods can be used to autowiring bean classes corresponding to the Spring framework. This embodiment does not specifically limit the autowiring of bean classes corresponding to the Spring framework. The bean class can be registered using the `@ConditionalOnMissingBean` annotation. During application execution, the storage interface can be called to store audit logs. In yet another example, after storing audit logs through the storage interface, a message about the audit logs can be sent to the user. Both the business component provider and the service provider can consume and store this message, and the business component can further process the storage interface to meet its specific needs.

[0091] Figure 7 This is the third flowchart illustrating the audit log recording method provided by the present invention;

[0092] To further introduce the audit log recording method provided by this invention, the following will be combined with... Figure 7 Please provide an explanation.

[0093] In an exemplary embodiment of the present invention, combined with Figure 7 As can be seen, the audit log recording method may include steps 710 to 790, and each step will be described below.

[0094] In step 710, beans are automatically assembled.

[0095] In one embodiment, a configuration class based on Spring Boot's autowiring bean class can be designed, thereby extending the bean class to create a log information storage interface for storing the final audit logs corresponding to the operation events.

[0096] In step 720, the custom function context is boxed.

[0097] In step 730, aspect interception is performed based on SpringAOP.

[0098] In one embodiment, the defined custom function can be boxed into the context of the Spring framework corresponding to the service's operating system. Furthermore, aspect interception can be performed on the event handling content based on Spring AOP to obtain the annotation-based configuration of the event handling content. The annotation-based configuration can include the event handling content, the logging content configured on the event handling content, and the input parameters of the event handling content, etc.

[0099] In step 740, the attributes configured on the event handling content are categorized and stored in maps: map1, which needs to be parsed before the event handling content is executed, and map2, which needs to be parsed after the event handling content is executed.

[0100] In one embodiment, map1 stores a first annotation-based configuration that needs to be parsed before the event handling content is executed, and map2 stores a second annotation-based configuration that needs to be parsed after the event handling content is executed.

[0101] In step 750, map1 is looped to perform SpringEL expression parsing on the value expression string to obtain the first parsing result.

[0102] In step 760, the event handling content is executed.

[0103] In step 770, map2 is looped to perform SpringEL expression parsing on the value expression string, resulting in the second parsing result.

[0104] In step 780, the parsed first and second parsing results are stored in the log information object.

[0105] In step 790, the audit log corresponding to the operation event is obtained.

[0106] In one embodiment, map1 (corresponding to the first virtual memory) can be traversed before the event handling content is executed, thereby ensuring that each first annotation-based configuration is parsed using SpringEL to obtain the first parsing result. During application, the first value expression string corresponding to the first annotation-based configuration can be parsed using SpringEL to obtain the first parsing result.

[0107] Furthermore, after the event handling content is executed, map2 (corresponding to the second virtual memory) can be traversed to ensure that each second annotation-based configuration is parsed using SpringEL to obtain the second parsing result. During application, the second value expression string corresponding to the second annotation-based configuration can be parsed using SpringEL to obtain the second parsing result.

[0108] Based on the correspondence between the first and second parsing results, the first and second parsing results are combined accordingly to obtain the final parsing result. This parsing result corresponds to the audit log. This embodiment achieves the acquisition of audit logs in a configuration-based manner, thereby decoupling business code and logging code, and enabling convenient and rapid acquisition of audit logs corresponding to operation events.

[0109] As described above, the audit log recording method provided by this invention uses Spring AOP to intercept event handling content, obtaining annotation-based configuration. Then, based on a custom function, it determines whether the annotation-based configuration of the event handling content needs to be parsed before or after the event handling content is executed. Finally, it combines Spring EL to parse the annotation-based configuration, obtaining the parsing result, thereby obtaining the audit log corresponding to the operation event. This achieves the acquisition of audit logs based on a configuration-based approach, thereby decoupling business code and logging code, and enabling convenient and fast acquisition of audit logs corresponding to operation events.

[0110] Based on the same concept, the present invention also provides an audit log recording device.

[0111] The audit log recording device provided by the present invention is described below. The audit log recording device described below can be referred to in correspondence with the audit log recording method described above.

[0112] Figure 8 This is a schematic diagram of the audit log recording device provided by the present invention.

[0113] In an exemplary embodiment of the present invention, the audit log recording device can be applied to an application service operating system. The audit log recording device may include a first module 810 to a sixth module 860, each of which will be described below.

[0114] The first module 810 can be configured to determine the operation event and the event handling content, wherein the event handling content is the processing content corresponding to the code that implements the operation event;

[0115] The second module 820 can be configured to determine a custom function, wherein the custom function is used to determine whether the annotation configuration on the event handling content is parsed before or after the event handling content is executed.

[0116] The third module 830 can be configured to box custom functions into the context of the Spring framework, which corresponds to the application service operating system;

[0117] The fourth module 840 can be configured to intercept event handling content using aspects, resulting in annotation-based configuration;

[0118] Module 850 can be configured to parse annotation-based configurations based on custom functions and obtain the parsing results.

[0119] The sixth module 860 can be configured to obtain audit logs corresponding to operation events based on the parsing results.

[0120] In an exemplary embodiment of the present invention, the fourth module 840 may perform aspect interception on the event processing content in the following manner: based on SpringAOP under the Spring framework, aspect interception on the event processing content is performed.

[0121] Module 5, 850, can be implemented using custom functions to parse annotation-based configurations in the following way: based on custom functions and SpringEL under the Spring framework, annotation-based configurations can be parsed.

[0122] In an exemplary embodiment of the present invention, the fifth module 850 can implement the parsing of annotation-based configuration based on custom functions and SpringEL under the Spring framework to obtain the parsing result in the following manner:

[0123] Based on custom functions, annotation-based configurations are classified into first annotation-based configurations and second annotation-based configurations. The first annotation-based configuration is an annotation-based configuration that is parsed before the execution of event handling content, and the second annotation-based configuration is an annotation-based configuration that is parsed after the execution of event handling content.

[0124] Before the event handling content is executed, the first annotation-based configuration is parsed based on SpringEL to obtain the first parsing result;

[0125] After the event handling content is executed, the second annotation-based configuration is parsed based on SpringEL to obtain the second parsing result;

[0126] Based on the first and second parsing results, the parsing result is obtained.

[0127] In an exemplary embodiment of the present invention, the fifth module 850 may further be configured to:

[0128] Store the first annotation-based configuration in the first virtual memory;

[0129] Store the second annotation-based configuration to the second virtual memory;

[0130] Module 850 can also be implemented in the following way: before the event handling content is executed, based on SpringEL, the first annotation-based configuration is parsed to obtain the first parsing result:

[0131] Before the event handling content is executed, the first virtual memory is traversed, and the first annotation-based configuration is parsed based on SpringEL to obtain the first parsing result;

[0132] Module 850 can also be implemented in the following way: after the event handling content is executed, based on SpringEL, the second annotation-based configuration is parsed to obtain the second parsing result:

[0133] After the event handling content is executed, the second virtual memory is traversed, and the second annotation-based configuration is parsed based on SpringEL to obtain the second parsing result.

[0134] In an exemplary embodiment of the present invention, the fifth module 850 may further be configured to:

[0135] Based on the first annotation-based configuration, obtain the first attribute key value corresponding to the first annotation-based configuration, and the first value expression string corresponding to the first attribute key value;

[0136] Module 850 can also be implemented using SpringEL to parse the first annotation-based configuration and obtain the first parsing result:

[0137] Based on SpringEL, create the first input parameter that corresponds to the first value expression string in SpringEL parsing;

[0138] Based on the first input parameter, convert the first value expression string into a first expression object;

[0139] Call the language function to get the first parsed value of the first expression object, and use the first parsed value as the first parsing result.

[0140] In an exemplary embodiment of the present invention, the fifth module 850 may further be configured to:

[0141] Based on the second annotation-based configuration, the second attribute key value corresponding to the second annotation-based configuration and the second value expression string corresponding to the second attribute key value are obtained;

[0142] Module 850 can also be implemented using SpringEL to parse the second annotation-based configuration and obtain the second parsing result:

[0143] Based on SpringEL, create a second input parameter that corresponds to the second value expression string parsed by SpringEL;

[0144] Based on the second input parameter, convert the second value expression string into a second expression object;

[0145] Call the language function to obtain the second parsed value after parsing the second expression object, and use the second parsed value as the second parsing result.

[0146] In an exemplary embodiment of the present invention, the sixth module 860 may further be configured to:

[0147] Based on the Spring framework, Spring Boot automatically configures the corresponding bean classes of the Spring framework;

[0148] Based on the bean class, extend the storage interface;

[0149] Call the storage interface to store the audit logs.

[0150] Figure 9 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 9 As shown, the electronic device may include: a processor 910, a communication interface 920, a memory 930, and a communication bus 940, wherein the processor 910, the communication interface 920, and the memory 930 communicate with each other through the communication bus 940. The processor 910 can call logical instructions in the memory 930 to execute an audit log recording method applied to an application service operating system. The method includes: determining an operation event and event processing content, wherein the event processing content is the processing content corresponding to the code implementing the operation event; determining a custom function, wherein the custom function is used to determine whether the annotation-based configuration on the event processing content is parsed before or after the event processing content is executed; boxing the custom function into the context of the Spring framework, wherein the Spring framework corresponds to the application service operating system; performing aspect interception on the event processing content to obtain the annotation-based configuration; parsing the annotation-based configuration based on the custom function to obtain a parsing result; and obtaining an audit log corresponding to the operation event based on the parsing result.

[0151] Furthermore, the logical instructions in the aforementioned memory 930 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0152] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the audit log recording method provided by the above methods, applied to an application service operating system. The method includes: determining an operation event and event processing content, wherein the event processing content is the processing content corresponding to the code implementing the operation event; determining a custom function, wherein the custom function is used to determine whether the annotation configuration on the event processing content is parsed before or after the event processing content is executed; boxing the custom function into the context of the Spring framework, wherein the Spring framework corresponds to the application service operating system; performing aspect interception on the event processing content to obtain the annotation configuration; parsing the annotation configuration based on the custom function to obtain a parsing result; and obtaining an audit log corresponding to the operation event based on the parsing result.

[0153] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the audit logging method provided by the above methods, applied to an application service operating system. The method includes: determining an operation event and event processing content, wherein the event processing content is the processing content corresponding to the code implementing the operation event; determining a custom function, wherein the custom function is used to determine whether the annotation-based configuration on the event processing content is parsed before or after the event processing content is executed; boxing the custom function into the context of a Spring framework, wherein the Spring framework corresponds to the application service operating system; performing aspect interception on the event processing content to obtain the annotation-based configuration; parsing the annotation-based configuration based on the custom function to obtain a parsing result; and obtaining an audit log corresponding to the operation event based on the parsing result.

[0154] The device embodiments described above are merely illustrative. 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 modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0155] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0156] It is further understood that although the operations are described in a specific order in the accompanying drawings in the embodiments of the present invention, this should not be construed as requiring these operations to be performed in the specific order or serial order shown, or requiring all the operations shown to obtain the desired result. In certain environments, multitasking and parallel processing may be advantageous.

[0157] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.< / map>

Claims

1. An audit log recording method, characterized in that, Applied to an application service operating system, the method includes: Determine the operation event and the event handling content, wherein the event handling content is the processing content corresponding to the code that implements the operation event; Determine a custom function, wherein the custom function is used to determine whether the annotation configuration on the event handling content is parsed before the event handling content is executed or after the event handling content is executed; The custom function is boxed into the context of the Spring framework, wherein the Spring framework corresponds to the operating system of the application service; The event handling content is intercepted by aspect to obtain the annotation-based configuration; Based on the custom function, the annotation-based configuration is parsed to obtain a parsing result. Specifically, parsing the annotation-based configuration based on the custom function includes: Based on the custom function and SpringEL under the Spring framework, the annotation-based configuration is parsed. Specifically, the parsing of the annotation-based configuration based on the custom function and SpringEL under the Spring framework to obtain the parsing result includes: Based on the custom function, the annotation-based configuration is classified to obtain a first annotation-based configuration and a second annotation-based configuration. The first annotation-based configuration is an annotation-based configuration that is parsed before the execution of the event handling content, and the second annotation-based configuration is an annotation-based configuration that is parsed after the execution of the event handling content. Before the event handling content is executed, the first annotation-based configuration is parsed based on SpringEL to obtain the first parsing result; After the event handling content is executed, the second annotation-based configuration is parsed based on SpringEL to obtain the second parsing result; Based on the first analysis result and the second analysis result, the analysis result is obtained; Based on the analysis results, the audit log corresponding to the operation event is obtained.

2. The audit log recording method according to claim 1, characterized in that, The aspect interception of the event handling content specifically includes: Based on SpringAOP under the Spring framework, aspect interception is performed on the event handling content.

3. The audit log recording method according to claim 1, characterized in that, After classifying the annotation-based configurations based on the custom function to obtain a first annotation-based configuration and a second annotation-based configuration, the method further includes: Store the first annotation-based configuration to the first virtual memory; Store the second annotation-based configuration to the second virtual memory; Before the event handling content is executed, the first annotation-based configuration is parsed based on SpringEL to obtain a first parsing result, specifically including: Before the event handling content is executed, the first virtual memory is traversed, and the first annotation-based configuration is parsed based on SpringEL to obtain the first parsing result; After the event handling content is executed, the second annotation-based configuration is parsed based on SpringEL to obtain a second parsing result, specifically including: After the event handling content is executed, the second virtual memory is traversed, and the second annotation-based configuration is parsed based on SpringEL to obtain the second parsing result.

4. The audit log recording method according to claim 1, characterized in that, After classifying the annotation-based configurations based on the custom function to obtain a first annotation-based configuration and a second annotation-based configuration, the method further includes: Based on the first annotation-based configuration, a first attribute key value corresponding to the first annotation-based configuration and a first value expression string corresponding to the first attribute key value are obtained; The process of parsing the first annotation-based configuration based on SpringEL to obtain a first parsing result specifically includes: Based on the SpringEL, create the first input parameter that corresponds to the first value expression string in the SpringEL parsing; Based on the first input parameter, the first value expression string is converted into a first expression object; Call the language function to obtain the first parsed value of the first expression object, and use the first parsed value as the first parsing result.

5. The audit log recording method according to claim 1 or 4, characterized in that, After classifying the annotation-based configurations based on the custom function to obtain a first annotation-based configuration and a second annotation-based configuration, the method further includes: Based on the second annotation-based configuration, a second attribute key value corresponding to the second annotation-based configuration and a second value expression string corresponding to the second attribute key value are obtained; The process of parsing the second annotation-based configuration based on SpringEL to obtain a second parsing result specifically includes: Based on the SpringEL, create a second input parameter that corresponds to the second value expression string parsed by SpringEL; Based on the second input parameter, the second value expression string is converted into a second expression object; Call the language function to obtain the second parsed value of the second expression object, and use the second parsed value as the second parsing result.

6. The audit log recording method according to claim 1, characterized in that, After obtaining the audit log corresponding to the operation event based on the parsing result, the method further includes: Based on the Spring Boot auto-wiring of the Spring framework and the corresponding bean classes of the Spring framework; Based on the aforementioned bean class, a storage interface is extended; Call the storage interface to store the audit logs.

7. An audit log recording device, characterized in that, Applied to an application service operating system, the apparatus is used to implement the audit log recording method according to any one of claims 1 to 6, the apparatus comprising: The first module is used to determine the operation event and the event handling content, wherein the event handling content is the processing content corresponding to the code that implements the operation event; The second module is used to determine a custom function, wherein the custom function is used to determine whether the annotation configuration on the event handling content is parsed before the event handling content is executed or after the event handling content is executed; The third module is used to box the custom function into the context of the Spring framework, wherein the Spring framework corresponds to the application service operating system; The fourth module is used to perform aspect interception on the event handling content to obtain the annotation-based configuration; The fifth module is used to parse the annotation-based configuration based on the custom function to obtain the parsing result; The sixth module is used to obtain the audit log corresponding to the operation event based on the parsing results.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the audit log recording method as described in any one of claims 1 to 6.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the audit log recording method as described in any one of claims 1 to 6.