Log output optimization method and device, equipment and medium

By obtaining and analyzing the initial log file, it is determined whether the target log content is related to the business. If not, the output strategy is determined, which solves the problem of useless information in the log output and improves the rationality and storage efficiency of the log output.

CN118672855APending Publication Date: 2024-09-20GREAT WALL MOTOR CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410829475.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-25
Publication Date
2024-09-20

AI Technical Summary

Technical Problem

In the existing technology, developers perform log output based on personal development experience, resulting in a large amount of useless information in the log file, resulting in unreasonable log output and inability to effectively locate problems.

Method used

By obtaining the initial log files of multiple node devices, determine whether the target log content is related to the target business. If not, determine the target output strategy based on the target log content, constrain the log output content, avoid the output of useless information, and improve the rationality and accuracy of the log output. Files take up space.

Benefits of technology

It effectively reduces the output of unreasonable content in log files, improves the rationality of log output and file storage efficiency, and saves the space occupied by log files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118672855A
    Figure CN118672855A
Patent Text Reader

Abstract

The invention provides a log output optimization method and device, equipment and a medium, the method is applied to a log output technology, and the method comprises the following steps: obtaining initial log files of a plurality of node equipment; wherein the initial log file is a log file output based on an initial output strategy; determining target log content in the initial log file; wherein the target log content is used for indicating log content with a proportion greater than or equal to a first preset threshold in target files of the plurality of node devices; determining whether the target log content is associated with a target service; if the target log content is not associated with the target service, determining a target output strategy based on the target log content; wherein the target output strategy is used for constraining the log output content in the source log data when the log output is executed next time. The method can improve the reasonability of log output.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of log output technology, and more specifically, to a log output optimization method, device, equipment and medium in the field of log output technology. Background Art

[0002] Service logs are an important tool for analyzing production problems. In complex distributed systems, service logs provide detailed information about system operation, which helps developers and operation and maintenance personnel locate problems and diagnose faults, making log printing particularly important.

[0003] In the related art, since developers output logs based on their personal development experience, a large amount of useless information is output, resulting in a large amount of unreasonable log content in the currently output log files.

[0004] Therefore, how to improve the rationality of log output becomes an urgent problem to be solved. Summary of the invention

[0005] The present application provides a log output optimization method, device, equipment and medium, which can improve the rationality of log output.

[0006] In a first aspect, a log output optimization method is provided, the method comprising:

[0007] Acquire initial log files of multiple node devices; wherein the initial log files are log files output based on an initial output strategy;

[0008] Determine the target log content in the initial log file; wherein the target log content is used to indicate the log content in the target files of the multiple node devices whose proportion is greater than or equal to a first preset threshold;

[0009] Determine whether the target log content is related to the target business;

[0010] If the target log content is not associated with the target business, a target output strategy is determined based on the target log content; wherein the target output strategy is used to constrain the log output content in the source log data when the log output is executed next time.

[0011] In an embodiment of the present application, initial log files of multiple node devices are obtained; target log content in the initial log file is determined; whether the target log content is associated with the target business is determined; if the target log content is not associated with the target business, a target output strategy is determined based on the target log content; in the above scheme, after the initial log file is obtained and the target log content that accounts for a relatively large proportion of the entire log storage in the initial log file is determined, since it is possible to identify whether the target log content needs to be optimized by judging whether the target log content is associated with the target business, and when the target log content is not associated with the target business, that is, when the target log content is useless content that needs to be optimized, a target output strategy can be determined based on the target log content to avoid outputting a large amount of useless content when the log output is executed next time, so that a large amount of unreasonable content will not appear in the output log file, thereby improving the rationality of the log output and saving the space occupied by the log file.

[0012] In conjunction with the first aspect, in some possible implementations, determining the target log content in the initial log file includes:

[0013] Obtain target information in the initial log file; wherein the target information includes a class package name or log content;

[0014] Based on the target information, the target log content is determined.

[0015] In the embodiment of the present application, since the target information is the class package name or log content in the initial log file, the target log content can be accurately determined from the initial log file based on the class package name or log content.

[0016] In combination with the first aspect and the foregoing implementation manner, in some possible implementation manners, determining the target log content based on the target information includes:

[0017] Grouping the log contents in the initial log file based on the target information to obtain multiple groups of log contents;

[0018] Determine a target proportion of each group of log content in the target file;

[0019] The target group log content corresponding to the target proportion being greater than or equal to the first preset threshold is determined as the target log content.

[0020] In an embodiment of the present application, since the log contents in the initial log file can be grouped based on the target information to obtain multiple groups of log contents, and the target proportion of each group of log contents in the target file can be determined, the target group log contents can be accurately selected from the multiple groups of log contents as the target log contents by comparing the target proportion of each group of log contents with the first preset threshold.

[0021] In combination with the first aspect and the above implementation manner, in some possible implementation manners, determining whether the target log content is associated with the target business includes:

[0022] Obtain the business corresponding to the target class package name of the target log content;

[0023] Determine whether the service corresponding to the target class package name is the target service.

[0024] In an embodiment of the present application, since the business corresponding to the target class package name of the target log content can be obtained and it can be determined whether the business corresponding to the target class package name is the target business, it is possible to automatically and quickly identify whether the target log content is the content to be optimized based on the business corresponding to the target class package name of the target log content.

[0025] In combination with the first aspect and the above implementation manner, in some possible implementation manners, before determining whether the target log content is associated with the target business, the method includes:

[0026] Display prompt information, where the prompt information is used to confirm whether the target log content is related to the target business;

[0027] The determining whether the target log content is associated with the target business includes:

[0028] In response to a user operation on the prompt information, it is determined whether the target log content is associated with the target business based on whether the user operation is a confirmation operation.

[0029] In an embodiment of the present application, when prompt information is displayed, it is possible to respond to a user operation on the prompt information and determine whether the target log content is associated with the target business based on whether the user operation is a confirmation operation. Therefore, when the user performs a confirmation operation, it is determined that the target log content is associated with the target business, that is, the target log content is considered to be content to be optimized, so that the user can determine whether the target log content is content to be optimized according to actual needs.

[0030] In combination with the first aspect and the above implementation manner, in some possible implementation manners, the method further includes:

[0031] If source log data to be output is detected, determining target log output content corresponding to the source log data based on the target output strategy;

[0032] Output the target log file corresponding to the target log output content.

[0033] In an embodiment of the present application, if source log data to be output is detected, the target log output content corresponding to the source log data is determined based on the target output strategy, and the target log file corresponding to the target log output content is output; in the above scheme, since when the source log data to be output is detected, the target log output content corresponding to the source log data can be determined based on the new output strategy, and the target log file corresponding to the target log output content is output, the target log file does not include a high proportion of target log content (i.e., useless content), thereby improving the rationality of the log output, and compared with the space occupied by the initial log file, the space occupied by the target log file is also significantly reduced.

[0034] In combination with the first aspect and the above implementation manner, in some possible implementation manners, the method further includes:

[0035] Generate a visualization chart based on the target proportion of each group of log content in the target file; wherein the visualization chart is used to indicate the target proportion of each group of log content in the target file;

[0036] The visualization chart is displayed.

[0037] In an embodiment of the present application, since a visualization chart can be generated and displayed based on the target proportion of each group of log content in the target file, the user can intuitively view the target log content with a high proportion through the visualization chart, and it is convenient for developers to view the class package name of the target log content through the visualization chart; it is convenient for developers to monitor.

[0038] In a second aspect, a log output optimization device is provided, the device comprising:

[0039] A first acquisition module is used to acquire initial log files of multiple node devices; wherein the initial log files are log files output based on the initial output strategy;

[0040] A first determination module is used to determine the target log content in the initial log file; wherein the target log content is used to indicate the log content in the target files of the multiple node devices whose proportion is greater than or equal to a first preset threshold;

[0041] A second determination module is used to determine whether the target log content is associated with a target business;

[0042] The third determination module is used to determine a target output strategy based on the target log content if the target log content is not associated with the target business; wherein the target output strategy is used to constrain the log output content in the source log data when the log output is executed next time.

[0043] According to a third aspect, an electronic device is provided, including:

[0044] A memory for storing executable program codes;

[0045] The processor is used to call and run the executable program code from the memory, so that the electronic device executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.

[0046] In a fourth aspect, a computer program product is provided, comprising: a computer program code, which, when executed on a computer, enables the computer to execute the method in the first aspect or any possible implementation of the first aspect.

[0047] In a fifth aspect, a computer-readable storage medium is provided, which stores a computer program code. When the computer program code runs on a computer, the computer executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 is a schematic diagram of a log output optimization system provided in an embodiment of the present application;

[0049] Figure 2 It is a flow chart of a log output optimization method provided in an embodiment of the present application;

[0050] Figure 3 An interactive schematic diagram of a log collection architecture provided in an embodiment of the present application;

[0051] Figure 4 A schematic diagram of a visualization chart provided in an embodiment of the present application;

[0052] Figure 5 A flow chart of another log output optimization method provided in an embodiment of the present application;

[0053] Figure 6 A schematic diagram of the structure of a log output optimization device provided in an embodiment of the present application;

[0054] Figure 7 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0055] The technical solution in the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B: "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0056] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features.

[0057] Currently, in complex distributed systems, service logs provide detailed information about system operation status, which helps developers and operation and maintenance personnel locate problems, diagnose faults, and optimize accordingly.

[0058] However, in the existing log output scheme, developers output logs based on their personal development experience, so a large amount of useless information is output, resulting in more unreasonable log contents in the currently output log files.

[0059] Therefore, how to improve the rationality of log output becomes an urgent problem to be solved.

