Service log generation method and device, electronic equipment and storage medium

By extracting and generating key information of the target service's log record information, the problem of diversified log formats cannot be managed in a unified manner is solved, and the format uniformity of service logs and the convenience of key information positioning is achieved.

CN119402380APending Publication Date: 2025-02-07BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411469705.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

In the prior art, the diversified log formats make it impossible to manage uniformly, which increases the difficulty of searching, filtering and positioning key information in massive log data.

Method used

By obtaining the logging information of the target service, and extracting the logging information based on the configuration information of the target service, obtaining the target key information, and generating the service log according to the log generation method set by the configuration information based on the target key information.

Benefits of technology

The format uniformity of service logs is realized, reducing the difficulty of subsequent searching, filtering and locateing key information on service logs, and solving the problem of diversified log formats that cannot be managed in a unified manner.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119402380A_ABST
    Figure CN119402380A_ABST
Patent Text Reader

Abstract

The invention relates to a service log generation method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining the log record information of a target service, carrying out the key information extraction of the log record information according to the configuration information corresponding to the target service, obtaining the target key information, and carrying out the key information extraction of the log record information based on the target key information. Generating a service log of the target service according to a log generation mode correspondingly set by the configuration information; therefore, the key information can be uniformly adopted to generate the service log, the problem that the log formats are diversified and cannot be uniformly managed in the prior art is solved, and the format uniformity of the service log can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a method, device, electronic device and storage medium for generating a service log. Background Art

[0002] With the development of the Internet, the functional services of various applications or software are also increasing. Usually, various functional services are implemented by numerous microservice applications. With the rapid expansion of business and the widespread adoption of microservice architecture, it is often necessary to deploy and manage dozens or even hundreds of microservice applications. In this scenario, log monitoring has become a key means to quickly diagnose and solve business problems. However, due to differences in log recording habits among different development teams, or different service applications need to use different log formats, the formats and concerns of logs generated by various service applications are different, that is, there is a problem that the log formats are diverse and cannot be managed uniformly. Summary of the invention

[0003] In order to solve the problem in the existing related technologies that the log formats are diversified and cannot be managed uniformly, the present application provides a method, device, electronic device and storage medium for generating a service log.

[0004] In a first aspect, the present application provides a method for generating a service log, comprising:

[0005] Get the target service's logging information;

[0006] Extract key information from the log record information according to the configuration information corresponding to the target service to obtain target key information;

[0007] Based on the target key information, a service log of the target service is generated according to the log generation method set corresponding to the configuration information.

[0008] Optionally, extracting key information from the log record information according to the configuration information corresponding to the target service to obtain target key information includes:

[0009] Obtaining the configuration information corresponding to the target service;

[0010] Determine the key parameter identifier corresponding to the target service according to the configuration information;

[0011] Extracting the target key parameter corresponding to the key parameter identifier from the log record information;

[0012] The target key parameters are used to generate the target key information.

[0013] Optionally, the adopting the target key parameter to generate the target key information includes:

[0014] Extracting parameter annotation information from the target key parameters;

[0015] Determining the parameter type of the target key parameter;

[0016] Based on the parameter annotation information, the target key information is generated according to the key information generation method corresponding to the parameter type.

[0017] Optionally, extracting a target key parameter corresponding to the key parameter identifier from the log record information includes:

[0018] Extracting the key parameter corresponding to the key parameter identifier from the log record information;

[0019] Determine the key parameter name and key parameter value of the key parameter;

[0020] Extracting configuration parameter names and configuration parameter values ​​from the configuration information;

[0021] When the key parameter name matches the configuration parameter name, determining whether the key parameter value matches the configuration parameter value;

[0022] When the key parameter value matches the configuration parameter value, the key parameter is determined as the target key parameter.

[0023] Optionally, generating the service log of the target service based on the target key information and in accordance with the log generation method set corresponding to the configuration information includes:

[0024] Determine the log generation method corresponding to the configuration information;

[0025] Extracting target record information from the log record information;

[0026] The target key information and the target record information are used to generate the service log according to the log generation method.

[0027] Optionally, generating the service log of the target service based on the target key information and in accordance with the log generation method set corresponding to the configuration information includes:

[0028] Determine the log generation method corresponding to the configuration information;

[0029] Based on the log generation method, determining a target printing field;

[0030] The target key information is printed into the target print field to generate the service log.

[0031] Optionally, printing the target key information into the target print field and generating the service log includes:

