Full-link log management method and device based on request address, equipment and medium
By establishing a mapping relationship between the request address and the business log configuration, a unique log scope is generated, the problems of scattered log information and unclear recording order in traditional systems are solved, and the consistency, order and integrity of the log are achieved, and problem investigation is simplified.
Patent Information
- Application Number
- CN202411705730.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-04-11
AI Technical Summary
In traditional systems, log information is scattered, and the logs are not chained between requests, which leads to difficulty in tracing log links and unclear logging order, which affects problem location.
By establishing a mapping relationship between the request address and the business log configuration, a unique log scope is generated to ensure the consistency, order and integrity of the log content, and facilitate exception positioning and troubleshooting.
It realizes the establishment of a unique log link for each request, ensures the order and integrity of the logs, and simplifies the problem-solving process.
Smart Images

Figure CN119814538A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of log management, and in particular to a full-link log management method, device, equipment and storage medium based on a request address. Background Art
[0002] In traditional systems, when logging different requests, the following problems are often encountered: log information is scattered, and the logs between requests are not linked, which makes it very difficult to trace the log link; the order of log records is unclear, which complicates the problem location process; when an exception occurs, there is a lack of global context information, making it difficult to quickly identify the problem based on the log content.
[0003] Therefore, how to record and manage logs effectively is of great significance. Summary of the invention
[0004] The present application provides a full-link log management method, device and storage medium based on request address, aiming to establish a unique log link for each request, thereby ensuring the consistency, sequence and integrity of the log content, and facilitating abnormal location and troubleshooting when problems occur.
[0005] In a first aspect, the present application provides a full-link log management method based on a request address, the method comprising:
[0006] Establish a mapping relationship between the request address and the business log configuration;
[0007] Obtaining a user request from a client; wherein the user request includes a target request address of a resource or service requested by the client;
[0008] Based on the target request address, generating a unique identifier corresponding to the user request;
[0009] Based on the target request address and the unique identifier, a log object injection operation is performed on the user request to generate a log scope;
[0010] Based on the unique identifier, obtaining the service request information associated with the user request and writing the service request information into the log scope;
[0011] Based on the mapping relationship, determine whether the service type corresponding to the service request information within the log scope needs to be logged;
[0012] When logging is required, the service request information is logged based on preset logging rules.
[0013] In some embodiments, judging whether the service type corresponding to the service request information within the log scope needs to be logged based on the mapping relationship includes:
[0014] Based on the mapping relationship, determine the log type that needs to be logged for the target request address identified in the business log configuration;
[0015] Matching the service type corresponding to the service request information with the log type that needs to be logged;
[0016] According to the matching result, it is determined whether log recording is required.
[0017] In some embodiments, determining whether logging is required based on the matching result includes:
[0018] Determine the amount of business request information that needs to be logged in the matching result;
[0019] Determining whether the amount of the service request information is greater than a preset threshold;
[0020] If so, confirm that logging is required.
[0021] In some embodiments, the logging of the service request information based on a preset logging rule includes:
[0022] Get the current system's logging load;
[0023] When the log record load is greater than a preset load threshold, the service request information is logged through a message queue.
[0024] In some embodiments, the logging of the service request information based on a preset logging rule includes:
[0025] Based on the service request information, determining whether there is a service abnormality;
[0026] In response to a business exception, the business request information is fully recorded to obtain a full-link log record;
[0027] Based on the abnormal log output strategy, the full-link log record is output.
[0028] In some embodiments, the method further comprises:
[0029] When logging is not required, a pre-release management strategy is executed on the log scope, including:
[0030] Determine whether there is potential abnormal information in the business request information in the log scope;
[0031] If yes, the business request information in the log scope is added to the abnormal message queue, and the log scope is pre-released; the abnormal message queue is used to generate and output a log record based on the business request information when receiving a log output instruction;
[0032] If not, obtaining historical log records from the client corresponding to the user request;
[0033] Based on the service request information, obtaining similar service request information from the historical log record;
[0034] Obtain output mark information of historical log records corresponding to the similar business request information;
[0035] Based on the output mark information, the output probability of the service request information is determined, and when the output probability is greater than a preset probability, the service request information is added to a cache message queue, and the log scope is pre-released.
[0036] In some embodiments, the determining whether there is abnormal information in the business request information in the log scope includes:
[0037] Determine the time point corresponding to each service record in the service request information;
[0038] Generate a time service sequence based on the time point and the service request information;
[0039] Based on the generated time business sequence and the following formula, determine whether there is abnormal information;
[0040]
[0041] y t -S t |>3σ
[0042] Among them, S t is the prediction result of the time business series, μ is the average value of the business time series, p is the autoregressive order, φ i is the coefficient of the autoregressive part, y t-i represents the log value of the previous moment, q is the order of the moving average part, θ j is the coefficient of the moving average part, ∈ t-j is the prediction error at the previous j moment, and the prediction error is y t-j -S t-j ∈ s is the standard deviation of past forecast errors.
[0043] In a second aspect, the present application provides a full-link log management device based on a request address, the device comprising:
[0044] A mapping relationship establishment module, used to establish a mapping relationship between a request address and a business log configuration;
[0045] A request acquisition module, used to acquire a user request from a client; wherein the user request includes a target request address of a resource or service requested by the client;
[0046] An identification generation module, used to generate a unique identification corresponding to the user request based on the target request address;
[0047] A scope generation module, configured to perform a log object injection operation on the user request based on the target request address and the unique identifier to generate a log scope;
[0048] A log writing module, used to obtain the service request information associated with the user request based on the unique identifier and write the service request information into the log scope;
[0049] A judgment module, used for judging whether the service type corresponding to the service request information within the log scope needs to be logged based on the mapping relationship;
[0050] The log recording module is used to log the service request information based on preset log recording rules when log recording is required.
[0051] 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;
[0052] Memory, used to store computer programs;
[0053] The processor is used to implement the steps of the full-link log management method based on the request address described in any embodiment of the first aspect when executing the program stored in the memory.
[0054] In 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 steps of the full-link log management method based on the request address are implemented as described in any embodiment of the first aspect.
[0055] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: in the technical solution of the present invention, a mapping relationship between logs and business operations is pre-established according to the request address, and the user request and the target request address are used to generate a unique log scope. In this way, the system can automatically determine which business module (such as order, payment, user login, etc.) the request belongs to according to the request address, thereby assigning corresponding log recording rules and log type labels to the request. By managing the writing of logs through log scopes, it can be ensured that logs from different user requests are recorded separately, and an orderly full life cycle link is formed to facilitate problem troubleshooting. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] 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.
[0057] 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.
[0058] Figure 1 A flowchart of a full-link log management method based on a request address provided in an embodiment of the present application;
[0059] Figure 2 A schematic diagram of a process for determining whether log recording is required provided in an embodiment of the present application;
[0060] Figure 3 A flow chart of the full-link log management method provided in the embodiment of the present application;
[0061] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0062] 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.
[0063] Figure 1A flowchart of a full-link log management method based on a request address provided in an embodiment of the present application. In some embodiments, process 100 can be executed by an electronic device (e.g., processor 111). Figure 1 As shown, process 100 may include the following operations.
[0064] Step 101: Establish a mapping relationship between a request address and a service log configuration.
[0065] The request address refers to the link address pointed to when the user initiates a request, such as a URL or URI, which can be a path for accessing a specific resource or service.
[0066] Business log configuration refers to the log recording rules and formats set for different business scenarios, including what information needs to be recorded, the log level, storage location, etc.
[0067] Establishing a mapping relationship means establishing a pointing relationship between a request address and a business log configuration. For example, for a certain request address, the mapping relationship can tell you what information needs to be recorded for requests accessing the address when logging, the level of the recorded log, and the storage location of the recorded log.
[0068] The mapping relationship can be a data structure used to associate the service request information with the target request address in the service log configuration and its corresponding log type. For example, it can be a dictionary or a hash table, with the key being the service request information and the value being the mapping between the target request address and the log type.
[0069] In some embodiments, the processor may associate each request address with the corresponding business log configuration through a configuration file or a database, thereby establishing a mapping relationship. For example, each URL path and the corresponding log record rule are defined through a JSON configuration file.
[0070] Step 102: Obtain a user request from a client.
[0071] The user request includes a target request address of a resource or service requested by the client.
[0072] When the server receives a request from the client, the processor can parse the request to obtain the target request address. For example, in a Web application, the target URL is obtained through HTTP request parsing.
[0073] Step 103: Generate a unique identifier corresponding to the user request based on the target request address.
[0074] The unique identifier may be a unique identifier, such as a primary key, etc., which may be used to track the entire life cycle of a user request.
[0075] In some embodiments, the generation of the unique identifier may be implemented based on a UUID or a time-based unique ID.
[0076] Step 104: Based on the target request address and the unique identifier, a log object injection operation is performed on the user request to generate a log scope.
[0077] A log object refers to an object instance used to record log information, which may include all relevant information and methods of the log.
[0078] Scope refers to a lifecycle management method that is effective within the scope of the current request, which ensures that the log object can be correctly released when the request ends.
[0079] In this embodiment, the life cycle of the full-link log is used as the scope, so that each request has an independent log object instance, which is valid throughout the entire life cycle of the request.
[0080] The full-link log refers to all log information generated from the initiation of the request to the completion of the request, including the intermediate processing steps and exception information.
[0081] In some embodiments, a log object may be created at the beginning of request processing through dependency injection or factory mode and associated with a unique identifier.
[0082] Step 105: Based on the unique identifier, obtain the service request information associated with the user request and write it into the log scope.
[0083] In some embodiments, during the request processing, relevant business request information may be captured and collected, and the information may be recorded in a log scope.
[0084] Business request information refers to the request data received by the system, including but not limited to the requested URL, HTTP method, request parameters, request header, etc.
[0085] Step 106: Based on the mapping relationship, determine whether the service type corresponding to the service request information within the log scope needs to be logged.
[0086] In some embodiments, the business type corresponding to the business request information can be implemented by aspect-oriented programming (AOP). Through aspect-oriented programming, the system can mark different log types at the interface position of the code. In simple terms, it is to add some annotations or labels at specific locations of the code (usually functions or interfaces) so that the system can automatically identify which category the log of this part of the code belongs to. For example, for different business operations (such as "order processing" or "payment processing"), by adding corresponding "order log" or "payment log" labels to the interface of the relevant code, these labels tell the system that when processing these interfaces, it should record specific types of logs, so as to obtain the business type corresponding to the business request information.
[0087] Aspect-oriented programming is a programming paradigm that is used to inject functionality, such as logging, through aspect technology without changing the business logic of the code.
[0088] In some embodiments, it can be determined whether the current request needs to be logged based on a predefined mapping relationship and a business log configuration. For example, if the target request address corresponding to the current request can find a corresponding business log in the mapping relationship, it is determined that a log recording operation needs to be performed based on the business log.
[0089] In this embodiment, when using the full-link log, log service classification is involved. By mapping the configuration ID of the log service type and using AOP to define it in the code interface, it is easier to locate the log service type.
[0090] Step 107: If logging is required, log the service request information based on preset logging rules.
[0091] Preset log recording rules refer to the pre-set log recording methods / constraints. Preset log recording rules can be set according to specific business needs and system architecture, such as log level rules, log content rules, log format rules, log storage rules, exception and error handling rules, security and privacy rules, etc.
[0092] In some embodiments, the processor may write the service request information into a log file or a log system according to a preset log recording rule, for example, formatting the log information into JSON and sending it to a log collection server.
[0093] In some embodiments, the logging of the business request information based on preset logging rules includes: obtaining the logging load of the current system; when the logging load is greater than a preset load threshold, logging the business request information through a message queue.
[0094] The logging load refers to the amount of logging operations performed by the current system over a period of time. It can usually be measured by indicators such as the frequency of logging operations and the size of the logging file.
[0095] The preset load threshold may be a preset value used to determine whether the current system log record load is too high. For example, the preset load threshold may be processing 1000 log requests per second.
[0096] A message queue is a mechanism for asynchronous communication that can temporarily store business request information and process it in sequence when the system load is too high to avoid system crashes or performance degradation.
[0097] In this embodiment, since the log content message will be relatively large after the log forms a link, at this time, the log content can be sent asynchronously through an independent log system, and the exception can be controlled. Even if the log error occurs, it will not affect the operation of the business process. In addition, when there is a problem with storing logs during peak hours, a message queue is used to queue the consumption log information and store it, which solves the problem of log writing concurrency.
[0098] In some embodiments, the business request information is logged based on preset log recording rules, including: judging whether there is a business abnormality based on the business request information; in response to a business abnormality, performing a full-link recording of the business request information to obtain a full-link log record; and outputting the full-link log record based on an abnormal log output strategy.
[0099] Among them, business exceptions can be errors or abnormal situations that occur during business processing, such as request failure, timeout, data error, etc.
[0100] Full-link logging refers to detailed and complete logging of all operations and status changes of a business request from initiation to completion.
[0101] The exception log output strategy refers to the log recording strategy for business exceptions, which defines how, when, and in what form the full-link log is output.
[0102] Exemplarily, when processing business request information, the system can monitor various abnormal situations in real time, such as request timeout, data error, etc. If an abnormal situation is detected, the business request is marked as abnormal. Once a business abnormality is detected, the full-link recording mechanism is started. Record all steps and state changes from request initiation, data processing to response return, and generate a complete log record. After that, decide how to output the full-link log according to the predefined exception log output strategy. For example, immediately output to a log file, send to a monitoring system, or store in a database for subsequent analysis. Ensure that the full-link log records can be output and stored in a timely and accurate manner to troubleshoot and resolve business anomalies.
[0103] In this embodiment, by effectively managing the system's log record load and performing detailed full-link log records when business exceptions occur, problems can be promptly checked and resolved, which not only improves the stability of the system but also enhances the reliability of exception handling.
[0104] When the full-link context log is thrown (output) in the event of an exception, it is also possible to configure whether all the full-link logs need to be thrown according to the actual scenario, and set the level of throwing the full-link log.
[0105] Figure 2 In some embodiments, judging whether the business type corresponding to the business request information within the log scope needs to be logged based on the mapping relationship in step 106 may include the following operations as shown in process 200.
[0106] Step 201: Based on the mapping relationship, determine the log type that needs to be logged for the target request address identified in the business log configuration.
[0107] Log type refers to the category of log records, which can include different levels such as DEBUG, INFO, WARN, ERROR, FATAL, or other types defined according to business needs.
[0108] In some embodiments, service request information may be extracted from the received request, such as URL, HTTP method, request parameters, etc. to obtain the service request information.
[0109] By querying the mapping relationship, for example, using the business request information as a key to query the predefined mapping relationship, the corresponding target request address and log type can be found. After that, the log type corresponding to the target request address is extracted from the mapping relationship. These log types are pre-defined in the business log configuration to obtain the log type that needs to be logged.
[0110] Step 202: Match the service type corresponding to the service request information with the log type that needs to be logged.
[0111] Matching may refer to checking whether the service type corresponding to the service request information is in a list of log types that need to be logged.
[0112] Step 203: Determine whether log recording is required based on the matching result.
[0113] If the business type successfully matches the log type that needs to be logged, it is determined that logging is required; if the business type does not match the log type that needs to be logged, it is determined that logging is not required.
[0114] If it is determined that log recording is required, log recording is performed according to the preset log recording rules, including recording log content and storage location.
[0115] In some embodiments, determining whether logging is required based on the matching result includes: determining the number of business request information that needs to be logged in the matching result; judging whether the number of business request information is greater than a preset threshold; if so, determining that logging is required.
[0116] The number of business request information refers to the total number of business request information that needs to be logged in the matching results received by the system within a certain period of time.
[0117] The preset threshold may be a preset value used to determine whether the number of service request information reaches the standard for log recording. For example, the preset threshold may be 10, indicating that logs are recorded only when the number of service request information is greater than 10.
[0118] Figure 3 A schematic diagram of a flow chart of a full-link log management method provided in an embodiment of the present application. In some embodiments, process 300 may be executed by an electronic device (eg, processor 111).
[0119] In some embodiments, when logging is not required, a pre-release management policy may be executed on the log scope through the operations shown in process 300 .
[0120] The pre-release management strategy refers to a management method that prepares or releases resources in advance to improve system efficiency when the log scope is no longer needed.
[0121] Step 301: determine whether there is potential abnormal information in the business request information in the log scope.
[0122] Potential abnormal information refers to the presence of signs or data in business request information that may cause abnormalities, such as abnormal request parameters, historical abnormal behaviors, etc.
[0123] In some embodiments, during the service request processing, the request parameters, request path, historical abnormal records, etc. are analyzed to determine whether there is potential abnormal information, for example, detecting abnormal request parameters or matching historical abnormal behavior records.
[0124] Step 302: If yes, add the business request information in the log scope to the abnormal message queue, and pre-release the log scope.
[0125] The abnormal message queue is used to generate and output a log record based on the business request information when receiving a log output instruction. For example, the abnormal message queue can be used to store a queue of business request information containing potential abnormal information, and generate and output a log record when receiving a log output instruction.
[0126] In some embodiments, if potential abnormal information is determined, the service request information is placed in an abnormal message queue, and a pre-release operation is performed to release resources occupied by the log scope to improve system performance.
[0127] Step 303: If not, obtain the historical log record from the client corresponding to the user request.
[0128] Historical log records are log records of previous business requests that have been stored in the system.
[0129] In some embodiments, if no potential abnormal information is detected, historical log records related to the user request can be retrieved, for example, historical records can be obtained based on user ID, request type, etc.
[0130] Step 304: Based on the service request information, similar service request information is obtained from the historical log records.
[0131] Similar service request information is historical service request information that has certain similar features (such as request type, parameters, etc.) to the current service request information.
[0132] In some embodiments, the current service request information can be compared with the historical log records to find similar request information. Similar request information can be matched based on features such as request parameters, request paths, and user behaviors.
[0133] Step 305: Obtain output mark information of the historical log record corresponding to the similar service request information.
[0134] Output mark information refers to the output information marked in the historical log records, such as whether the log is output and the output time.
[0135] In some embodiments, information of similar service requests and their corresponding output tag information may be extracted from historical log records.
[0136] Step 306: determine the output probability of the service request information based on the output tag information, and when the output probability is greater than a preset probability, add the service request information to a cache message queue and pre-release the log scope.
[0137] The output probability refers to the probability of whether the current business request information needs to output a log based on historical data. In some embodiments, the output probability of the current business request information can be calculated based on the historical output of similar business requests. For example, statistical methods or machine learning models are used to perform probability calculations.
[0138] The preset probability can be a preset threshold value used to determine whether the current service request information should be recorded and output to the log. For example, a preset probability threshold value is set, such as 0.7, and if the calculated output probability is greater than the preset probability threshold value, the service request information is added to the cache message queue.
[0139] The cache message queue is a queue used to temporarily store business request information waiting to determine whether log records need to be output.
[0140] In some embodiments, the determining whether there is abnormal information in the service request information in the log scope includes: determining a time point corresponding to each service record in the service request information; generating a time service sequence based on the time point and the service request information; determining whether there is abnormal information based on the generated time service sequence and the following formulas (1) and (2);
[0141]
[0142] y t -S t |>3σ (2)
[0143] Among them, S t is the prediction result of the time business series, μ is the average value of the business time series, p is the autoregressive order, φ i is the coefficient of the autoregressive part, y t-i represents the log value of the previous moment, q is the order of the moving average part, θ j is the coefficient of the moving average part, ∈ t-j is the prediction error at the previous j moment, and the prediction error is y t-j -S t-j ∈ s is the standard deviation of past forecast errors. t -S t |>3σ, it is determined that there is abnormal information.
[0144] In some embodiments, for each service request record, the time point at which it occurred can be extracted. For example, if the service request information includes a timestamp field, the field is directly read. The service request information is arranged in chronological order to form a time service sequence.
[0145] In this embodiment, time series analysis technology is used to predict the normal range of business requests through autoregression and moving average models (Formulas 1 and 2 above), and whether there is an anomaly is determined based on the prediction error, thereby improving the system's anomaly detection capability and response efficiency.
[0146] The beneficial effects that can be brought about by the embodiments of the present application include: all logs of the entire request life cycle can be tracked through a link, and all the contextual content of the log will be recorded in the event of an exception. If there is a problem, it can be solved based on the contextual content, and the log records have a chronological order. Compared with the traditional method of looking for the source of the log everywhere, this method can locate the problem more quickly and can better eliminate the problem based on the source data.
[0147] Based on the same inventive concept, the embodiment of the present application also provides a full-link log management device based on a request address, the device comprising:
[0148] A mapping relationship establishment module, used to establish a mapping relationship between a request address and a business log configuration;
[0149] A request acquisition module, used to acquire a user request from a client; wherein the user request includes a target request address of a resource or service requested by the client;
[0150] An identification generation module, used to generate a unique identification corresponding to the user request based on the target request address;
[0151] A scope generation module, configured to perform a log object injection operation on the user request based on the target request address and the unique identifier to generate a log scope;
[0152] A log writing module, used to obtain the service request information associated with the user request based on the unique identifier and write the service request information into the log scope;
[0153] A judgment module, used for judging whether the service type corresponding to the service request information within the log scope needs to be logged based on the mapping relationship;
[0154] The log recording module is used to log the service request information based on preset log recording rules when log recording is required.
[0155] like Figure 4 As shown, an embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0156] Memory 113, used for storing computer programs;
[0157] In one embodiment of the present application, the processor 111 is configured to execute a program stored in the memory 113 to implement a method for full-link log management based on a request address provided by any of the aforementioned method embodiments, including:
[0158] Establish a mapping relationship between the request address and the business log configuration;
[0159] Obtaining a user request from a client; wherein the user request includes a target request address of a resource or service requested by the client;
[0160] Based on the target request address, generating a unique identifier corresponding to the user request;
[0161] Based on the target request address and the unique identifier, a log object injection operation is performed on the user request to generate a log scope;
[0162] Based on the unique identifier, obtaining the service request information associated with the user request and writing the service request information into the log scope;
[0163] Based on the mapping relationship, determine whether the service type corresponding to the service request information within the log scope needs to be logged;
[0164] When logging is required, the service request information is logged based on preset logging rules.
[0165] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the full-link log management method based on the request address provided in any of the aforementioned method embodiments are implemented.
[0166] 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.
[0167] 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 full-link log management method based on request address, characterized in that: The method comprises: Establish a mapping relationship between the request address and the business log configuration; Obtaining a user request from a client; wherein the user request includes a target request address of a resource or service requested by the client; Based on the target request address, generating a unique identifier corresponding to the user request; Based on the target request address and the unique identifier, a log object injection operation is performed on the user request to generate a log scope; Based on the unique identifier, obtaining the service request information associated with the user request and writing the service request information into the log scope; Based on the mapping relationship, determine whether the service type corresponding to the service request information within the log scope needs to be logged; When logging is required, the service request information is logged based on preset logging rules.
2. The method according to claim 1, characterized in that The determining, based on the mapping relationship, whether the service type corresponding to the service request information within the log scope needs to be logged includes: Based on the mapping relationship, determine the log type that needs to be logged for the target request address identified in the business log configuration; Matching the service type corresponding to the service request information with the log type that needs to be logged; According to the matching result, it is determined whether log recording is required.
3. The method according to claim 2, characterized in that The determining whether log recording is required according to the matching result includes: Determine the amount of business request information that needs to be logged in the matching result; Determining whether the amount of the service request information is greater than a preset threshold; If so, confirm that logging is required.
4. The method according to claim 1, characterized in that: The logging of the service request information based on the preset logging rule includes: Get the current system's logging load; When the log record load is greater than a preset load threshold, the service request information is logged through a message queue.
5. The method according to claim 1, characterized in that: The logging of the service request information based on a preset logging rule includes: Based on the service request information, determining whether there is a service abnormality; In response to a business exception, the business request information is fully recorded to obtain a full-link log record; Based on the abnormal log output strategy, the full-link log record is output.
6. The method according to claim 1, characterized in that The method further comprises: When logging is not required, a pre-release management strategy is executed on the log scope, including: Determine whether there is potential abnormal information in the business request information in the log scope; If yes, the business request information in the log scope is added to the abnormal message queue, and the log scope is pre-released; the abnormal message queue is used to generate and output a log record based on the business request information when receiving a log output instruction; If not, obtaining historical log records from the client corresponding to the user request; Based on the service request information, obtaining similar service request information from the historical log record; Obtain output mark information of historical log records corresponding to the similar business request information; Based on the output mark information, the output probability of the service request information is determined, and when the output probability is greater than a preset probability, the service request information is added to a cache message queue, and the log scope is pre-released.
7. The method according to claim 6, characterized in that The determining whether there is abnormal information in the business request information in the log scope includes: Determine the time point corresponding to each service record in the service request information; Generate a time service sequence based on the time point and the service request information; Based on the generated time business sequence and the following formula, determine whether there is abnormal information; y t -S t |>3σ Among them, S t is the prediction result of the time business series, μ is the average value of the business time series, p is the autoregressive order, φ i is the coefficient of the autoregressive part, y t-i represents the log value of the previous moment, q is the order of the moving average part, θ j is the coefficient of the moving average part, ∈ t-j is the prediction error at the previous j moment, and the prediction error is y t-j -S t-j ∈ s is the standard deviation of past forecast errors.
8. A full-link log management device based on request address, characterized in that: The device comprises: A mapping relationship establishment module is used to establish a mapping relationship between a request address and a business log configuration; A request acquisition module, used to acquire a user request from a client; wherein the user request includes a target request address of a resource or service requested by the client; An identification generation module, used to generate a unique identification corresponding to the user request based on the target request address; A scope generation module, configured to perform a log object injection operation on the user request based on the target request address and the unique identifier to generate a log scope; A log writing module, used to obtain the service request information associated with the user request based on the unique identifier and write the service request information into the log scope; A judgment module, used for judging whether the service type corresponding to the service request information within the log scope needs to be logged based on the mapping relationship; The log recording module is used to log the service request information based on preset log recording rules when log recording is required.
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 steps of the full-link log management method based on the request address as 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 the processor, the steps of the full-link log management method based on the request address are implemented.
Citation Information
Cited By
Log recording method and device based on dynamic context awareness and medium
CN120407534A