[0060] In view of this, the log output optimization method provided by the embodiment of the present application can obtain the initial log files of multiple node devices; determine the target log content in the initial log file; determine whether the target log content is related to the target business; if the target log content is not related to the target business, determine the target output strategy based on the target log content; in the above scheme, after the initial log file is obtained and the target log content in the initial log file that accounts for a relatively large proportion of the entire log storage is determined, since it is possible to identify whether the target log content needs to be optimized by judging whether the target log content is related to the target business, and when the target log content is not related to the target business, that is, when the target log content is useless content that needs to be optimized, the target output strategy can be determined based on the target log content to avoid outputting a large amount of useless content when the log output is executed next time, so that a large amount of unreasonable content will not appear in the output log file, thereby improving the rationality of the log output and saving the space occupied by the log file.

[0061] Figure 11 is a schematic diagram of a log output optimization system provided by an embodiment of the present application. The system may include a log collection module 101, a log key information extraction module 102, a log analysis module 103, and a log output strategy optimization module 104; wherein the log collection module 101, the log key information extraction module 102, the log analysis module 103, and the log output strategy optimization module 104 are different functional modules in a cloud platform or an electronic device.

[0062] The log collection module 101 can be used to collect log data generated by different microservices, and convert the data format of the collected log data to obtain a log file, that is, an initial log file; and store the initial log file.

[0063] The log key information extraction module 102 can be used to extract the log key information in the initial log file to obtain the log key information; wherein the log key information includes target information; and store the log key information in the log collection module 101.

[0064] The log analysis module 103 may be used to obtain an initial log file from the log collection module 101 ; determine target log content in the initial log file; and determine whether the target log content is associated with a target business.

[0065] The log output strategy optimization module 104 may be used to determine a target output strategy based on the target log content when the target log content is not associated with the target business.

[0066] Figure 2 A flow chart of a log output optimization method provided in an embodiment of the present application.

[0067] like Figure 2 As shown, the above method may include S201 to S204, and S201 to S204 are described in detail below.

[0068] Exemplarily, the above method may be executed by an electronic device or by a cloud platform; or by a chip of an electronic device; or by the above method. Figure 1 The log analysis module 103 and the log output strategy optimization module 104 are executed.

[0069] S201, obtaining initial log files of multiple node devices.

[0070] The initial log file is a log file output based on the initial output strategy.

[0071] Optionally, the log output optimization method provided in the embodiment of the present application can be applied in a microservice architecture to optimize the log output of initial log files of multiple microservices, that is, one microservice corresponds to one node device.

[0072] Exemplarily, after generating log data of multiple node devices, logs of multiple node devices can be collected through a log collection and processing visualization tool (Elasticsearch Logstash Kibana, ELK), and the format of the received log data can be converted to obtain an initial log file, and the initial log file can be stored based on the storage function of ELK. In this way, the initial log file can be directly obtained from the storage space of the ELK tool.

[0073] Figure 3 An interactive schematic diagram of a log collection architecture provided in an embodiment of the present application.

[0074] like Figure 3 As shown, the architecture includes multiple node devices, which are node devices 1 to node devices n respectively; and also includes an ELK tool, which includes a collection module 01, a storage module 02 and a display module 03; wherein, Figure 3 The solid lines in the figure represent the connection between different modules, and the arrows represent the data flow.

[0075] After node device 1 to node device n generate log files, the log files can be sent to the ELK tool, that is, the log files are collected by the collection module 01 in the ELK tool; after the collection module collects the log files, the collection module 01 can be converted to obtain the initial log file.

[0076] The collection module 01 may send the initial log file to the storage module 02, and the storage module 02 may store the received initial log file in a corresponding disk.

[0077] The storage module 02 may send the initial log file to the display module 03. After receiving the initial log file, the display module 03 may open the initial log file and display the log content in the initial log file in a visual interface.

[0078] Optionally, the initial output strategy may be a strategy for specifying an output format.

[0079] A log file is a file that records events that occur during the operation of an operating system or other software or messages between different users of a communication software. The initial log file may be an event log file or a message log file.

[0080] Optionally, the extension of the log file may be .log. The log file has no fixed format and is usually a text file that can be opened with Notepad and a text editor.

[0081] S202: Determine the target log content in the initial log file.

[0082] The target log content is used to indicate the log content in the target files of the multiple node devices whose proportion is greater than or equal to the first preset threshold.

[0083] Optionally, the initial log file includes multiple log contents, and the target log content is part or all of the log contents in the multiple log contents.

[0084] Optionally, when the target log content is the entire log content, if the proportion of the initial log file in the target file is less than a first preset threshold, the following S203 may be executed.

[0085] Optionally, the above-mentioned target file can be understood as a storage space for storing log files.

[0086] Optionally, the first preset threshold may be factory set or user-defined. Of course, the user may trigger a modification of the first preset threshold.