[0032] Determine the key information field and the record information field according to the target printing field;

[0033] Extracting target record information from the log record information;

[0034] The target key information is printed into the record information field, and the target record information is printed into the record information field to generate the service log.

[0035] In a second aspect, the present application provides a device for generating a service log, including:

[0036] The acquisition module is used to obtain the log record information of the target service;

[0037] An extraction module, used to extract key information from the log record information according to the configuration information corresponding to the target service, to obtain target key information;

[0038] The log generation module is used to generate a service log of the target service based on the target key information and in accordance with the log generation method set corresponding to the configuration information.

[0039] In a third aspect, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0040] Memory, used to store computer programs;

[0041] The processor is used to implement the service log generation method described in any one of the first aspects when executing the program stored in the memory.

[0042] According to a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method for generating a service log as described in any one of the first aspects is implemented.

[0043] The embodiment of the present application obtains the log record information of the target service, and extracts key information from the log record information according to the configuration information corresponding to the target service to obtain the target key information, so as to generate the service log of the target service based on the target key information and in accordance with the log generation method set corresponding to the configuration information; thereby, the key information can be uniformly used to generate the service log, which solves the problem in the existing related technology that the log formats are diversified and cannot be uniformly managed, and can effectively improve the format uniformity of the service log. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0046] Figure 1 A flow chart of a method for generating a service log provided in an embodiment of the present application;

[0047] Figure 2 A schematic diagram of an application scenario of a method for generating a service log provided in an embodiment of the present application;

[0048] Figure 3 A schematic diagram of the structure of a device for generating a service log provided in an embodiment of the present application;

[0049] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0051] Logs are recorded information generated by various business services in applications during their operation. Logs need to be extracted and analyzed in scenarios such as problem diagnosis, security monitoring, and performance analysis. However, in the existing technology, different development teams have different habits for log recording, or different service applications require different log formats. When using logs to diagnose problems, monitor security, and analyze performance of applications, it is usually necessary to extract some logs. At this time, due to the diversity of log generation methods, it is impossible to quickly locate or extract the required logs, which increases the difficulty of searching, filtering, and quickly locating key information in massive log data. As a result, the log generation method in the existing related technology has the problem that the log formats are diverse and cannot be managed uniformly.

[0052] In order to solve the problem that the log generation method in the existing related technology has diversified log formats and cannot be uniformly managed, the present application provides a service log generation method, device, electronic device and storage medium, by obtaining the log record information of the target service and extracting key information from the log record information according to the configuration information corresponding to the target service to obtain the target key information, and then generate the service log of the target service based on the target key information and the log generation method set according to the configuration information; thereby, the key information can be uniformly used to generate the service log, which solves the problem that the log format is diversified and cannot be uniformly managed in the existing related technology, and can effectively improve the format uniformity of the service log.

[0053] Figure 1 A flow chart of a method for determining a verification method provided in an embodiment of the present application. The method can be applied to one or more electronic devices such as a client and a server. In addition, the execution subject of the method can be hardware or software. When the above-mentioned execution subject is hardware, the execution subject can be one or more of the above-mentioned electronic devices. For example, a single electronic device can execute the method, or a plurality of electronic devices can cooperate with each other to execute the method. When the above-mentioned execution subject is software, the method can be implemented as a plurality of software or software modules, or as a single software or software module. No specific limitation is made herein.

[0054] like Figure 1 As shown, the present application discloses an embodiment, providing a method for generating a service log, which may specifically include the following steps:

[0055] Step S110: Obtain log record information of the target service.

[0056] Among them, the target service may refer to the service that currently needs to generate logs, and the log record information may represent the information generated by the target service that needs to be logged. For example, the log record information may include one or more of the service request information, response request information, request time, response time, etc. This embodiment does not make any specific limitations on this.

[0057] Step S120: extract key information from the log record information according to the configuration information corresponding to the target service to obtain target key information.

[0058] Specifically, after obtaining the log record information of the target service, the configuration information corresponding to the target service can be determined. The configuration information can refer to the information that needs to extract parameters for the target service in advance according to the needs, so that the log record information can be extracted based on the configuration information to obtain the target key information, wherein the key information represents the information in the log record information that matches the configuration information, such as keywords, key fields, key names and other information, and the key information extraction is to extract the information in the log record information that matches the configuration information, and the target relationship information can represent all the key information extracted from the log record information, that is, the target key information can contain one or more key information, and this embodiment does not make specific limitations on this.

