A log recording method, device, equipment and readable storage medium
By reversing the order of the URL to determine the test items and matching key information, the problem of logging difficulty caused by full URL parsing is solved, and efficient and accurate logging is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JINAN INSPUR DATA TECH CO LTD
- Filing Date
- 2022-07-27
- Publication Date
- 2026-05-12
AI Technical Summary
在复杂业务场景下,现有技术需要全量解析URL进行日志记录,导致算力需求高且日志信息不够精简,增加了记录难度。
Starting from the end of the URL, the test items are determined in reverse order, and key information is matched and logged according to preset rules, including key information rules, key information location rules, and regular expression rules. If no match is found, all characters are matched.
It improves the efficiency and accuracy of log recording, reduces the probability of recording redundant information, and enhances the accuracy of logs.
Smart Images

Figure CN115269324B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a log recording method, apparatus, device, and readable storage medium. Background Technology
[0002] Currently, logging actual accessed URLs requires full parsing of the entire URL path. In more complex business scenarios, due to the large number of URLs, full parsing of all URLs requires significant computing power, and the logged information may not be concise enough, increasing the difficulty of logging.
[0003] Therefore, how to efficiently determine the information in the URL that needs to be logged, and improve the accuracy and efficiency of logging, is a problem that needs to be solved by those skilled in the art. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a logging method, apparatus, device, and readable storage medium to efficiently determine the information in the URL that needs to be logged, thereby improving log accuracy and recording efficiency. The specific solution is as follows:
[0005] Firstly, this application provides a logging method, including:
[0006] Get the URL corresponding to the HTTP request;
[0007] Starting from the end of the URL, determine each item to be tested in the URL in reverse order;
[0008] The URLs are matched according to the determined order of each item to be tested. If the URL matches a preset rule, the matched content is logged.
[0009] Optionally, determining the items to be tested in the URL in reverse order, starting from the end of the URL, includes:
[0010] From the end to the beginning of the URL, characters located between adjacent separators are identified as test items, and / or characters at specific positions are identified as test items, and / or specific characters are identified as test items, in order to determine the test items existing in the URL in reverse order.
[0011] Optionally, if the URL matches a preset rule, logging is performed on the matching content, including:
[0012] The preset rules include: key information rules, key information location rules, and regular expression rules;
[0013] For the URL, the key information rules are first used for matching. If the URL matches the key information rules, the matching content is logged.
[0014] Optionally, it also includes:
[0015] If the URL does not match the key information rule, then the key information location rule is used for matching. If the URL matches the key information location rule, then the matching content is logged.
[0016] Optionally, it also includes:
[0017] If the URL does not match the key information rule, then the key information location rule is used for matching. If the URL matches the key information location rule, then the matching content is logged.
[0018] Optionally, it also includes:
[0019] If the URL does not match the key information rule, the key information location rule, or the regular expression rule, then the URL will be logged.
[0020] Optionally, it also includes:
[0021] Analyze the URLs recorded in the logs to obtain the analysis results;
[0022] The preset rules are completed based on the analysis results.
[0023] Optionally, the preset rules further include: full-character matching rules; correspondingly, before determining each item to be tested in the URL in reverse order starting from the end of the URL, the following steps are also included:
[0024] Use full-character matching rules to match all characters in the URL;
[0025] If the match fails, the following steps are performed: starting from the end of the URL, determine each item to be tested in the URL in reverse order; match the URL according to the determined order of each item to be tested; if the URL matches a preset rule, log the matching content.
[0026] Secondly, this application provides a log recording device, comprising:
[0027] The retrieval module is used to retrieve the URL corresponding to the HTTP request;
[0028] The determination module is used to determine each item to be tested in the URL in reverse order, starting from the end of the URL;
[0029] The recording module is used to match the URLs according to the determined order of each item to be tested. If the URL matches a preset rule, the matching content is logged.
[0030] Optionally, the module is specifically used for:
[0031] From the end to the beginning of the URL, characters located between adjacent separators are identified as test items, and / or characters at specific positions are identified as test items, and / or specific characters are identified as test items, in order to determine the test items existing in the URL in reverse order.
[0032] Optionally, the recording module includes:
[0033] The keyword matching unit is used to first match the URL using the key information rules. If the URL matches the key information rules, the matching content is logged. The preset rules include: key information rules, key information location rules, and regular expression rules.
[0034] Optionally, the recording module also includes:
[0035] The key location matching unit is used to match the key information location rule if the URL does not match the key information rule, and to log the matching content if the URL matches the key information location rule.
[0036] Optionally, the recording module also includes:
[0037] The regular expression matching unit is used to match the URL with the key information location rule if the URL does not match the key information rule, and to log the matching content if the URL matches the key information location rule.
[0038] Optionally, the recording module also includes:
[0039] The URL recording unit is used to record the URL to the log if the URL does not match the key information rule, the key information location rule, or the regular expression rule.
[0040] Optionally, it also includes:
[0041] The analysis module is used to analyze each URL recorded in the log to obtain analysis results; and to complete the preset rules based on the analysis results.
[0042] Optionally, it also includes:
[0043] The full-character matching module is used to match all characters in the URL using full-character matching rules; if the match fails, the steps in the determination module and the recording module are executed.
[0044] Thirdly, this application provides an electronic device, comprising:
[0045] Memory, used to store computer programs;
[0046] A processor is configured to execute the computer program to implement the aforementioned disclosed logging method.
[0047] Fourthly, this application provides a readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned disclosed logging method.
[0048] As can be seen from the above scheme, this application provides a logging method, including: obtaining the URL corresponding to the HTTP request; determining each item to be tested in the URL in reverse order starting from the end of the URL; matching the URL according to the determination order of each item to be tested; and logging the matching content if the URL matches a preset rule.
[0049] As can be seen, this application can determine the test items in the URL in reverse order, starting from the end of the URL, and then match the current URL according to the determination order of the test items (i.e., reverse order). If the URL matches a preset rule, the matched content is logged. The key information in the URL is operation-related information (such as operation type, operated file, etc.), and this information is generally located at the end of the URL. Therefore, matching the URL starting from the end can quickly find the key information to be recorded. If the current URL matches a preset rule, it means that key information that needs to be logged has been matched, so the matched content is logged, thereby accurately determining the key information to be recorded. Therefore, this application does not need to analyze the entire URL, but quickly determines the key information to be logged from the end of the URL, thereby improving logging efficiency, reducing the probability of recording redundant information, and improving logging accuracy.
[0050] Correspondingly, the log recording device, equipment, and readable storage medium provided in this application also have the above-mentioned technical effects. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0052] Figure 1 This is a flowchart of a log recording method disclosed in this application;
[0053] Figure 2 This is a schematic diagram illustrating the implementation process of one of the solutions disclosed in this application;
[0054] Figure 3 This is a schematic diagram of a log recording device disclosed in this application;
[0055] Figure 4 This is a schematic diagram of an electronic device disclosed in this application. Detailed Implementation
[0056] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0057] Currently, logging actual accessed URLs requires full URL path parsing. In complex business scenarios, due to the large number of URLs, full parsing of all URLs requires significant computing power, and the recorded log information may not be concise enough, increasing the difficulty of logging. Therefore, this application provides a logging scheme that can efficiently determine the information in the URL that needs to be logged, improving log accuracy and recording efficiency.
[0058] See Figure 1 As shown in the figure, this application discloses a log recording method, including:
[0059] S101. Obtain the URL corresponding to the HTTP request.
[0060] S102. Starting from the end of the URL, determine the items to be tested in the URL in reverse order.
[0061] In one specific implementation, starting from the end of the URL, the test items in the URL are determined in reverse order. This includes: identifying characters between adjacent separators as test items from the end of the URL to the beginning, and / or identifying characters at specific positions as test items, and / or identifying specific characters as test items, to determine the test items in the URL in reverse order. The separator in the URL is generally " / ". For example, if the URL is " / api / database / create / ", then "create" is a test item, "database" is also a test item, and "api" is naturally also a test item. Thus, "create", "database", and "api" are identified as the three test items. The URL is then matched according to the order in which these three test items were determined (that is, the reverse order of these three test items in the URL).
[0062] Of course, specific positions can be pre-defined as test items; that is, regardless of the character at a specific position in the URL, that character is considered a test item. Similarly, specific characters can be pre-defined as test items; that is, if a specific character appears in the URL, that specific character is a test item. Furthermore, a specific character set can be pre-defined; if any character in the URL appears in the specific character set, then that character is a test item.
[0063] In this process, when matching URLs, the key information rules in the preset rules are used first. If the key information rules cannot match the current URL, the key information location rules and regular expression rules in the preset rules are then used. If the current URL does not match any of the key information rules, key information location rules, or regular expression rules, then the current URL is recorded for subsequent analysis. Therefore, in one specific implementation, if the URL does not match any of the key information rules, key information location rules, or regular expression rules, the URL is recorded in the log. In another specific implementation, the URLs recorded in the log are analyzed to obtain analysis results; the preset rules are then supplemented based on the analysis results.
[0064] S103. Match the URLs according to the determined order of each item to be tested. If the URL matches the preset rule, log the matching content.
[0065] In one specific implementation, if the URL matches a preset rule, the matched content is logged. The preset rule includes: a key information rule, a key information location rule, and a regular expression rule. For the URL, the key information rule is first used for matching. If the URL matches the key information rule, the matched content is logged. If the URL does not match the key information rule, the key information location rule is used for matching. If the URL matches the key information location rule, the matched content is logged. If the URL does not match the key information location rule, a regular expression rule is used for matching. If the URL matches the regular expression rule, the matched content is logged.
[0066] In one specific implementation, the preset rule further includes a full-character matching rule. Therefore, the scheme also includes the following steps: matching all characters in the URL using the full-character matching rule; if the matching fails, determining each test item in the URL in reverse order starting from the end of the URL; matching the URL according to the determination order of each test item; and logging the matching content if the URL matches the preset rule.
[0067] Full-character matching rules can be recorded in the form of "URL=key value". A single full-character matching rule would look like this: ` / account-server-outer / import_user=accountout.import_user / model-deploy / promote=deploy.promote`. Here, ` / account-server-outer / import_user=accountout.import_user / model-deploy / promote` is a URL, and `deploy.promote` is the key value corresponding to that URL. This key value determines the log information that needs to be recorded.
[0068] Therefore, this embodiment provides full-character matching rules, key information rules, key information location rules, and regular expression rules. This embodiment prioritizes full-character matching rules; if matching fails, key information rules are used; if matching still fails, the key information location rules and regular expression rules are then applied. It is evident that this embodiment uses the rules in a predetermined order. Full-character matching rules have a limited number of rules and can quickly determine whether a match is successful or not, therefore they are used first. Key information rules and key information location rules have moderate matching efficiency, so they are used in the middle order. Regular expression rules have lower matching efficiency than other rules, so they are used last. Thus, this embodiment improves matching efficiency.
[0069] To ensure that rules are used in sequence, a priority setting can be assigned to each rule, determining the rule to be used currently based on its priority. The priority of full-character matching rules, key information rules, key information location rules, and regular expression rules is arranged from highest to lowest.
[0070] As can be seen, this embodiment can determine the test items in the URL in reverse order, starting from the end of the URL, and then match the current URL according to the determination order of the test items (i.e., reverse order). If the URL matches a preset rule, the matched content is logged. The key information in the URL is information related to the operation (such as the operation type, the file being operated on, etc.), and this information is generally located at the end of the URL. Therefore, matching the items in the URL starting from the end can quickly find the key information to be recorded. If the current URL matches a preset rule, it means that key information that needs to be logged has been matched, so the matched content is logged, thereby accurately determining the key information to be recorded. It is evident that this application does not require full analysis of the entire URL, but rather quickly determines the key information in the URL that needs to be logged starting from the end of the URL, thereby improving logging efficiency, reducing the probability of recording redundant information, and improving log accuracy.
[0071] Please see Figure 2 , Figure 2 This paper presents the implementation steps of a logging scheme. Specifically, the scheme first categorizes URLs, then defines configuration files, and initializes a data structure based on the configuration files. Upon obtaining a specific URL, the scheme uses the aforementioned data structure to log that URL.
[0072] 1. URL categorization.
[0073] For URLs with regular patterns, regular expression matching, key information position matching, and key information matching can be used. For URLs with irregular patterns, full character matching is required to determine the information in the URL that needs to be logged. Based on this, regular expression matching rules, key information position matching rules, key information matching rules, and full character matching rules can be set. A key information matching rule could be: `special_operatecode = full_backup.drain(specific character set)`, meaning that if a certain character in the URL appears in the specific character set, then the relevant log information for that character will be logged.
[0074] 2. Define the configuration file and determine the data structure.
[0075] (1) The configuration file corresponding to the full-character matching rule can record the full-character matching rule and its corresponding key value. The configuration file corresponding to the regular expression matching rule can record the regular expression matching rule and its corresponding key value. And so on. For example, the regular expression matching rule and its corresponding key value are: / model-manager / [a-z_-]*=model(key value), / pod-file-manager / [a-z_-]*=pod_file(key value), etc.
[0076] (2) Based on the set configuration file, the contents of the configuration file are parsed into the corresponding MAP data structure, so as to obtain the data structures corresponding to the regular expression matching rules, key information position matching rules, key information matching rules and full character matching rules respectively.
[0077] 3. Log recording.
[0078] After receiving an HTTP request, the server performs reverse matching on the characters in the URL corresponding to the HTTP request in the following order: full character matching rules, key information matching rules, key information position matching rules, and regular expression matching rules, in order to detect the information that needs to be logged.
[0079] (1) Match the current URL based on the random MAP corresponding to the full character matching rule. If the match is successful, log the corresponding log keyword.
[0080] (2) If (1) fails to match, then the characters in the URL are matched in reverse order. Specifically, the characters in the URL are matched in reverse order using the keyword MAP corresponding to the key information matching rule. If the match is successful, the corresponding log keyword is used for logging. If the match fails, the characters in the URL are matched in reverse order using the keyword position MAP corresponding to the key information position matching rule. If the match is successful, the corresponding log keyword is used for logging. If the match still fails, the characters in the URL are matched in reverse order using the regular expression matching rule. If the match is successful, the corresponding log keyword is used for logging. If the match still fails, proceed to step (3).
[0081] (3) Logs are recorded with the full URL so that URL features can be summarized later and the corresponding configuration files can be updated based on the URL features, thereby improving the corresponding data structure.
[0082] By applying the rules sequentially—first full-character matching, then key information matching, then key information position matching, and finally regular expression matching—matching efficiency can be improved. Furthermore, this embodiment uses reverse matching of characters in the URL, balancing performance and memory usage. Compared to full forward matching of the URL, performance is improved by several times.
[0083] The aforementioned configuration files are as follows: (1) `inference_operate_object_nonregular.properties`, used to record the full-character matching rules for nonregular URLs; and (2) `inference_operate_object_database.properties`, used to record the key information matching rules, key information location matching rules, and regular expression matching rules for regular URLs. Based on these two configuration files, feature data MAPs can be generated, such as: account, deploy, system, regular, etc.
[0084] Suppose an HTTP request corresponds to the URL ` / model-deploy / serviceA`, and the configuration file contains the following setting: ` / model-deploy / [a-z_-]*=deploy.service`. First, a query in the unregistered MAP will find that this MAP does not match the URL. Next, a query in the keyword MAP will also find that the keyword MAP does not match the URL. Finally, a query in the regular expression MAP will find that it matches successfully. Therefore, the logging keyword can be determined as `deploy.service`, and operation logs will be recorded using this keyword. In other words, the log information to be recorded is determined based on "deploy.service".
[0085] As can be seen, this embodiment optimizes the matching order and improves matching efficiency by placing fast string matching at the beginning and regular expression matching at the end. Furthermore, this embodiment matches URLs in reverse order from back to front, thus balancing performance and memory usage.
[0086] The following describes a log recording device provided in an embodiment of this application. The log recording device described below and the log recording method described above can be referred to each other.
[0087] See Figure 3 As shown in the figure, this application discloses a log recording device, including:
[0088] Module 301 is used to obtain the URL corresponding to the HTTP request;
[0089] The determination module 302 is used to determine each item to be tested in the URL in reverse order, starting from the end of the URL.
[0090] The recording module 303 is used to match the URL according to the determined order of each item to be tested. If the URL matches the preset rule, the matching content is logged.
[0091] In one specific implementation, the determining module is specifically used for:
[0092] From the end of the URL to the beginning, characters located between adjacent separators are identified as test items, and / or characters at specific positions are identified as test items, and / or specific characters are identified as test items, in order to identify the test items in the URL in reverse order.
[0093] In one specific implementation, the recording module includes:
[0094] The keyword matching unit is used to first match the URL using the key information rules. If the URL matches the key information rules, the matching content is logged. The preset rules include: key information rules, key information location rules, and regular expression rules.
[0095] In one specific implementation, the recording module further includes:
[0096] The key location matching unit is used to match the URL if the URL does not match the key information rule, and to log the matching content if the URL matches the key information location rule.
[0097] In one specific implementation, the recording module further includes:
[0098] The regular expression matching unit is used to match the URL with the key information location rule if the URL does not match the key information rule, and to log the matching content if the URL matches the key information location rule.
[0099] In one specific implementation, the recording module further includes:
[0100] The URL recording unit is used to record the URL to the log if the URL does not match the key information rule, the key information location rule, or the regular expression rule.
[0101] In one specific implementation, it further includes:
[0102] The analysis module is used to analyze the various URLs recorded in the logs and obtain analysis results; it also completes the preset rules based on the analysis results.
[0103] In one specific implementation, it further includes:
[0104] The full match module is used to match all characters in the URL using full character matching rules; if the match fails, the steps in the determine module and the record module are executed.
[0105] For more detailed information on the working process of each module and unit in this embodiment, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0106] As can be seen, this embodiment provides a log recording device that can efficiently determine the information in the URL that needs to be recorded in the log, thereby improving log accuracy and recording efficiency.
[0107] The following describes an electronic device provided by an embodiment of this application. The electronic device described below can be referred to in conjunction with the log recording method and apparatus described above.
[0108] See Figure 4 As shown in the figure, an embodiment of this application discloses an electronic device, including:
[0109] Memory 401 is used to store computer programs;
[0110] Processor 402 is configured to execute a computer program to implement the methods disclosed in any of the above embodiments.
[0111] In this embodiment, when the processor executes the computer program stored in the memory, it can specifically implement the following steps: obtain the URL corresponding to the HTTP request; starting from the end of the URL, determine each item to be tested in the URL in reverse order; match the URL according to the determined order of each item to be tested; if the URL matches a preset rule, log the matching content.
[0112] In this embodiment, when the processor executes the computer program stored in the memory, it can specifically implement the following steps: from the end of the URL to the beginning, determine the characters located between adjacent separators as a test item, and / or determine the characters at a specific position as a test item, and / or determine a specific character as a test item, so as to determine the test items existing in the URL in reverse order.
[0113] In this embodiment, when the processor executes the computer program stored in the memory, it can specifically implement the following steps: the preset rules include: key information rules, key information location rules, and regular expression rules; for the URL, the key information rules are first used for matching, and if the URL matches the key information rules, the matching content is logged.
[0114] In this embodiment, when the processor executes the computer program stored in the memory, it can specifically implement the following steps: for a URL, if the URL does not match the key information rule, then the key information location rule is used for matching; if the URL matches the key information location rule, then the matched content is logged.
[0115] In this embodiment, when the processor executes the computer program stored in the memory, it can specifically implement the following steps: if the URL does not match the key information rule, then the key information location rule is used for matching; if the URL matches the key information location rule, then the matched content is logged.
[0116] In this embodiment, when the processor executes the computer program stored in the memory, it can specifically implement the following steps: if the URL does not match the key information rule, the key information location rule, or the regular expression rule, then the URL is recorded in the log.
[0117] In this embodiment, when the processor executes the computer program stored in the memory, it can specifically implement the following steps: analyze each URL recorded in the log to obtain the analysis results; and complete the preset rules based on the analysis results.
[0118] In this embodiment, when the processor executes the computer program stored in the memory, it can specifically implement the following steps: matching all characters in the URL using a full character matching rule; if the matching fails, then starting from the end of the URL, determining each item to be tested in the URL in reverse order; matching the URL according to the determined order of each item to be tested; if the URL matches a preset rule, then logging the matching content.
[0119] Furthermore, this application also provides a server as the aforementioned electronic device. Specifically, the server may include: at least one processor, at least one memory, a power supply, a communication interface, an input / output interface, and a communication bus. The memory stores a computer program, which is loaded and executed by the processor to implement the relevant steps in the logging method disclosed in any of the foregoing embodiments.
[0120] In this embodiment, the power supply is used to provide operating voltage for each hardware device on the server; the communication interface can create a data transmission channel between the server and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0121] In addition, the memory, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored on it include operating system, computer programs and data, etc., and the storage method can be temporary storage or permanent storage.
[0122] The operating system is used to manage and control the various hardware devices and computer programs on the server, enabling the processor to perform operations and processes on the data in the memory. It can be Windows Server, Netware, Unix, Linux, etc. In addition to computer programs capable of performing the logging methods disclosed in any of the foregoing embodiments, the computer programs may further include computer programs capable of performing other specific tasks. The data may include, in addition to data such as virtual machine data, data such as virtual machine developer information.
[0123] Furthermore, this application also provides a terminal as the aforementioned electronic device. This terminal may specifically include, but is not limited to, a smartphone, tablet computer, laptop computer, or desktop computer.
[0124] Typically, the terminal in this embodiment includes a processor and a memory.
[0125] The processor may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor can be implemented using at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor may also include a main processor and coprocessors. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0126] The memory may include one or more computer-readable storage media, which may be non-transitory. The memory may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory is used to store at least the following computer program, which, after being loaded and executed by the processor, is capable of implementing the relevant steps in the logging method executed by the terminal side as disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory may also include operating systems and data, and the storage method may be temporary or permanent storage. The operating system may include Windows, Unix, Linux, etc. The data may include, but is not limited to, application update information.
[0127] In some embodiments, the terminal may further include a display screen, an input / output interface, a communication interface, a sensor, a power supply, and a communication bus.
[0128] The following describes a readable storage medium provided in an embodiment of this application. The readable storage medium described below can be referred to in conjunction with the log recording method, apparatus and device described above.
[0129] A readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the logging method disclosed in the foregoing embodiments.
[0130] In this embodiment, the computer program executed by the processor can specifically implement the following steps: obtain the URL corresponding to the HTTP request; starting from the end of the URL, determine each item to be tested in the URL in reverse order; match the URL according to the determined order of each item to be tested; if the URL matches a preset rule, log the matching content.
[0131] In this embodiment, the computer program executed by the processor can specifically implement the following steps: from the end of the URL to the beginning, determine the characters located between adjacent separators as a test item, and / or determine the characters at a specific position as a test item, and / or determine a specific character as a test item, so as to determine the test items existing in the URL in reverse order.
[0132] In this embodiment, the computer program executed by the processor can specifically implement the following steps: the preset rules include: key information rules, key information location rules, and regular expression rules; for the URL, the key information rules are first used for matching, and if the URL matches the key information rules, the matched content is logged.
[0133] In this embodiment, the computer program executed by the processor can specifically implement the following steps: for a URL, if the URL does not match the key information rule, then the key information location rule is used for matching; if the URL matches the key information location rule, then the matched content is logged.
[0134] In this embodiment, the computer program executed by the processor can specifically implement the following steps: if the URL does not match the key information rule, then match it using the key information location rule; if the URL matches the key information location rule, then log the matched content.
[0135] In this embodiment, the computer program executed by the processor can specifically implement the following steps: if the URL does not match the key information rule, the key information location rule, or the regular expression rule, then the URL is recorded in the log.
[0136] In this embodiment, the computer program executed by the processor can specifically implement the following steps: analyze each URL recorded in the log to obtain analysis results; and complete the preset rules based on the analysis results.
[0137] In this embodiment, the computer program executed by the processor can specifically implement the following steps: matching all characters in the URL using a full character matching rule; if the matching fails, determining each test item in the URL in reverse order starting from the end of the URL; matching the URL according to the determined order of each test item; and logging the matching content if the URL matches a preset rule.
[0138] The terms “first,” “second,” “third,” “fourth,” etc., used in this application (if applicable) are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, or apparatus that includes a series of steps or units is not necessarily limited to those explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, or apparatus.
[0139] It should be noted that the use of terms such as "first" and "second" in this application is for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of those features. Furthermore, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. If the combination of technical solutions is contradictory or impossible to implement, such a combination of technical solutions should be considered non-existent and not within the scope of protection claimed in this application.
[0140] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0141] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of readable storage medium known in the art.
[0142] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A log recording method, characterized in that, include: Get the URL corresponding to the HTTP request; Starting from the end of the URL, determine each item to be tested in the URL in reverse order; The URLs are matched according to the determined order of each item to be tested. If the URL matches a preset rule, the matched content is logged. Wherein, if the URL matches a preset rule, the matching content is logged, including: The preset rules include: key information rules, key information location rules, and regular expression rules; For the URL, the key information rules are first used for matching. If the URL matches the key information rules, the matching content is logged. If the URL does not match the key information rule, then the key information location rule is used for matching; if the URL matches the key information location rule, then the matching content is logged. If the URL does not match the key information rule or the key information location rule, then the regular expression rule is used for matching; if the URL matches the regular expression rule, then the matched content is logged. If the URL does not match the key information rule, the key information location rule, or the regular expression rule, then the URL will be recorded in the log. The preset rules also include: full character matching rules; Accordingly, before determining the items to be tested in the URL in reverse order, starting from the end of the URL, the method further includes: Use full-character matching rules to match all characters in the URL; If the match fails, the following steps are performed: starting from the end of the URL, determine each item to be tested in the URL in reverse order; match the URL according to the determined order of each item to be tested; if the URL matches a preset rule, log the matching content.
2. The method according to claim 1, characterized in that, The step of determining each item to be tested in the URL in reverse order, starting from the end of the URL, includes: From the end to the beginning of the URL, characters located between adjacent separators are identified as test items, and / or characters at specific positions are identified as test items, and / or specific characters are identified as test items, in order to determine the test items existing in the URL in reverse order.
3. A log recording device, characterized in that, include: The retrieval module is used to retrieve the URL corresponding to the HTTP request; The determination module is used to determine each item to be tested in the URL in reverse order, starting from the end of the URL; The recording module is used to match the URLs according to the determined order of each item to be tested. If the URL matches a preset rule, the matching content is logged. The preset rules include: key information rules, key information location rules, and regular expression rules; Accordingly, the recording module includes: The keyword matching unit is used to first match the URL using the key information rules. If the URL matches the key information rules, the matching content is logged. A key location matching unit is used to match the key information location rule if the URL does not match the key information rule, and to log the matching content if the URL matches the key information location rule. The regular expression matching unit is used to match the URL with the key information rule and the key information location rule if the URL does not match the key information rule and the key information location rule. If the URL matches the regular expression rule, the matching content is logged. The URL recording unit is used to record the URL to the log if the URL does not match the key information rule, the key information location rule, or the regular expression rule. The preset rules also include: full character matching rules; correspondingly, they also include: The full-match module is used to match all characters in the URL using full-character matching rules before determining each test item in the URL in reverse order, starting from the end of the URL. If the match fails, the steps of determining each test item in the URL in reverse order, matching the URL according to the determined order of each test item, and logging the matching content if the URL matches a preset rule are executed.
4. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the method as described in any one of claims 1 to 2.
5. A readable storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the method as described in any one of claims 1 to 2.