[0087] In one implementation, the step of determining the target log content in the initial log file may specifically include:

[0088] Obtain target information in the initial log file; wherein the target information includes a class package name or log content;

[0089] Based on the target information, determine the target log content.

[0090] Optionally, one possible way is to traverse all log contents in the initial log file to obtain the target information; another possible implementation method is to use log parsing technology, regular expressions or pattern matching to extract key information of each log content in the initial log file, and store the key information in the ELK tool. The key information may include class package name, log level, timestamp and specific log content, so that the target information can be directly obtained from the key information stored in the ELK tool.

[0091] In the embodiment of the present application, since the target information is the class package name or log content in the initial log file, the target log content can be accurately determined from the initial log file based on the class package name or log content.

[0092] In one implementation, the above-mentioned determining the target log content based on the target information includes:

[0093] Grouping the log contents in the initial log file based on the target information to obtain multiple groups of log contents;

[0094] Determine the target proportion of each group of log contents in the target file among multiple groups of log contents;

[0095] The target group log content corresponding to the target proportion being greater than or equal to the first preset threshold is determined as the target log content.

[0096] Optionally, when the target information is a class package name, the class package names of any two log contents in the initial log file can be compared respectively, and the log contents with the same class package name can be divided into the same group to obtain multiple groups of log contents; when the target information is log content, any two log contents in the initial log file can be compared respectively, and the log contents with similarity greater than or equal to the similarity threshold can be divided into the same group to obtain multiple groups of log contents.

[0097] It should be noted that when the log contents in the initial log file are grouped based on the class package name to obtain multiple groups of log contents, any two log contents in each group of log contents may be the same or different.

[0098] Optionally, one possible way is to calculate the space occupied by each group of log contents and the space occupied by the target file, and find the ratio of the space occupied by each group of log contents to the space occupied by the target file, which is the target proportion of each group of log contents in the target file. Another possible way is that when the target file only includes the initial log file, the number of logs corresponding to each group of log contents can be counted, and the total number of logs in the initial log file can be counted, and the ratio of the number of logs corresponding to each group of log contents to the total number of logs can be found as the target proportion of each group of log contents in the target file.

[0099] Optionally, the target proportion of each group of log contents may be compared with a first preset threshold value, so that target group log contents are screened out from multiple groups of log contents, and the number of groups of the target group log contents is one or more groups.

[0100] Exemplarily, taking the first preset threshold of 50% as an example. The log contents in the initial log file are grouped based on the class package name to obtain multiple groups of log contents, which include group A log contents, group B log contents, and group C log contents; the target proportion of group A log contents is determined to be 20%, the target proportion of group B log contents is 18%, and the target proportion of group C log contents is 62%; the target proportion of each group of log contents is compared with the first preset threshold, and the group C log contents with a target proportion of 62% are determined as the target log contents.

[0101] In an embodiment of the present application, since the log contents in the initial log file can be grouped based on the target information to obtain multiple groups of log contents, and the target proportion of each group of log contents in the target file can be determined, the target group log contents can be accurately selected from the multiple groups of log contents as the target log contents by comparing the target proportion of each group of log contents with the first preset threshold.

[0102] In one implementation, the log output optimization method provided in the embodiment of the present application may further include:

[0103] Based on the target proportion of each group of log contents in the target file, a visualization chart is generated; wherein the visualization chart is used to indicate the target proportion of each group of log contents in the target file.

[0104] Displays a visualization chart.

[0105] Exemplarily, the above-mentioned visualization chart may be a pie chart, a pie chart or other possible visualization charts.

[0106] Figure 4 A schematic diagram of a visualization chart provided in an embodiment of the present application.

[0107] As shown in Figure 4, a pie chart is displayed in the interface. The pie chart includes three groups of log contents grouped based on the class package name. The class package name of the first group of log contents is m1, and the target proportion is 68%; the class package name of the second group of log contents is m2, and the target proportion is 20%; the class package name of the third group of log contents is m3, and the target proportion is 18%.

[0108] It should be noted that the above Figure 3 The target ratio of each group of log contents is displayed in a visual chart as an example for illustrative explanation, and the number of logs in each group of log contents can also be displayed.

[0109] Optionally, in the interface where the visualization chart is located, the class package name corresponding to each group of log content can be visualized from large to small on the platform according to the target proportion of each group of log content in the target file, so that developers can analyze the functions and uses of these high-frequency class packages, and why they appear frequently in the logs.

[0110] Optionally, when the log contents in the initial log file are grouped based on the class package name to obtain multiple groups of log contents, a table can be generated based on the class package name, a group of log contents corresponding to each class package name, and the total number of the group of log contents; and the table is displayed. In this way, by displaying the table, it is convenient for developers to associate class package names with specific log contents, view these high-frequency log contents, and further analyze whether these high-frequency log contents are meaningful and whether developers need to optimize them accordingly.