[0059] It should be noted that, since different target services pay attention to different key information, different target services pay attention to different business fields for the extraction of key information. For example, the embedding service pays attention to the model name, such as the call volume of each model and model call-related information, while the large model inference service pays attention to prompt_id, and the large model inference service can only be accessed through prompt_id; therefore, in this embodiment, through the configuration information, the corresponding key information that needs to be extracted can be determined for different target services, so as to achieve the purpose of accurately extracting the key information of the target service.

[0060] In addition, in this embodiment, the configuration information can be pre-stored in the server, that is, after obtaining the log record information of the target service, the target service identifier of the target service can be determined, and the configuration information corresponding to the target service identifier can be obtained from the server, so that the corresponding configuration information can be determined for different target services, thereby playing the role of determining the corresponding configuration information for different target services.

[0061] Step S130: Based on the target key information, a service log of the target service is generated according to the log generation method set in the configuration information.

[0062] Specifically, after obtaining the target key information, the log generation method corresponding to the configuration information can be determined. The log generation method represents a unified method of log generation that is pre-configured, so that the log generation method can be used to generate logs for the target key information to obtain the service log of the target service. The service log refers to the log corresponding to the log record information of the target service.

[0063] It should be noted that the log generation method in this embodiment is set in advance according to the configuration information, and the configuration information may refer to the information for extracting parameters that are configured for the target service in advance according to the needs, that is, the configuration information is associated with the target service, and the services in different scenarios or different areas use different conventional log generation methods. For example, the business service logs in area A are all generated using log4j2. At this time, the method of encapsulating another layer on log4j2 can be determined as the log generation method corresponding to the configuration information corresponding to the service in the area, so that the service in the area can achieve the increase of target key information during the log generation process, and generate logs by encapsulating another layer on log4j2, so as to be compatible with all the interfaces of the original log4j2 generated, so that the usage is consistent with log42, and the log can be printed by explicitly introducing the class or by introducing the annotation, thereby reducing the learning and use costs caused by the change in the log generation method, and can effectively improve the implementation applicability and compatibility of the service log generation method of this application.

[0064] It can be seen that in this embodiment, the log record information of the target service is obtained, and the key information of the log record information is extracted according to the configuration information corresponding to the target service to obtain the target key information, so as to generate the service log of the target service based on the target key information and in accordance with the log generation method set corresponding to the configuration information; thereby, the key information can be uniformly used to generate the service log, and the service log can include the target key information corresponding to the target service, which can effectively reduce the difficulty of subsequent searching, filtering and locating key information in the service log, thereby solving the problem in the existing related technology that the log formats are diversified and cannot be uniformly managed, and can effectively improve the format uniformity of the service log.

[0065] In an optional embodiment of the present application, step S120 extracts key information from the log record information based on the configuration information corresponding to the target service to obtain the target key information, which may specifically include the following sub-steps: obtaining the configuration information corresponding to the target service; determining the key parameter identifier corresponding to the target service based on the configuration information; extracting the target key parameters corresponding to the key parameter identifier from the log record information; and using the target key parameters to generate the target key information.

[0066] In this embodiment, after obtaining the log record information, the configuration information corresponding to the target service can be obtained, so that the key parameter identifier corresponding to the target service can be determined based on the configuration information. The key parameter identifier represents the identifier of the key information corresponding to the target service. The key parameter identifier can be determined by extracting it from the configuration information, or by determining the parameter identifier corresponding to the configuration information as the key parameter identifier. This embodiment does not make specific restrictions on this. Then, the target key parameter corresponding to the key parameter identifier can be extracted from the log record information. The specific extraction method can be traversing each record parameter in the log record information, and determining whether each record parameter matches the key parameter identifier, and determining the record parameter matching the key parameter identifier as the target key parameter. The target key parameter can then be used to generate the target key information. Specifically, the target key parameter can be directly used as the target key information, or the target key parameter can be judged for validity to obtain a validity judgment result, and when the validity judgment result is a valid result, the target key parameter can be used as the target key information. Of course, other methods can also be used, and this embodiment does not make specific restrictions on this.

