Log unification method, device and equipment based on framework encapsulation, and medium
Through a framework-based encapsulation method, the microservice logs of the financial payment system are processed in format encapsulation, exception capture, etc., which solves the problem of unified inefficiency caused by the difference in log structure and style, and realizes unified and efficient processing of logs.
Patent Information
- Application Number
- CN202411715835.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-14
AI Technical Summary
The log structure, style and specifications of each microservice in the financial payment system are different, resulting in low log uniformity efficiency, and each microservice needs to redevelop customized log packaging, resulting in resource cost consumption and inefficiency.
The log unification method based on framework encapsulation is adopted. By initializing the log factory and financial log objects, log format encapsulation, exception capture, interface parameter unification, link tracing, log desensitization and ultra-long log control are achieved to achieve comprehensive encapsulation and unification of logs.
It realizes the unified format and efficiency of logs, facilitates troubleshooting and problem location, reduces resource cost consumption, and improves the efficiency of log uniformity.
Smart Images

Figure CN119621015A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of log monitoring and financial technology, and in particular to a log unification method, device, equipment and medium based on framework encapsulation. Background Art
[0002] Financial payment systems often provide multiple microservices. In order to monitor and optimize the financial payment system, it is necessary to analyze the logs of each microservice of the financial payment system. Since the log structure, log style, and log specifications between different microservices may be different, the logs of the financial system need to be unified.
[0003] Most of the existing log unification methods are based on simple log frameworks, which only provide the functions of recording points and output archiving. In actual applications, the cycles and startup times of various microservice projects in financial payment systems are different. On the other hand, although microservices are highly decoupled, it is difficult to achieve unified output structure, style and specifications. Moreover, each microservice redevelops a set of customized log encapsulation, which will cause a lot of unnecessary resource cost consumption, time-consuming and labor-intensive, and then make the efficiency of log unification low. Summary of the invention
[0004] The present invention provides a log unification method, device, equipment and medium based on artificial intelligence framework encapsulation to solve the technical problem of low efficiency of log unification due to different log structures of various microservices when performing log analysis on a financial system.
[0005] In the first aspect, a log unification method based on framework encapsulation is provided, including:
[0006] Initialize a log factory, and initialize a financial log object according to the log factory;
[0007] Encapsulating the financial log object in log format to obtain an encapsulated financial log;
[0008] Exception capture and exception information encapsulation are performed on the encapsulated financial log to obtain a captured exception log;
[0009] Unifying interface parameters of the captured exception log to obtain a unified financial log;
[0010] Performing link tracing on the unified financial log to obtain a tracing financial log;
[0011] The financial tracking log is desensitized and over-long log is controlled to obtain a standard output log.
[0012] In a second aspect, a log unification device based on framework encapsulation is provided, including:
[0013] A log acquisition module, used to initialize a log factory and initialize a financial log object according to the log factory;
[0014] A format encapsulation module, used to encapsulate the financial log object in a log format to obtain an encapsulated financial log;
[0015] An exception encapsulation module, used to capture exceptions and encapsulate exception information of the encapsulated financial log to obtain a captured exception log;
[0016] A parameter unification module, used to unify the interface parameters of the captured exception log to obtain a unified financial log;
[0017] A link tracking module, used to perform link tracking on the unified financial log to obtain a tracking financial log;
[0018] The log output module is used to perform log desensitization and overlong log control on the tracking financial log to obtain a standard output log.
[0019] In a third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned log unification method based on framework encapsulation when executing the computer program.
[0020] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned log unification method based on framework encapsulation is implemented.
[0021] In the scheme implemented by the log unification method, device, computer equipment and storage medium based on the framework encapsulation, the client can communicate with the server through the network, and the server can initialize the log factory through the client, and initialize the financial log object according to the log factory; encapsulate the financial log object in log format to obtain an encapsulated financial log; perform exception capture and exception information encapsulation on the encapsulated financial log to obtain a captured exception log; unify the interface parameters of the captured exception log to obtain a unified financial log; perform link tracking on the unified financial log to obtain a tracking financial log; perform log desensitization and overlong log control on the tracking financial log to obtain a standard output log. In the present invention, The log format encapsulation of the financial log object includes: extracting system information, user information and session request context information from the financial log object respectively; encapsulating the financial log object in the system domain according to the system information to obtain the system domain financial log; encapsulating the system domain financial log in the user domain according to the user information to obtain the user domain financial log; encapsulating the user domain financial log in the context domain according to the session request context information to obtain the encapsulated financial log, which can make the log automatically include the system, user and link tracking information, realize the comprehensive encapsulation of the log, so that the log can be consistent when calling across services, facilitate troubleshooting and problem location, realize the unification of the log format, and improve the efficiency of log unification. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0023] Figure 1 It is a schematic diagram of an application environment of a log unification method implemented based on framework encapsulation in one embodiment of the present invention;
[0024] Figure 2 It is a flow chart of a log unification method implemented based on framework encapsulation in one embodiment of the present invention;
[0025] Figure 3 yes Figure 1 A schematic flow chart of a specific implementation of step S20;
[0026] Figure 4 yes Figure 1 A schematic flow chart of a specific implementation of step S30;
[0027] Figure 5 yes Figure 1 A schematic flow chart of a specific implementation of step S40;
[0028] Figure 6 It is a structural schematic diagram of a log unification device implemented based on framework encapsulation in one embodiment of the present invention;
[0029] Figure 7 is a schematic diagram of a structure of a computer device in one embodiment of the present invention;
[0030] Figure 8 It is another structural schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0031] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0032] The log unification method based on framework encapsulation provided by the embodiment of the present invention can be applied in Figure 1 In an application environment, a client communicates with a server through a network. The server can initialize the log factory through the client, and initialize the financial log object according to the log factory; perform log format encapsulation on the financial log object to obtain an encapsulated financial log; perform exception capture and exception information encapsulation on the encapsulated financial log to obtain a captured exception log; perform interface parameter unification on the captured exception log to obtain a unified financial log; perform link tracking on the unified financial log to obtain a tracked financial log; perform log desensitization and over-long log control on the tracked financial log to obtain a standard output log. In the present invention, log format encapsulation is performed on the financial log object, including: extracting system information, user information and session request context information from the financial log object respectively; performing system domain encapsulation on the financial log object according to the system information to obtain a system domain financial log; performing user domain encapsulation on the system domain financial log according to the user information to obtain a user domain financial log; performing context domain encapsulation on the user domain financial log according to the session request context information to obtain an encapsulated financial log, which can make the log automatically contain system, user and link tracking information, realize comprehensive encapsulation of the log, so that the log is consistent when calling across services, facilitates troubleshooting and problem location, realizes the format unification of the log, and improves the efficiency of log unification. The client may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices. The server may be implemented by an independent server or a server cluster consisting of multiple servers. The present invention is described in detail below through specific embodiments.
[0033] See also Figure 2 As shown, Figure 2 A flow chart of a log unification method based on framework encapsulation implementation provided by an embodiment of the present invention includes the following steps:
[0034] S10. Initialize a log factory, and initialize a financial log object according to the log factory.
[0035] In detail, the log factory is a design pattern or tool for creating and managing loggers, which is used to provide a unified way to obtain different types of logger instances. It is often used to abstract the implementation details of the logging framework so that developers can easily use the logging function in the code without worrying about the specific logging implementation.
[0036] Specifically, the LoggerFactory class can be used to initialize the log factory. The LoggerFactory class is used to serve as a unified entry point for the log framework. The LoggerFactory can be used to obtain the Logger instance without having to worry about the underlying specific implementation, thereby increasing the flexibility of the log system.
[0037] In the embodiment of the present invention, the initializing the financial log object according to the log factory includes:
[0038] Obtaining a target financial log using the log factory;
[0039] Performing information format initialization operation on the target financial log to obtain an information log object;
[0040] Performing an error correction format initialization operation on the information log object to obtain an error correction log object;
[0041] Performing an alarm format initialization operation on the error-checking log object to obtain an alarm log object;
[0042] An error format initialization operation is performed on the alarm log object to obtain a financial log object.
[0043] In detail, the getLogger method of the log factory can be used to obtain the target financial log, thereby realizing unified log acquisition using the framework, the info() method can be used to perform information format initialization operations, the debug() method can be used to perform error format initialization operations, the warn() method can be used to perform alarm format initialization operations, and the error() method can be used to perform alarm format initialization operations.
[0044] In the embodiment of the present invention, by initializing the log factory, unified import of microservice logs can be achieved, and by initializing the financial log object according to the log factory, the logs can be unified at the output level, thereby improving the efficiency of log processing.
[0045] S20: Encapsulate the financial log object in a log format to obtain an encapsulated financial log.
[0046] In detail, the encapsulated financial log refers to a financial log object that encapsulates format information of three domains: system domain, user domain and mapped debugging context domain (MappedDiagnosticContext, MDC for short).
[0047] Specifically, the system domain usually refers to the log information used to capture the entire application system in the log system. The log information in the system domain usually does not depend on specific user requests, but is a log generated for the entire application environment, system status or infrastructure operations. The logs in the system domain are usually used to record: application start, stop and other events; insufficient memory, database connection failure and other system-level errors or warnings; performance monitoring, resource usage, configuration file loading, initialization process, etc.
[0048] In detail, the user domain refers to log information related to specific user requests or user operations. Logs that encapsulate the user domain are usually used to capture: for example, HTTP requests, database queries and other user-initiated operations; such as login, file upload and other inputs, outputs or behaviors related to specific users, as well as errors or success states caused by user operations. In microservices or distributed systems, user domain logs often contain information such as user ID, request ID, TraceId, etc. This information can help developers track the user's behavior path and thus discover problems faster.
[0049] Specifically, the mapping debug context domain is a function for associating session request context information for each thread, and is usually used in complex, concurrent systems. The content of the mapping debug context domain is usually part of the user domain because it records the context information of a specific request or operation, such as a user ID or TraceId. The mapping debug context domain allows certain context information to be automatically included in the log without having to be manually added in each log statement. This context information may include: TraceId for tracing the flow path of a request in multiple microservices or different threads; SessionId or UserId used to identify the user or session of the current operation, and other context information such as transaction ID, order number, etc.
[0050] In detail, the mapping debug context domain is thread-local, usually helps to track specific requests or user operations in a multi-threaded or distributed system, and the session request context information is not automatically propagated across threads.
[0051] In the embodiment of the present invention, refer to Figure 3 As shown, the financial log object is encapsulated in log format to obtain an encapsulated financial log, including:
[0052] S21, extracting system information, user information and session request context information from the financial log object respectively;
[0053] S22, performing system domain encapsulation on the financial log object according to the system information to obtain a system domain financial log;
[0054] S23, performing user domain encapsulation on the system domain financial log according to the user information to obtain a user domain financial log;
[0055] S24. Perform context domain encapsulation on the user domain financial log according to the session request context information to obtain an encapsulated financial log.
[0056] In detail, the system information includes information such as the system service name and system environment of the financial log object, the user information includes information such as the user ID and user role, and the session request context information includes information such as link tracking. The system information, user information and session request context information can be extracted from the financial log object respectively by regular expression or keyword search.
[0057] Specifically, the system domain encapsulation of the financial log object refers to initializing the system domain information when the application starts, such as the service name information of UserService and the operating environment information such as Production. These system domain information are usually fixed and can be loaded into the log context when the application starts to ensure that all log entries contain the basic information of the service. System domain encapsulation can be performed by adding variables such as serviceName or userId.
[0058] In detail, the user domain encapsulation of the system domain financial log refers to obtaining user domain information at each request, because user domain information is usually dynamic and will change with different user requests. When a user request comes in, user-related information such as user ID and role is obtained from the request, and this information is added to the log context. The content in the user domain can be customized by calling list, map, json, exception, message, field and other methods.
[0059] Specifically, when using methods such as list, map, field, and json, the key values can be defined by the user according to the way the object is converted to json. For example, logger.field("name","zhangsan") will output "name":"zhangsan" in the log. When using methods such as exception and message, the key values are fixed, such as "exception" and "message".
[0060] In detail, the context domain encapsulation of the user domain financial log refers to setting link tracking information, that is, setting a unique tracking identifier traceId during the request processing so that each request has a unique identifier, which can be achieved through UUID or other unique identifier generation methods. When a request comes in, a tracking identifier is generated and added to the log context to track the request link.
[0061] In the embodiment of the present invention, by encapsulating the financial log object in log format, the log can automatically include system, user and link tracking information, thereby achieving comprehensive encapsulation of the log, so that the log remains consistent when calling across services, facilitating troubleshooting and problem location.
[0062] S30, performing exception capture and exception information encapsulation on the encapsulated financial log to obtain a captured exception log.
[0063] In the embodiment of the present invention, refer to Figure 4 As shown, the encapsulated financial log is subjected to exception capture and exception information encapsulation to obtain a captured exception log, including:
[0064] S31, initializing a global exception class according to the encapsulated financial log;
[0065] S32, adding an exception capture method to the global exception class to obtain a global capture class;
[0066] S33, capturing exception information according to the global capture class to obtain exception information;
[0067] S34, encapsulating the encapsulated financial log according to the abnormal information to obtain an abnormal information log;
[0068] S35. Perform exception response encapsulation on the exception information log to obtain a captured exception log.
[0069] In detail, the RestControllerAdvice method of the springaop framework can be used to initialize the global exception class, that is, to define a global exception handling class for the encapsulated financial log. The function of the global exception handling class is to globally capture exceptions thrown in the controller to ensure that unhandled exceptions occurring in any request will be uniformly intercepted. The global exception handling class will contain methods for handling various exception types.
[0070] Specifically, the RuntimeException method of the global exception handling class can be used to add an exception capture method, and the @ExceptionHandler(RuntimeException.class) method can be used to add annotations to the captured exceptions, which will ensure that all runtime exceptions are captured and processed by this method.
[0071] In detail, the information encapsulation of the encapsulated financial log refers to encapsulating the exception into a system exception or a business exception as needed, and defining a standard return structure, and the exception information encapsulation includes: exception codes used to represent different types of exceptions for easy identification and troubleshooting; exception messages that describe the cause of the exception or provide error prompts to the user; and timestamps used to store detailed exception stack information, exception details that facilitate log recording and debugging, and the time when the exception occurred, so as to facilitate the analysis of the timing of the problem.
[0072] Specifically, you can encapsulate exception responses by implementing the ErrorController interface. Spring provides the ErrorController interface, which allows you to define a generic error page or return exception information in JSON format. You can further customize the exception handling logic in the ErrorController to ensure that each exception response complies with a unified format standard.
[0073] In an embodiment of the present invention, by performing exception capture and exception information encapsulation, unified capture and encapsulation of exceptions in logs can be achieved, thereby ensuring consistency in the exception log record format, facilitating rapid problem troubleshooting, and providing a unified error response structure for the client, which helps to improve the user experience.
[0074] S40: Unify the interface parameters of the captured exception log to obtain a unified financial log.
[0075] In the embodiment of the present invention, refer to Figure 5 As shown, the interface parameters of the captured exception log are unified to obtain a unified financial log, including:
[0076] S41, initializing the aspect class according to the captured exception log;
[0077] S42, configuring the entry point of the section class to obtain a standard section class;
[0078] S43, performing pre-notification configuration and request parameter acquisition on the standard aspect class to obtain pre-request parameters;
[0079] S44, performing post notification configuration and return parameter acquisition on the standard aspect class to obtain post return parameters;
[0080] S45. Perform parameter uniform encapsulation on the captured exception log according to the pre-request parameter and the post-return parameter to obtain a unified financial log.
[0081] In detail, the aspect class is a core concept in aspect-oriented programming, which is used to encapsulate functions that are not directly related to business logic, such as logging, transaction management, performance monitoring, etc. The aspect class defines entry points and notifications through specific annotations or configurations to enhance the target object.
[0082] Specifically, you can use the Pointcut() method to initialize the pointcut, and use the RequestMapping, GetMapping, and PostMapping annotation methods to configure the pointcut. Pointcut is an important concept of the aspect class, which is used to define which specific connection points should be applied by the aspect enhancement logic. The pointcut determines the scope and target of the aspect code. Pointcut is one of the core of aspect-oriented programming. Through the pointcut, you can specify which methods or classes need to be woven into the aspect logic.
[0083] In detail, HttpServletRequestWrapper can be used to read parameters in the request message, such as the request body and request header information, and the Before annotation can be used to configure the pre-notification and obtain the request parameters, and the AfterReturning annotation can be used to configure the post-notification and obtain the return parameters. By wrapping the request with HttpServletRequestWrapper, the request parameters can be read without affecting the normal flow of the request. Among them, the Before annotation can execute the notification before the target method is executed to read the parameters in the request message, and the AfterReturning annotation can create a post-notification, which will be executed after the target method successfully returns the result, and the response parameters of the interface can be captured through the return value such as the interface response data.
[0084] Specifically, the unified parameter encapsulation refers to recording the front request parameters and the post return parameters and other parameters in the captured exception log in a unified format. The captured exception log includes request parameters such as request body, request header, query parameters; response parameters such as the return message information of the interface, and request timestamp, interface path, HTTP method and other information.
[0085] In an embodiment of the present invention, by unifying the interface parameters of the captured exception log, unified log recording of interface parameters and return messages can be achieved, so that the request parameters and response data of each interface call are recorded in a unified format, which is convenient for troubleshooting interface problems. It can also achieve comprehensive tracking and analysis of interface calls, thereby improving the efficiency of log unification.
[0086] S50: Perform link tracing on the unified financial log to obtain a tracing financial log.
[0087] In the embodiment of the present invention, the link tracing of the unified financial log to obtain the tracing financial log includes:
[0088] Performing front-end request tracking on the unified financial log to obtain a front-end tracking log;
[0089] Performing gateway service tracking on the front-end tracking log to obtain a gateway tracking log;
[0090] Perform application service tracking on the gateway tracking log to obtain an application tracking log;
[0091] Performing microservice delivery tracing on the application tracing log to obtain a microservice tracing log;
[0092] Perform downstream service tracing on the microservice tracing log to obtain a tracing financial log.
[0093] In detail, front-end request tracking can be achieved by adding a global tracking identifier, namely traceId, and agreeing with the front-end page to transmit the tracking identifier field in the front-end header file. When the front-end page does not generate a tracking identifier or does not pass the tracking identifier, gateway service tracking can be performed by generating a tracking identifier in the back-end gateway service.
[0094] Specifically, the application service tracking refers to using a log framework such as Logback or SLF4J in the application service to obtain a tracking identifier at each request, and adding a corresponding tracking identifier to the log output, so that each log can be associated through the tracking identifier.
[0095] In detail, the microservice transmission tracking refers to the log tracking between microservices by calling FeignClient. When making a FeignClient call, the tracking identifier is added to the request header of each Feign request by inheriting HystrixConcurrencyStrategy and implementing the FeignRequestInterceptor interface, so that the logs of the microservices can be associated through the tracking identifier. The downstream service tracking means that when each downstream service receives a Feign request, it extracts the tracking identifier from the request header and records the tracking identifier in the log of the service, thereby ensuring that the log of the entire call link contains a unified tracking identifier.
[0096] In an embodiment of the present invention, by performing link tracking on the unified financial log, all log records can contain the same tracking identifier, and the status and behavior of the request in each service can be located by searching for the complete path and process of the tracking identifier, thereby realizing link tracking, and being able to quickly identify the complete flow and abnormal location of the request, thereby improving the efficiency of log unification.
[0097] S60: desensitize the financial tracking log and control the excessively long log to obtain a standard output log.
[0098] In the embodiment of the present invention, the log desensitization and overlong log control are performed on the tracking financial log to obtain a standard output log, including:
[0099] Extracting sensitive information from the financial tracking log to obtain the log sensitive information;
[0100] Encrypting and desensitizing the sensitive information in the log to obtain desensitized log information;
[0101] Using the desensitized log information to update the tracking financial log to obtain a desensitized financial log;
[0102] Extracting field information from the desensitized financial log to obtain a log key field information set;
[0103] Limiting the length of the log key field information set to obtain a key field information set with a limited length;
[0104] The desensitized financial log is updated according to the length-limited key field information set to obtain a standard output log.
[0105] In detail, the sensitive information extraction refers to extracting sensitive information such as the user's ID number, mobile phone number, bank card number, email address, etc. in the financial tracking log through methods such as keyword matching, and the encryption desensitization refers to desensitizing the sensitive information in the log using preset desensitization rules such as character replacement and data encryption. The desensitized log information meets security and performance requirements.
[0106] Specifically, the preset desensitization rules, for example, only retain the first three digits and the last four digits of the mobile phone number, and replace the middle part with special characters, such as 138xxxx1234; only retain the first six digits and the last four digits of the ID card number, and replace the rest with special characters; only retain the first four digits and the last four digits of the bank card number; only retain the first character of the username and its domain name for the email address, and replace the rest with special characters.
[0107] Specifically, the log content can be intercepted and analyzed in the log output process through, for example, an interceptor of an AOP aspect or a log framework, to find the field values that need to be length controlled, thereby realizing field information extraction.
[0108] In detail, the field information extraction refers to extracting the field information with field length restriction requirements in the desensitized financial log, and the character segment length restriction requirement refers to limiting the length of information for each log key field information set in the log key field information set. For example, the field length limit of the request parameter is 500 characters, and the field length limit of the return value is 1000 characters.
[0109] Specifically, the length limitation may be a staged restriction on the original content. For example, the original content is "requestParams": "very long request parameters...", which is truncated to "requestParams": "very long requestpa... (truncated)".
[0110] In an embodiment of the present invention, by desensitizing the financial tracking log, desensitization processing of the log can be achieved, sensitive information can be effectively hidden in the log, and the security of log records can be improved. By controlling over-long logs, the length of each field value in the log can be limited to avoid performance problems or excessive log files caused by over-long logs, thereby improving the efficiency of log unification.
[0111] It can be seen that in the above scheme, by initializing the log factory, the unified import of microservice logs can be achieved. By initializing the financial log object according to the log factory, the log can be unified at the output level of the log, which improves the efficiency of log processing. By encapsulating the financial log object in log format, the log can automatically include system, user and link tracking information, and achieve comprehensive encapsulation of the log, so that the log remains consistent when calling across services, which is convenient for troubleshooting and problem location. By performing exception capture and exception information encapsulation, the unified capture and encapsulation of exceptions in the log can be achieved, thereby ensuring that the exception log record format is consistent, which is convenient for rapid problem troubleshooting, and at the same time provides a unified error response structure for the client, which helps to improve the user experience.
[0112] By unifying the interface parameters of the captured exception log, unified log recording of interface parameters and return messages can be achieved, so that the request parameters and response data of each interface call are recorded in a unified format, which is convenient for troubleshooting interface problems, and can also achieve comprehensive tracking and analysis of interface calls, thereby improving the efficiency of log unification; by performing link tracking on the unified financial log, all log records can contain the same tracking identifier, and the status and behavior of the request in each service can be located by searching the complete path and process of the tracking identifier, thereby achieving link tracking, and being able to quickly identify the complete flow and abnormal location of the request, thereby improving the efficiency of log unification; by performing log desensitization on the tracking financial log, log desensitization processing can be achieved, so that sensitive information can be effectively hidden in the log, thereby improving the security of log records; by performing over-long log control, the length of each field value in the log can be limited, avoiding performance problems or excessive log files caused by over-long logs, thereby improving the efficiency of log unification.
[0113] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0114] In one embodiment, a log unification device based on framework encapsulation is provided, and the log unification device based on framework encapsulation corresponds one-to-one with the log unification method based on framework encapsulation in the above embodiment. Figure 6 As shown, the log unification device based on framework encapsulation implementation includes a log acquisition module 101, a format encapsulation module 102, an abnormal encapsulation module 103, a parameter unification module 104, a link tracking module 105 and a log output module 106. The detailed description of each functional module is as follows:
[0115] The log acquisition module 101 is used to initialize a log factory and initialize a financial log object according to the log factory;
[0116] The format encapsulation module 102 is used to encapsulate the financial log object in a log format to obtain an encapsulated financial log;
[0117] The exception encapsulation module 103 is used to capture exceptions and encapsulate exception information of the encapsulated financial log to obtain a captured exception log;
[0118] The parameter unification module 104 is used to unify the interface parameters of the captured exception log to obtain a unified financial log;
[0119] The link tracking module 105 is used to perform link tracking on the unified financial log to obtain a tracking financial log;
[0120] The log output module 106 is used to perform log desensitization and overlong log control on the tracking financial log to obtain a standard output log.
[0121] In one embodiment, when executing initialization of a financial log object according to the log factory, the log acquisition module 101 is used to:
[0122] Obtaining a target financial log using the log factory;
[0123] Performing information format initialization operation on the target financial log to obtain an information log object;
[0124] Performing an error correction format initialization operation on the information log object to obtain an error correction log object;
[0125] Performing an alarm format initialization operation on the error-checking log object to obtain an alarm log object;
[0126] An error format initialization operation is performed on the alarm log object to obtain a financial log object.
[0127] In one embodiment, when performing log format encapsulation on the financial log object to obtain the encapsulated financial log, the format encapsulation module 102 is used to:
[0128] Extracting system information, user information and session request context information from the financial log object respectively;
[0129] Performing system domain encapsulation on the financial log object according to the system information to obtain a system domain financial log;
[0130] Performing user domain encapsulation on the system domain financial log according to the user information to obtain the user domain financial log;
[0131] The user domain financial log is context-encapsulated according to the session request context information to obtain an encapsulated financial log.
[0132] In one embodiment, when the exception encapsulation module 103 performs exception capture and exception information encapsulation on the encapsulated financial log to obtain the captured exception log, it is used to:
[0133] Initialize the global exception class according to the encapsulated financial log;
[0134] Add an exception capture method to the global exception class to obtain a global capture class;
[0135] Exception information is captured according to the global capture class to obtain exception information;
[0136] Encapsulating the encapsulated financial log according to the abnormal information to obtain an abnormal information log;
[0137] The exception information log is encapsulated with an exception response to obtain a captured exception log.
[0138] In one embodiment, when the parameter unification module 104 performs interface parameter unification on the captured exception log to obtain a unified financial log, it is used to:
[0139] Initialize the aspect class according to the captured exception log;
[0140] Performing entry point configuration on the aspect class to obtain a standard aspect class;
[0141] Perform pre-notification configuration and request parameter acquisition on the standard aspect class to obtain pre-request parameters;
[0142] Perform post notification configuration and return parameter acquisition on the standard aspect class to obtain post return parameters;
[0143] The captured exception log is uniformly encapsulated according to the front request parameter and the back return parameter to obtain a unified financial log.
[0144] In one embodiment, when performing link tracing on the unified financial log to obtain the tracing financial log, the link tracing module 105 is used to:
[0145] Performing front-end request tracking on the unified financial log to obtain a front-end tracking log;
[0146] Performing gateway service tracking on the front-end tracking log to obtain a gateway tracking log;
[0147] Perform application service tracking on the gateway tracking log to obtain an application tracking log;
[0148] Performing microservice delivery tracing on the application tracing log to obtain a microservice tracing log;
[0149] Perform downstream service tracing on the microservice tracing log to obtain a tracing financial log.
[0150] In one embodiment, when the log output module 106 performs log desensitization and overlong log control on the tracking financial log to obtain a standard output log, it is used to:
[0151] Extracting sensitive information from the financial tracking log to obtain the log sensitive information;
[0152] Encrypting and desensitizing the sensitive information in the log to obtain desensitized log information;
[0153] Using the desensitized log information to update the tracking financial log to obtain a desensitized financial log;
[0154] Extracting field information from the desensitized financial log to obtain a log key field information set;
[0155] Limiting the length of the log key field information set to obtain a key field information set with a limited length;
[0156] The desensitized financial log is updated according to the length-limited key field information set to obtain a standard output log.
[0157] The present invention provides a log unification device based on framework encapsulation. The device can realize the unified import of microservice logs by initializing the log factory. The device can unify the logs at the output level of the logs by initializing the financial log objects according to the log factory, thereby improving the efficiency of log processing. The device can automatically contain system, user and link tracking information by encapsulating the financial log objects in log format, thereby realizing comprehensive encapsulation of the logs, thereby making the logs consistent when calling across services, facilitating troubleshooting and problem location. The device can realize the unified capture and encapsulation of exceptions in the logs by performing exception capture and exception information encapsulation, thereby ensuring the consistency of the exception log record format, facilitating rapid problem troubleshooting, and providing a unified error response structure for the client, thereby helping to improve the user experience.
[0158] By unifying the interface parameters of the captured exception log, unified log recording of interface parameters and return messages can be achieved, so that the request parameters and response data of each interface call are recorded in a unified format, which is convenient for troubleshooting interface problems, and can also achieve comprehensive tracking and analysis of interface calls, thereby improving the efficiency of log unification; by performing link tracking on the unified financial log, all log records can contain the same tracking identifier, and the status and behavior of the request in each service can be located by searching the complete path and process of the tracking identifier, thereby achieving link tracking, and being able to quickly identify the complete flow and abnormal location of the request, thereby improving the efficiency of log unification; by performing log desensitization on the tracking financial log, log desensitization processing can be achieved, so that sensitive information can be effectively hidden in the log, thereby improving the security of log records; by performing over-long log control, the length of each field value in the log can be limited, avoiding performance problems or excessive log files caused by over-long logs, thereby improving the efficiency of log unification.
[0159] For the specific limitations of the log unification device based on framework encapsulation, please refer to the limitations of the intelligent question and answer method above, which will not be repeated here. The various modules in the above-mentioned log unification device based on framework encapsulation can be implemented in whole or in part through software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0160] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client through a network connection. When the computer program is executed by the processor, it implements a function or step on the server side of a log unification method based on framework encapsulation.
[0161] In one embodiment, a computer device is provided. The computer device may be a client, and its internal structure diagram may be as follows: Figure 8As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements a function or step on the client side of a log unification method based on framework encapsulation.
[0162] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0163] Initialize a log factory, and initialize a financial log object according to the log factory;
[0164] Encapsulating the financial log object in log format to obtain an encapsulated financial log;
[0165] Exception capture and exception information encapsulation are performed on the encapsulated financial log to obtain a captured exception log;
[0166] Unifying interface parameters of the captured exception log to obtain a unified financial log;
[0167] Performing link tracing on the unified financial log to obtain a tracing financial log;
[0168] The financial tracking log is desensitized and over-long log is controlled to obtain a standard output log.
[0169] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0170] Initialize a log factory, and initialize a financial log object according to the log factory;
[0171] Encapsulating the financial log object in log format to obtain an encapsulated financial log;
[0172] Exception capture and exception information encapsulation are performed on the encapsulated financial log to obtain a captured exception log;
[0173] Unifying interface parameters of the captured exception log to obtain a unified financial log;
[0174] Performing link tracing on the unified financial log to obtain a tracing financial log;
[0175] The financial tracking log is desensitized and over-long log is controlled to obtain a standard output log.
[0176] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant descriptions on the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0177] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0178] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0179] The above-described embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some of the technical features therein by equivalents; and these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should be included in the protection scope of the present invention. It should be noted that if software tools or components other than those of the company appear in the embodiments of this application, they are only used for example introduction and do not represent actual use.
Claims
1. A log unification method based on framework encapsulation, characterized in that: include: Initialize a log factory, and initialize a financial log object according to the log factory; Encapsulating the financial log object in log format to obtain an encapsulated financial log; Exception capture and exception information encapsulation are performed on the encapsulated financial log to obtain a captured exception log; Unifying interface parameters of the captured exception log to obtain a unified financial log; Performing link tracing on the unified financial log to obtain a tracing financial log; The financial tracking log is desensitized and over-long log is controlled to obtain a standard output log.
2. The log unification method based on framework encapsulation implementation as claimed in claim 1, characterized in that: Initializing the financial log object according to the log factory includes: Obtaining a target financial log using the log factory; Performing information format initialization operation on the target financial log to obtain an information log object; Performing an error correction format initialization operation on the information log object to obtain an error correction log object; Performing an alarm format initialization operation on the error-checking log object to obtain an alarm log object; An error format initialization operation is performed on the alarm log object to obtain a financial log object.
3. The log unification method based on framework encapsulation implementation as claimed in claim 1, characterized in that: The step of encapsulating the financial log object in a log format to obtain an encapsulated financial log includes: Extracting system information, user information and session request context information from the financial log object respectively; Performing system domain encapsulation on the financial log object according to the system information to obtain a system domain financial log; Performing user domain encapsulation on the system domain financial log according to the user information to obtain the user domain financial log; The user domain financial log is context-encapsulated according to the session request context information to obtain an encapsulated financial log.
4. The log unification method based on framework encapsulation implementation as claimed in claim 1, characterized in that: The step of performing exception capture and exception information encapsulation on the encapsulated financial log to obtain a captured exception log includes: Initialize the global exception class according to the encapsulated financial log; Add an exception capture method to the global exception class to obtain a global capture class; Exception information is captured according to the global capture class to obtain exception information; Encapsulating the encapsulated financial log according to the abnormal information to obtain an abnormal information log; The exception information log is encapsulated with an exception response to obtain a captured exception log.
5. The log unification method based on framework encapsulation implementation as claimed in claim 1, characterized in that: The step of unifying interface parameters of the captured exception log to obtain a unified financial log includes: Initialize the aspect class according to the captured exception log; Performing entry point configuration on the aspect class to obtain a standard aspect class; Perform pre-notification configuration and request parameter acquisition on the standard aspect class to obtain pre-request parameters; Perform post notification configuration and return parameter acquisition on the standard aspect class to obtain post return parameters; The captured exception log is uniformly encapsulated according to the front request parameter and the back return parameter to obtain a unified financial log.
6. The log unification method based on framework encapsulation implementation as claimed in claim 1, characterized in that: The link tracing of the unified financial log to obtain the tracing financial log includes: Performing front-end request tracking on the unified financial log to obtain a front-end tracking log; Performing gateway service tracking on the front-end tracking log to obtain a gateway tracking log; Perform application service tracking on the gateway tracking log to obtain an application tracking log; Performing microservice delivery tracing on the application tracing log to obtain a microservice tracing log; Perform downstream service tracing on the microservice tracing log to obtain a tracing financial log.
7. The log unification method based on framework encapsulation implementation as claimed in claim 1, characterized in that: The tracking financial log is desensitized and overlong log is controlled to obtain a standard output log, including: Extracting sensitive information from the financial tracking log to obtain the log sensitive information; Encrypting and desensitizing the sensitive information in the log to obtain desensitized log information; Using the desensitized log information to update the tracking financial log to obtain a desensitized financial log; Extracting field information from the desensitized financial log to obtain a log key field information set; Limiting the length of the log key field information set to obtain a key field information set with a limited length; The desensitized financial log is updated according to the length-limited key field information set to obtain a standard output log.
8. A log unification device based on framework encapsulation, characterized in that: include: A log acquisition module, used to initialize a log factory and initialize a financial log object according to the log factory; A format encapsulation module, used to encapsulate the financial log object in a log format to obtain an encapsulated financial log; An exception encapsulation module, used to capture exceptions and encapsulate exception information of the encapsulated financial log to obtain a captured exception log; A parameter unification module, used to unify the interface parameters of the captured exception log to obtain a unified financial log; A link tracking module, used to perform link tracking on the unified financial log to obtain a tracking financial log; The log output module is used to perform log desensitization and overlong log control on the tracking financial log to obtain a standard output log.
9. A computer 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 computer program, the log unification method based on framework encapsulation as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the log unification method based on framework encapsulation as claimed in any one of claims 1 to 7 is implemented.