[0111] Optionally, the above table can be displayed simultaneously with the display of the visual chart.

[0112] In an embodiment of the present application, since a visualization chart can be generated and displayed based on the target proportion of each group of log content in the target file, the user can intuitively view the target log content with a high proportion through the visualization chart, and it is convenient for developers to view the class package name of the target log content through the visualization chart; it is convenient for developers to monitor.

[0113] S203: Determine whether the target log content is related to the target business.

[0114] Optionally, the target service may be a specific service, or may include multiple services. It should be noted that the target service refers to a service involving a specific function. For example, the target service is a search service.

[0115] Optionally, the above target services may be pre-configured by developers according to actual needs.

[0116] Optionally, the target business is used to identify whether the target log content is the log content to be optimized. When the business corresponding to the target class package name is the target business, that is, the target class package name involves a specific business, it is considered that the target log content does not need to be optimized; when the business corresponding to the target class package name is not the target business, it is considered that the target class package name does not involve a specific business, and the target log content is considered to be the log content to be optimized.

[0117] Optionally, determining whether the target log content is associated with the target business can be achieved in the following two ways:

[0118] Method 1

[0119] In one implementation, the step of determining whether the target log content is associated with the target business may specifically include:

[0120] Get the business corresponding to the target class package name of the target log content;

[0121] Determine whether the business corresponding to the target class package name is the target business.

[0122] Optionally, different class package names correspond to different services; when the target class package name is a class package name, the service corresponding to the class package name can be determined, and it can be judged whether the service corresponding to the class package name is the target service; when the target class package name is multiple class package names, it can be determined whether the service corresponding to each class package name in the multiple class package names is the target service.

[0123] Optionally, when the target class package name is a plurality of class package names, the services corresponding to some of the class package names may be the target services, while the services corresponding to other class package names may not be the target services.

[0124] In one example, the target business is business A. Assume that the business corresponding to the target class package name of the target log content is business A. Since the business corresponding to the target class package name is the same as the target business, the target log content can be associated with the target business.

[0125] In an embodiment of the present application, since the business corresponding to the target class package name of the target log content can be obtained and it can be determined whether the business corresponding to the target class package name is the target business, it is possible to automatically and quickly identify whether the target log content is the content to be optimized based on the business corresponding to the target class package name of the target log content.

[0126] In an embodiment of the present application, when prompt information is displayed, it is possible to respond to a user operation on the prompt information and determine whether the target log content is associated with the target business based on whether the user operation is a confirmation operation. Therefore, when the user performs a confirmation operation, it is determined that the target log content is associated with the target business, that is, the target log content is considered to be content to be optimized, so that the user can determine whether the target log content is content to be optimized according to actual needs.

[0127] Method 2

[0128] In one implementation, before the above step of determining whether the target log content is associated with the target business, the method provided by the embodiment of the present application may further include:

[0129] Display prompt information, which is used to confirm whether the target log content is related to the target business;

[0130] Accordingly, the above step of determining whether the target log content is associated with the target business may specifically include:

[0131] In response to a user operation on the prompt information, it is determined whether the target log content is associated with the target business based on whether the user operation is a confirmation operation.

[0132] Optionally, when the user operation is a confirmation operation, it can be determined that the target log content is associated with the target business; when the user operation is a denial operation, it can be determined that the target log content is not associated with the target business.

[0133] In one example, a prompt message “Please confirm whether log content A is associated with business A? Yes or No” is displayed; when the user selects “Yes”, the log content A can be determined to be associated with business A in response to the user's confirmation operation.

[0134] S204: If the target log content is not related to the target business, determine a target output strategy based on the target log content.

[0135] The target output strategy is used to constrain the log output content in the source log data when the log output is executed next time.

[0136] Optionally, the above source log data can be understood as source code for printing logs.

[0137] Optionally, the target output policy is used to constrain the log output content in the source log data when the log output is executed next time. It can be understood that the target output policy is used to clearly indicate the log content that can be output when there is a printing demand.

[0138] Optionally, the above-mentioned determining the target output strategy based on the target log content may be understood as determining the target output strategy based on the detailed information and / or type of the target log content.

[0139] Exemplarily, when the detailed information of the target log content is meaningless information of aspect oriented programming (Aspect Oriented Programming, AOP), the target policy information is not to print the target log content.

[0140] Exemplarily, when the detailed information of the target log content includes sensitive information, the target policy information is not to print the sensitive information or to replace the sensitive information with preset characters.

[0141] Optionally, the above-mentioned determination of the target output policy based on the target log content can be understood as determining the target output policy based on the target log content and preset log output conditions; wherein the preset log output conditions are used to constrain the content of the log output.

[0142] Optionally, the above-mentioned preset log output conditions may include log level, log type, naming conventions, log format, log storage and backup, log output location and log output principles; wherein, the log output principles may include the security of log output, log output content, log specifications and performance requirements for log output, etc.