[0067] In one example, since the configuration information in this embodiment can be information such as keywords, key fields, key names, etc., when the configuration information is a key field, the parameter identifier of the key field can be determined as the key parameter identifier, so that in the log record information, the parameters in the key field marked by the key parameter identifier can be extracted to obtain the target key parameters; when the configuration information is a key name, the parameter identifier of the key name can be determined as the key parameter identifier, so that in the log record information, the parameters matching the key name represented by the key parameter identifier can be extracted to obtain the target key parameters, wherein the parameters matching the key name represented by the key parameter identifier can be a match that is completely consistent with the name, or a match that contains a preset matching relationship, such as for the field name prompt_id, the name in some services is prompt_id, and the name in some services may be promptId, or It may be other names. In this case, prompt_id can be used as the key name, that is, configuration information, and the matching relationship between the key name and other names can be pre-configured. For example, prompt_id, promptId and prompt_id are all matching relationships. At this time, in the log record information, based on the extraction of parameters that match the key name represented by the key parameter identifier, the names of promptId and prompt_id can be extracted. Even if the parameter names used in the business development stage may be different, they ultimately represent the same parameter meaning. Through the key parameter identifier, a corresponding relationship can be established between multiple aliases defined in the development stage and the actual name. When extracting the target key parameters corresponding to the key parameter identifier from the log record information, the aliases will also be judged and extracted one by one according to the preset matching relationship, thereby ensuring the flexibility of extracting the target key parameters.

[0068] In an optional embodiment of the present application, target key parameters are used to generate target key information, which may specifically include the following sub-steps: extracting parameter annotation information from the target key parameters; determining the parameter type of the target key parameters; and generating the target key information based on the parameter annotation information and in accordance with the key information generation method corresponding to the parameter type.

[0069] In this embodiment, in the process of using target key parameters to generate target key information, parameter annotation information can be extracted from the target key parameters, the parameter annotation information represents the annotation information pre-configured in the target key parameters, and the parameter type of the target key parameters is determined, where the parameter type can represent the data type of the target key parameter, such as a custom object, a JSON string, a Map type, etc. Since different parameter types can use different processing methods to generate target key information, that is, based on the parameter annotation information, the target key information can be generated according to the key information generation method corresponding to the parameter type, where the key information generation method represents the method of processing the parameter annotation information and generating the target key information.

[0070] In one example, the log record information generated when the target service is running specifically may include request information, and different parameters in the request information may use different annotations, that is, different request information may have different parameter annotation information. If the parameter annotation used in the URL is RequestParam, the parameter annotation information is RequestParam. If the parameter annotation used in the Body is RequestBody, the parameter annotation information is RequestBody. When the parameter annotation is RequestBody, the data type of the target service may be a custom object, a simple JavaScript Object Notation (JSON) string, or a simple mapping table (Map) type. That is, the parameter type of the target key parameter may be a custom object, a JSON string, a Map type, etc.

[0071] Specifically, when the parameter type is a Map type, the key information corresponding to the parameter type can be generated by directly converting the target key parameter into a Map, and then comparing the key of the Map with the keyword represented by the configuration information corresponding to the target service. If they are equal, extract the corresponding key and value of the Map to generate the target key information.

[0072] When the parameter type is a JSON string, the key information corresponding to the parameter type can be generated by converting the JSON string into a corresponding Map type, and then comparing the Map key with the keywords represented by the configuration information corresponding to the target service. If they are equal, extract the corresponding key and value of the Map to generate the target key information.

[0073] When the parameter type is a custom object, the key information corresponding to the parameter type can be generated by using the Java reflection mechanism to obtain the corresponding key and value, and compare the key with the keywords represented by the configuration information corresponding to the target service. If they are consistent, the corresponding extraction is performed. Of course, the above is only an example for illustration. In the specific implementation, it can be adaptively adjusted according to the scenario and requirements, and this embodiment does not make specific limitations on this.

[0074] In an optional embodiment of the present application, a target key parameter corresponding to a key parameter identifier is extracted from log record information, which may specifically include the following sub-steps: extracting the key parameter corresponding to the key parameter identifier from the log record information; determining the key parameter name and the key parameter value of the key parameter; extracting the configuration parameter name and the configuration parameter value from the configuration information; when the key parameter name matches the configuration parameter name, determining whether the key parameter value matches the configuration parameter value; when the key parameter value matches the configuration parameter value, determining the key parameter as the target key parameter.

[0075] In this embodiment, in the process of extracting the target key parameters from the log record information, the key parameters corresponding to the key parameter identifiers can be extracted from the log record information. The key parameters can refer to the parameters marked by the key parameter identifiers, so that the key parameter names and key parameter values ​​of the key parameters can be determined. The key parameter names can refer to the names of the key parameters, and the key parameter values ​​can refer to the specific values ​​corresponding to the key parameters. Then, the configuration parameter names and configuration parameter values ​​can be extracted from the configuration information. Since the configuration information can refer to the information that needs to extract parameters for the target service configuration in advance according to the needs, the configuration information can include the configuration parameter names and configuration parameter values. The configuration parameter names can indicate the configuration of the target service. The name of the parameter to be extracted is set, and the configuration parameter value can indicate the specific value corresponding to the parameter to be extracted from the target service configuration; then the key parameter name can be matched and compared with the configuration parameter name to determine whether the key parameter name and the configuration parameter name match. When the key parameter name and the configuration parameter name do not match, there is no need for subsequent steps and the key parameter is discarded. When the key parameter name and the configuration parameter name match, it can be determined whether the key parameter value and the configuration parameter value match. When the key parameter value and the configuration parameter value do not match, there is no need for subsequent steps and the key parameter is discarded. When the key parameter value and the configuration parameter value match, the key parameter can be determined as the target key parameter.

[0076] In one example, during the specific implementation, Spring's Aspect-Oriented Programming (AOP) mechanism can be combined to obtain the annotations of key parameters, thereby determining the key parameter names and key parameter values ​​of the key parameters, and then comparing them with the configuration parameter names and configuration parameter values ​​corresponding to the parameters represented by the configuration information, thereby achieving the effect of improving the accuracy of the target key parameters.

[0077] In an optional embodiment of the present application, step S130 generates a service log for the target service based on the target key information and in accordance with the log generation method set corresponding to the configuration information. Specifically, it may include the following sub-steps: determining the log generation method set corresponding to the configuration information; extracting the target record information from the log record information; and generating a service log with the target key information and the target record information in accordance with the log generation method.

[0078] In this embodiment, after obtaining the target key information, the log generation method corresponding to the configuration information can be determined, and the target record information can be extracted from the log record information. The target record information can represent information used for routine log recording, such as request time, request end identifier, response time and other information. Then, the target key information and the target record information can be used to generate a service log according to the log generation method, so that a service log with a consistent format can be generated through a unified log generation method, and the target key information and the target record information can be used to generate a service log together, so that the service log can include the target key information, which is convenient for the subsequent use of the target key information to perform fast and accurate search, filtering and positioning operations on the service log, that is, the effect of unified format of the service log is achieved.

[0079] In an optional embodiment of the present application, step S130 generates a service log of the target service based on the target key information and in accordance with the log generation method set corresponding to the configuration information. Specifically, it may include the following sub-steps: determining the log generation method set corresponding to the configuration information; determining the target print field based on the log generation method; printing the target key information to the target print field to generate a service log.

[0080] In this embodiment, in the process of generating a service log, the log generation method corresponding to the configuration information can be determined, wherein the log generation method can include a target printing field, and the target printing field represents the specific field where the target key information is printed. That is, based on the log generation method, the target printing field can be determined, and the target key information can be printed to the target printing field to generate a service log.

[0081] In an optional embodiment of the present application, the target key information is printed to the target print field to generate a service log, which may specifically include the following sub-steps: determining the key information field and the record information field based on the target print field; extracting the target record information from the log record information; printing the target key information to the record information field, and printing the target record information to the record information field to generate a service log.

[0082] In this embodiment, in the process of printing the target key information to the target print field and generating a service log, the key information field and the record information field can be determined based on the target print field. The key information field indicates the specific field to which the target key information is printed, and the record information field indicates the specific field to which the target record information is printed. Then, the target record information can be extracted from the log record information, and the target key information can be printed to the record information field, and the target record information can be printed to the record information field to generate a service log. It should be noted that in this embodiment, the key information field and the record information field can be the same field, or can be continuous fields, and of course can also be discontinuous fields. This embodiment does not make specific limitations on this.

[0083] In addition, when implementing the service log generation method of the present application, in order to facilitate use, in addition to explicitly specifying the API for calling, it can also be introduced through annotations, so that the cost of use can be simplified while improving the efficiency of development. The specific custom new log framework annotation is changed during compilation. The specific process can be referred to Figure 2 ;The compilation process can be divided into three steps:

[0084] Step 1: Parsing and filling symbol table process;

[0085] Step 2: Annotation processing of plug-in annotation processor;

[0086] Step 3: Analysis and bytecode generation process.