[0143] Exemplarily, when the detailed information of the target log content is meaningless information of aspect oriented programming (AOP), if the preset log output condition is not allowed to use AAOP aspects to globally control printing request and response information, then the target policy information is not to print the target log content.

[0144] It should be understood that determining the target output policy based on the target log content means determining the target output policy based on all log contents that are the same as or similar to the target log content.

[0145] In another possible implementation, the above-mentioned determination of the target output strategy includes: responding to the user's target input; and determining the target output strategy based on the input content of the target input. In this way, the user can adjust the current initial output strategy based on the target log content and in combination with his or her actual experience to obtain the target output strategy, thereby changing the log output content at the next log output based on the target strategy.

[0146] In one implementation, the log output optimization method provided in the embodiment of the present application may further include the following steps:

[0147] If source log data to be output is detected, the target log output content corresponding to the source log data is determined based on the target output strategy;

[0148] Output the target log file corresponding to the target log output content.

[0149] It should be understood that, since the target output policy is used to constrain the log output content in the source log data when the log output is executed next time, when the source log data to be output is detected, the target log output content can be determined based on the target output policy, so that the target log file corresponding to the target log output content can be output; at this time, the target log file does not include the target log content, or the target log file includes log content with a high degree of similarity to the target log content, but the proportion of the log content in the target file is far less than the first preset threshold. For example, the log content only appears once in the target log file.

[0150] In an embodiment of the present application, if source log data to be output is detected, the target log output content corresponding to the source log data is determined based on the target output strategy, and the target log file corresponding to the target log output content is output; in the above scheme, since when the source log data to be output is detected, the target log output content corresponding to the source log data can be determined based on the new output strategy, and the target log file corresponding to the target log output content is output, the target log file does not include a high proportion of target log content, thereby providing flexibility in log output.

[0151] In one example, the first preset threshold is 50% and the target business is D service. After obtaining the initial log files of multiple node devices, the log contents in the initial log files can be grouped based on the class package name to obtain multiple groups of log contents, which include group A log content, group B log content and group C log content respectively; determine that the target proportion of group A log content is 20%, the target proportion of group B log content is 18%, and the target proportion of group C log content is 62%; compare the target proportion of each group of log content with the first preset threshold, and determine the group C log content with a target proportion of 62% as the target log content; obtain the target class package name of group C log content and the service corresponding to the target class package name is E service, because the service corresponding to the target class package name is not D service, that is, the log content of group C is useless content, so based on the log content of group C, it can be determined that the target output strategy is not to print log content similar to the log content of group C, so as to constrain the log output content in the source log data when the log output is executed next time, that is, to avoid the output of useless content. In this way, the rationality of log output is improved and the space occupied by log files is saved.

[0152] In an embodiment of the present application, initial log files of multiple node devices are obtained; target log content in the initial log file is determined; whether the target log content is associated with the target business is determined; if the target log content is not associated with the target business, a target output strategy is determined based on the target log content; in the above scheme, after the initial log file is obtained and the target log content that accounts for a relatively large proportion of the entire log storage in the initial log file is determined, since it is possible to identify whether the target log content needs to be optimized by judging whether the target log content is associated with the target business, and when the target log content is not associated with the target business, that is, when the target log content is useless content that needs to be optimized, a target output strategy can be determined based on the target log content to avoid outputting a large amount of useless content when the log output is executed next time, so that a large amount of unreasonable content will not appear in the output log file, thereby improving the rationality of the log output and saving the space occupied by the log file.

[0153] Figure 5 A flow chart of another log output optimization method provided in an embodiment of the present application. This method can be applied to the above Figure 1 The log output optimization system shown.

[0154] Exemplarily, the above method may be executed by an electronic device or by a cloud platform; or by a chip of an electronic device; or by the above method. Figure 1 The log analysis module 103 and the log output strategy optimization module 104 are executed.

[0155] like Figure 5As shown, the log output optimization method includes S301 to S308, and S301 to S308 are described in detail below.

[0156] S301, obtaining initial log files of multiple node devices and target information in the initial log files.

[0157] Optionally, the initial log file is a log file output based on an initial output strategy; the target information may include a class package name or log content.

[0158] Exemplarily, the initial log file and the target information are directly obtained from the storage space of the log collection module 101 for storing log files.

[0159] Exemplarily, the initial log file may be processed using log parsing technology, regular expressions, or pattern matching to obtain target information.

[0160] S302: grouping the log contents in the initial log file based on the target information to obtain multiple groups of log contents.

[0161] For example, taking the target information as a class package name, the class package name of each log content in the initial log file is recorded, and the log contents with the same class package name are grouped together to obtain multiple groups of log contents.

[0162] S303: Determine a target proportion of each group of log contents in the target file.

[0163] Exemplarily, the number of logs in each group of log contents is counted, and the total number of all log contents in the target file is counted, and the ratio of the number of logs in each group of log contents to the total number is the target proportion of each group of log contents in the target file.