[0087] from Figure 2 The flowchart shows that if the annotation processor modifies the syntax tree during annotation processing, the compiler will return to the process of parsing and filling the symbol table for reprocessing until the annotation processor does not modify the syntax tree again.

[0088] After the annotation is introduced, the API of the new device will be automatically introduced after compilation to print the log.

[0089] The last point is the configuration of the entire device. Regular analysis of log keywords is performed on the log platform to facilitate subsequent log queries. The logs can be configured according to the actual situation of each service.

[0090] It should be noted that the annotations in this embodiment have different meanings from those in the previous embodiments. The annotations in this embodiment are annotations that are introduced into the code during the programming code process, that is, after the annotations are introduced into the project, some explicit codes will be automatically introduced during compilation, avoiding the manual introduction of explicit codes. The service log generation method in this embodiment is compatible with the log4j2 interface, so it can also be consistent with log4j2 in use, which facilitates developers to use it seamlessly, thereby realizing custom annotations. For example, if an annotation @mylog is defined, then as long as the class annotated with @mylog is used in the project, a code will be inserted into the code during compilation. This code plays the role of executing the service log generation method of this application. In this way, mylog can be used directly to print logs in the project without the need to explicitly introduce log-related code. The main principle of implementation is to dynamically change the content of the bytecode during compilation and insert new code into the bytecode. The entire process is as follows: Figure 2 As shown, the Java syntax tree will be parsed, and then the annotation processing will be performed. If the processed code indirectly depends on the annotation, the parsing process will continue until all annotations are processed, and finally a new syntax tree will be generated.

[0091] like Figure 3 As shown, the present application also discloses an embodiment, providing a device for generating a service log, including:

[0092] The acquisition module 310 is used to acquire the log record information of the target service;

[0093] An extraction module 320 is used to extract key information from the log record information according to the configuration information corresponding to the target service to obtain target key information;

[0094] The log generation module 330 is used to generate a service log of the target service based on the target key information and in accordance with the log generation method set corresponding to the configuration information.

[0095] In an optional embodiment of the present application, the extraction module 320 may include:

[0096] A first acquisition unit, configured to acquire the configuration information corresponding to the target service;

[0097] A first determining unit, configured to determine a key parameter identifier corresponding to the target service according to the configuration information;

[0098] A first extraction unit, configured to extract a target key parameter corresponding to the key parameter identifier from the log record information;

[0099] The first generating unit is used to generate the target key information by adopting the target key parameter.

[0100] In an optional embodiment of the present application, the first generating unit may include:

[0101] A first extraction subunit, configured to extract parameter annotation information from the target key parameter;

[0102] A first determining subunit, configured to determine a parameter type of the target key parameter;

[0103] The first generating subunit is used to generate the target key information based on the parameter annotation information and in accordance with the key information generating method corresponding to the parameter type.

[0104] In an optional embodiment of the present application, the first extraction unit may include:

[0105] A second extraction subunit is used to extract the key parameter corresponding to the key parameter identifier from the log record information;

[0106] A second determining subunit, used to determine a key parameter name and a key parameter value of the key parameter;

[0107] A third extraction subunit is used to extract a configuration parameter name and a configuration parameter value from the configuration information;

[0108] A third determining subunit, configured to determine whether the key parameter value matches the configuration parameter value when the key parameter name matches the configuration parameter name;

[0109] The fourth determining subunit is configured to determine the key parameter as the target key parameter when the key parameter value matches the configuration parameter value.

[0110] In an optional embodiment of the present application, the log generation module 330 may include:

[0111] A second determining unit, used to determine the log generation mode set corresponding to the configuration information;

[0112] A second extraction unit, used to extract target record information from the log record information;

[0113] The second generating unit is used to generate the service log according to the log generating method by using the target key information and the target record information.

[0114] In an optional embodiment of the present application, the log generation module 330 may include:

[0115] A third determining unit, used to determine the log generation mode set corresponding to the configuration information;

[0116] A fourth determining unit, configured to determine a target printing field based on the log generation method;

[0117] The third generating unit is used to print the target key information to the target printing field to generate the service log.

[0118] In an optional embodiment of the present application, the third generating unit may include:

[0119] A fifth determining subunit, configured to determine a key information field and a record information field according to the target printing field;

[0120] a fourth extraction subunit, configured to extract target record information from the log record information;

[0121] The second generating subunit is used to print the target key information to the record information field, and print the target record information to the record information field to generate the service log.