[0164] S304: Determine the target group log content corresponding to the target proportion being greater than or equal to the first preset threshold as the target log content.

[0165] Optionally, when the target group log content includes multiple groups of log content, the multiple groups of log content may be the same or different.

[0166] S305, detecting whether the target log content is associated with the target business; if not, executing the following S306.

[0167] Exemplarily, the target log content may be displayed; if the developer checks the target log content, he or she may determine whether the target log content is related to the target business.

[0168] S306: Determine a target output strategy based on the target log content.

[0169] The target output strategy is used to constrain the log output content in the source log data when the log output is executed next time.

[0170] Exemplarily, the target output strategy may be obtained based on the target log content and the experience of the developer.

[0171] S307: If source log data to be output is detected, target log output content corresponding to the source log data is determined based on the target output strategy.

[0172] Optionally, the target log data content is log content that is allowed to be output.

[0173] S308, output the target log file corresponding to the target log output content.

[0174] It should be noted that the above target log file is different from the initial log file.

[0175] Optionally, the above S301 to S305 can be performed by Figure 1 The log analysis module 103 in the above-mentioned S307 and S308 can be performed by the above-mentioned Figure 1 The log output strategy optimization module 104 executes.

[0176] For the description of the above S301 to S308, reference may be made to the detailed description of S201 to S204 in the above embodiment, which will not be elaborated in detail in the embodiment of the present application.

[0177] In an embodiment of the present application, after the initial log file is obtained and the target log content that accounts for a relatively large proportion of the entire log storage in the initial log file is determined, whether the target log content needs to be optimized can be identified by judging whether the target log content is related to the target business, and when the target log content is not related to the target business, that is, when the target log content is useless content that needs to be optimized, a target output strategy can be determined based on the target log content to avoid outputting a large amount of useless content when the log output is executed next time, so that a large amount of unreasonable content will not appear in the output log file, thereby improving the rationality of the log output and saving the space occupied by the log file.

[0178] Figure 6 A schematic diagram of the structure of a log output optimization device provided in an embodiment of the present application.

[0179] like Figure 6 As shown, the apparatus 400 may include:

[0180] The first acquisition module 401 may be used to acquire initial log files of multiple node devices; wherein the initial log files are log files output based on the initial output strategy;

[0181] The first determination module 402 may be used to determine target log content in the initial log file; wherein the target log content is used to indicate log content in the target files of the multiple node devices whose proportion is greater than or equal to a first preset threshold;

[0182] The second determination module 403 may be used to determine whether the target log content is associated with a target business;

[0183] The third determination module 404 may be used to determine a target output strategy based on the target log content if the target log content is not associated with the target business; wherein the target output strategy is used to constrain the log output content in the source log data when the log output is executed next time.

[0184] In a possible implementation, the first determination module 402 may be specifically configured to obtain target information in the initial log file; wherein the target information includes a class package name or log content; and determine the target log content based on the target information.

[0185] In one possible implementation, the first determination module 402 can be specifically used to group the log contents in the initial log file based on the target information to obtain multiple groups of log contents; and determine the target proportion of each group of log contents in the multiple groups of log contents in the target file; and determine the target group log content corresponding to the target proportion greater than or equal to the first preset threshold as the target log content.

[0186] In a possible implementation, the second determination module 403 may be specifically configured to obtain a business corresponding to a target class package name of the target log content; and determine whether the business corresponding to the target class package name is the target business.

[0187] In a possible implementation, the device further includes:

[0188] A first display module may be used to display prompt information, wherein the prompt information is used to confirm whether the target log content is associated with the target business;

[0189] The second determination module 403 may be specifically configured to determine, in response to a user operation on the prompt information and based on whether the user operation is a confirmation operation, whether the target log content is associated with the target business.

[0190] In a possible implementation, the device may further include:

[0191] A fourth determination module may be used to determine target log output content corresponding to the source log data based on the target output strategy if source log data to be output is detected;

[0192] The log output module can be used to output the target log file corresponding to the target log output content.

[0193] In a possible implementation, the device may further include:

[0194] A chart generation module may be used to generate a visual chart based on the target proportion of each group of log content in the target file; wherein the visual chart is used to indicate the target proportion of each group of log content in the target file;

[0195] The second display module can be used to display the visual chart.

[0196] In an embodiment of the present application, after the initial log file is obtained and the target log content that accounts for a relatively large proportion of the entire log storage in the initial log file is determined, whether the target log content needs to be optimized can be identified by judging whether the target log content is related to the target business, and when the target log content is not related to the target business, that is, when the target log content is useless content that needs to be optimized, a target output strategy can be determined based on the target log content to avoid outputting a large amount of useless content when the log output is executed next time, so that a large amount of unreasonable content will not appear in the output log file, thereby improving the rationality of the log output and saving the space occupied by the log file.

[0197] Figure 7 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application.

[0198] For example, Figure 7 As shown, the electronic device 500 includes: a memory 501 and a processor 502, wherein the memory 501 stores an executable program code 5011, and the processor 502 is used to call and execute the executable program code 5011 to perform a log output optimization method.

[0199] In addition, an embodiment of the present application also protects a device, which may include a memory and a processor, wherein the memory stores executable program code, and the processor is used to call and execute the executable program code to execute a log output optimization method provided by an embodiment of the present application.

[0200] In this embodiment, the functional modules of the device can be divided according to the above method example. For example, each functional module can be corresponded, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0201] In the case of dividing each functional module according to each function, the device may also include a first acquisition module, a first determination module, a first display module, and a log output module, etc. It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module, which will not be repeated here.

[0202] It should be understood that the device provided in this embodiment is used to execute the above-mentioned log output optimization method, and thus can achieve the same effect as the above-mentioned implementation method.

[0203] In the case of an integrated unit, the device may include a processing module and a storage module. When the device is applied to a vehicle, the processing module may be used to control and manage the actions of the vehicle. The storage module may be used to support the vehicle in executing related program codes, etc.

[0204] The processing module may be a processor or a controller, which may implement or execute various exemplary logic blocks, modules and circuits shown in conjunction with the disclosure of the present application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module may be a memory.

[0205] In addition, the device provided in the embodiments of the present application may specifically be a chip, a component or a module, and the chip may include a connected processor and a memory; wherein the memory is used to store instructions, and when the processor calls and executes the instructions, the chip can execute a log output optimization method provided in the above embodiments.

[0206] This embodiment also provides a computer-readable storage medium, in which a computer program code is stored. When the computer program code is executed on a computer, the computer executes the above-mentioned related method steps to implement a log output optimization method provided in the above embodiment.

[0207] This embodiment also provides a computer program product. When the computer program product runs on a computer, it enables the computer to execute the above-mentioned related steps to implement a log output optimization method provided by the above embodiment.

[0208] Among them, the device, computer-readable storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.

[0209] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0210] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0211] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A log output optimization method, It is characterized in that The method comprises: Acquire initial log files of multiple node devices; wherein the initial log files are log files output based on the initial output strategy; Determine the target log content in the initial log file; wherein the target log content is used to indicate the log content in the target files of the multiple node devices whose proportion is greater than or equal to a first preset threshold; Determine whether the target log content is related to the target business; If the target log content is not associated with the target business, a target output strategy is determined based on the target log content; wherein the target output strategy is used to constrain the log output content in the source log data when the log output is executed next time.

2. The method according to claim 1, It is characterized in that Determining the target log content in the initial log file includes: Obtain target information in the initial log file; wherein the target information includes a class package name or log content; Based on the target information, the target log content is determined.

3. The method according to claim 2, It is characterized in that The determining the target log content based on the target information includes: Grouping the log contents in the initial log file based on the target information to obtain multiple groups of log contents; Determine a target proportion of each group of log content in the target file; The target group log content corresponding to the target proportion being greater than or equal to the first preset threshold is determined as the target log content.

4. The method according to claim 1, It is characterized in that The determining whether the target log content is associated with the target business includes: Obtain the business corresponding to the target class package name of the target log content; Determine whether the service corresponding to the target class package name is the target service.

5. The method according to claim 1, It is characterized in that Before determining whether the target log content is associated with the target business, the method includes: Display prompt information, where the prompt information is used to confirm whether the target log content is related to the target business; The determining whether the target log content is associated with the target business includes: In response to a user operation on the prompt information, it is determined whether the target log content is associated with the target business based on whether the user operation is a confirmation operation.

6. The method according to claim 1, It is characterized in that The method further comprises: If source log data to be output is detected, determining target log output content corresponding to the source log data based on the target output strategy; Output the target log file corresponding to the target log output content.

7. The method according to claim 3, It is characterized in that The method further comprises: Generate a visualization chart based on the target proportion of each group of log content in the target file; wherein the visualization chart is used to indicate the target proportion of each group of log content in the target file; The visualization chart is displayed.

8. A log output optimization device, It is characterized in that The device comprises: A first acquisition module is used to acquire initial log files of multiple node devices; wherein the initial log files are log files output based on the initial output strategy; A first determination module is used to determine the target log content in the initial log file; wherein the target log content is used to indicate the log content in the target files of the multiple node devices whose proportion is greater than or equal to a first preset threshold; A second determination module is used to determine whether the target log content is associated with a target business; The third determination module is used to determine a target output strategy based on the target log content if the target log content is not associated with the target business; wherein the target output strategy is used to constrain the log output content in the source log data when the log output is executed next time.

9. An electronic device, It is characterized in that The electronic device comprises: A memory for storing executable program codes; A processor, configured to call and run the executable program code from the memory, so that the electronic device executes the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 7 is implemented.