[0122] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.

[0123] like Figure 4 As shown, an embodiment of the present application provides an electronic device, including a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other through the communication bus 440;

[0124] Memory 430, for storing computer programs;

[0125] In one embodiment of the present application, the processor 410, when used to execute the program stored in the memory 430, implements the service log generation method provided by any of the aforementioned method embodiments, by obtaining the log record information of the target service, and extracting key information from the log record information according to the configuration information corresponding to the target service, to obtain the target key information, and based on the target key information, generate the service log of the target service in accordance with the log generation method set corresponding to the configuration information; thereby, the key information can be uniformly used to generate the service log, and the service log includes the target key information corresponding to the target service, which can effectively reduce the difficulty of subsequent searching, filtering and locating key information in the service log, thereby solving the problem in the existing related technology that the log formats are diversified and cannot be uniformly managed, and can effectively improve the format uniformity of the service log.

[0126] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for generating a service log as provided in any of the aforementioned method embodiments is implemented, by obtaining log record information of the target service, and extracting key information from the log record information according to configuration information corresponding to the target service, to obtain target key information, and to generate a service log of the target service based on the target key information and in accordance with a log generation method set corresponding to the configuration information; thereby, the key information can be uniformly used to generate the service log, and the service log includes the target key information corresponding to the target service, which can effectively reduce the difficulty of subsequent searching, filtering and locating key information in the service log, thereby solving the problem in the existing related technology that the log formats are diversified and cannot be uniformly managed, and can effectively improve the format uniformity of the service log.

[0127] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0128] The above describes specific embodiments of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0129] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for generating a service log, characterized in that: include: Get the target service's logging information; Extract key information from the log record information according to the configuration information corresponding to the target service to obtain target key information; Based on the target key information, a service log of the target service is generated according to the log generation method set corresponding to the configuration information.

2. The method for generating a service log according to claim 1, characterized in that: The step of extracting key information from the log record information based on the configuration information corresponding to the target service to obtain target key information includes: Obtaining the configuration information corresponding to the target service; Determine the key parameter identifier corresponding to the target service according to the configuration information; Extracting the target key parameter corresponding to the key parameter identifier from the log record information; The target key parameters are used to generate the target key information.

3. The method for generating a service log according to claim 2, characterized in that: The step of adopting the target key parameters to generate the target key information includes: Extracting parameter annotation information from the target key parameters; Determining the parameter type of the target key parameter; Based on the parameter annotation information, the target key information is generated according to the key information generation method corresponding to the parameter type.

4. The method for generating a service log according to claim 2, characterized in that: Extracting the target key parameter corresponding to the key parameter identifier from the log record information includes: Extracting the key parameter corresponding to the key parameter identifier from the log record information; Determine the key parameter name and key parameter value of the key parameter; Extracting configuration parameter names and configuration parameter values ​​from the configuration information; When the key parameter name matches the configuration parameter name, determining whether the key parameter value matches the configuration parameter value; When the key parameter value matches the configuration parameter value, the key parameter is determined as the target key parameter.

5. The method for generating a service log according to claim 1, characterized in that: The generating the service log of the target service based on the target key information and in accordance with the log generating method corresponding to the configuration information includes: Determine the log generation method corresponding to the configuration information; Extracting target record information from the log record information; The target key information and the target record information are used to generate the service log according to the log generation method.

6. The method for generating a service log according to claim 1, characterized in that: The generating the service log of the target service based on the target key information and in accordance with the log generating method corresponding to the configuration information includes: Determine the log generation method corresponding to the configuration information; Based on the log generation method, determining a target printing field; The target key information is printed into the target print field to generate the service log.

7. The method for generating a service log according to claim 6, characterized in that: The step of printing the target key information to the target print field and generating the service log includes: Determine the key information field and the record information field according to the target printing field; Extracting target record information from the log record information; The target key information is printed into the record information field, and the target record information is printed into the record information field to generate the service log.

8. A device for generating a service log, characterized in that: include: The acquisition module is used to obtain the log record information of the target service; An extraction module, used to extract key information from the log record information according to the configuration information corresponding to the target service, to obtain target key information; The log generation module is used to generate a service log of the target service based on the target key information and in accordance with the log generation method set corresponding to the configuration information.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; The processor is used to implement the service log generation method described in any one of claims 1-7 when executing the program stored in the memory.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for generating a service log as described in any one of claims 1 to 7 is implemented.