Log context viewing method and device, electronic equipment and medium
By collecting and identifying server logs, the problem of low efficiency in log context viewing in multi-host systems is solved, and the rapid positioning and viewing of fault log context is achieved, improving the efficiency of fault analysis.
Patent Information
- Application Number
- CN202411330231.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-03-07
AI Technical Summary
When performing fault analysis in multiple host systems, log context viewing is inefficient, resulting in the fault analysis process being slowed down.
By periodically collecting logs from each server, and assigning unique self-increasing identification codes and generating identification information to each log, it is stored in the log storage engine. When receiving the user's log query information, locate the fault log and view its context based on its identification code and identification information.
By actively collecting logs and assigning unique identification codes and identification information to them, the speed of log context viewing is significantly improved and the efficiency of fault analysis is improved.
Smart Images

Figure CN119576887A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of log data processing, and in particular to a log context viewing method, device, electronic device and medium. Background Art
[0002] When locating operating faults in some systems, it is usually done based on log data. Currently, we will enter the server to view the fault point log, and check a certain number of logs before and after the fault point log to analyze the cause and effect of the fault.
[0003] Usually, when multiple hosts are involved, they are checked one by one, which results in low efficiency of log context viewing and slows down the process of fault analysis. Summary of the invention
[0004] Embodiments of the present application provide a log context viewing method, device, electronic device, and medium to improve the efficiency of log context viewing.
[0005] In a first aspect, an embodiment of the present application provides a log context viewing method, the method comprising:
[0006] Periodically collecting logs of each server, assigning a unique self-incrementing identification code to each log collected, and generating identification information of the log;
[0007] The collected logs and corresponding identification codes and identification information are stored in the log storage engine;
[0008] When receiving log query information from the user, locate the fault log according to the log query information;
[0009] The target identification code and target identification information of the fault log are obtained, and the context of the fault log is checked according to the target identification code and target identification information.
[0010] In a second aspect, an embodiment of the present application provides a log context viewing device, the device comprising:
[0011] An allocation module, used for periodically collecting logs of each server, assigning a unique self-incrementing identification code to each log collected, and generating identification information of the log;
[0012] A storage module, used to store the collected logs and corresponding identification codes and identification information in a log storage engine;
[0013] A positioning module, configured to locate the fault log according to the log query information received from the user;
[0014] The viewing module is used to obtain the target identification code and target identification information of the fault log, and view the context of the fault log according to the target identification code and target identification information.
[0015] In a third aspect, an embodiment of the present application further provides an electronic device, the electronic device comprising:
[0016] one or more processors;
[0017] a storage device for storing one or more programs,
[0018] When one or more programs are executed by one or more processors, the one or more processors implement the log context viewing method provided in any embodiment of the present application.
[0019] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, characterized in that when the program is executed by a processor, a log context viewing method as provided in any embodiment of the present application is implemented.
[0020] The technical solution of the embodiment of the present application is to periodically collect the logs of each server, assign a unique self-incrementing identification code to each log collected, and generate identification information of the log; store the collected logs and the corresponding identification code and identification information in the log storage engine; when receiving the user's log query information, locate the fault log according to the log query information; obtain the target identification code and target identification information of the fault log, and view the context of the fault log according to the target identification code and target identification information. Based on this, by actively collecting logs, assigning a unique self-incrementing identification code to the collected logs and generating identification information for the log, when viewing the log context later, the context adjacent to the fault log can be found according to the identification code, thereby improving the viewing speed of the log context. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 A flowchart of a log context viewing method provided in Example 1 of the present application;
[0022] Figure 2 A structural diagram of a log context viewing device provided in Embodiment 2 of the present application;
[0023] Figure 3 A schematic diagram of the structure of an electronic device provided in Example 3 of the present application. DETAILED DESCRIPTION
[0024] The present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for ease of description, only the parts related to the present application, rather than all structures, are shown in the accompanying drawings.
[0025] Embodiment 1
[0026] Figure 1 A flow chart of a log context viewing method provided in Example 1 of the present application is shown as follows: Figure 1 As shown, the log context viewing method provided in this embodiment can be applied to a log context viewing platform mounted on a device with data processing capabilities such as a computer, and can be used in conjunction with some work platform software to achieve a better experience. Specifically, the method may include the following steps:
[0027] Step 101: periodically collect logs of each server, assign a unique self-incrementing identification code to each collected log, and generate identification information of the log.
[0028] In this step, periodic collection is to pre-set a time length, and collect logs once every time length. Specifically, every time length, the current time can be subtracted from the time length to obtain the start time of collection, and then the logs from the start time to the current time can be collected.
[0029] In a specific example, the time length may be 1 hour, 8 hours, 12 hours or 24 hours.
[0030] In order to facilitate the subsequent search for the log context, this step assigns an identification code to each collected log. Specifically, for each log collected, a unique self-incrementing UUID is assigned to the log, and the UUID is determined as the identification code of the log; the host name field, IP field, and file path file name field corresponding to the log are obtained, and the host name field, IP field, and file path file name field are determined as the identification information of the log.
[0031] In this step, each log collected will be assigned a universally unique identifier (UUID), and the UUID will be used as the identification code of the log.
[0032] It should be noted that when allocating UUIDs, they will be automatically incremented. For example, the first log will be assigned an identification code of 00001, and the second log will be assigned an identification code that is automatically incremented by 1, that is, 00002. Automatically incrementing can ensure that the identification code of each log is unique and will not be repeated.
[0033] In addition, when collecting logs, they should be collected in the chronological order of log generation to ensure that the order of the assigned identification codes is consistent with the chronological order, so as to facilitate the subsequent correct acquisition of the context of the fault log.
[0034] In this step, the identification information of the log is mainly the relevant information of the host to which the log belongs, such as the host name field, the IP field and the file path file name field. In this embodiment, in order to facilitate the acquisition of the log context of each different host, the identification information will be generated when the log is collected. When viewing the context later, the log of the corresponding host can be selected, which is convenient for users to view the context of the fault log of each host without switching the host device, thereby improving the convenience of viewing.
[0035] Step 102: Store the collected logs and corresponding identification codes and identification information in a log storage engine.
[0036] In this step, in order to make the stored log clearer, for any collected log, the log is mapped with the corresponding identification code and identification information to obtain the mapping information of the log; and then the mapping information is stored in the log storage engine.
[0037] Specifically, the mapping information may be, but is not limited to, in a table format, with each row being one piece of mapping information. In a specific example, the mapping information may be as shown in Table 1 below:
[0038] Table 1
[0039] log Identification code Identification Information Log 1 00001 Information 1 Log 2 00002 Information 2 …… …… ……
[0040] Step 103: When receiving the log query information from the user, locate the fault log according to the log query information.
[0041] In order to facilitate the query of log context, the present embodiment may provide a viewing interface, in which a search box may be provided, and the user may enter a keyword in the search box to input log query information.
[0042] Specifically, when a keyword is input into the search box, the keyword and the search information are determined as the user's log query information. In a specific example, the keyword can be error or exception, etc., so as to locate the fault log.
[0043] That is, in this step, when the user enters a keyword in the search box, the keyword will be received as the user's log query information, so that the fault log can be located according to the log query information. When querying, the log containing the keyword can be retrieved as the fault log.
[0044] Specifically, the key words in the log query information can be used to search the logs to obtain the fault logs containing the key words. Therefore, the fault logs retrieved all contain the key words.
[0045] It should be noted that there may be multiple fault logs retrieved. In this embodiment, the multiple fault logs can be directly displayed in the viewing interface to facilitate user selection.
[0046] Step 104: Obtain the target identification code and target identification information of the fault log, and check the context of the fault log according to the target identification code and target identification information.
[0047] Based on the foundation laid by the previous steps, in this step, you can first obtain the occurrence time of the fault log, and determine the time period to be viewed based on the occurrence time; then search for all logs belonging to the time period to be viewed based on the host name field, IP field, and file path file name field in the target identification information; then search from all logs for the logs corresponding to the ascending target number and descending target number of the target identification code to obtain the context of the fault log.
[0048] It should be noted that since the time interval between the occurrence time of the fault cause and the generation time of the fault log is usually not long, you can use the occurrence time of the fault log as a benchmark to determine a time period, namely the time period to be viewed, and only obtain the logs in the time period to be viewed.
[0049] The aforementioned time interval may be set based on past historical experience, for example, 4 hours, 6 hours, etc. Then the corresponding time period to be checked may be 4 hours or 6 hours before and after the occurrence time of the fault log.
[0050] After determining the time period to be viewed, all logs within the time period to be viewed can be searched based on the host name field, IP field, and file path file name field in the target identification information. Since hosts are usually independent, when searching, only the logs of the host to which the fault log belongs can be searched.
[0051] The host name field, IP field and file path file name field in the aforementioned target identification information can help limit the search scope to the host to which the fault log belongs, among which the host name field is mainly used. When searching, the host name field, IP field and file path file name field can be searched in an "or" logical relationship to find all logs related to the fault log.
[0052] Since an identification code is assigned to each log during log collection, when viewing the context from all the logs searched above, you can first sort all the logs according to the identification code, and then search for the logs corresponding to the ascending target number and descending target number of the target identification code of the fault log.
[0053] The ascending target number is the target number of items whose identification codes are gradually greater than the target identification code, and the descending target number is the target number of items whose identification codes are gradually less than the target identification code. The target number can be selected by the user, such as 100 items, 500 items, etc.
[0054] In addition, the logs corresponding to the ascending target number and the descending target number of the target identification code are the context of the fault log, and these logs can be directly displayed on the viewing interface for direct viewing by the user.
[0055] In this embodiment, logs of each server are collected periodically, and each time a log is collected, a unique self-incrementing identification code is assigned to the log, as well as identification information of the generated log; the collected logs and the corresponding identification code and identification information are stored in the log storage engine; when the user's log query information is received, the fault log is located according to the log query information; the target identification code and target identification information of the fault log are obtained, and the context of the fault log is viewed according to the target identification code and target identification information. Based on this, by actively collecting logs and assigning a unique self-incrementing identification code to the collected logs and the identification information of the generated log, when the log context is subsequently viewed, the context adjacent to the fault log can be found according to the identification code, thereby improving the viewing speed of the log context.
[0056] Embodiment 2
[0057] Figure 2 This is a structural diagram of a log context viewing device provided in Example 2 of the present application. The log context viewing device provided in the embodiment of the present application can execute the log context viewing method provided in any embodiment of the present application, and has the corresponding functional modules and beneficial effects of the execution method. The device can be implemented in software and / or hardware, such as Figure 2 As shown, the log context viewing device specifically includes: an allocation module 201 , a storage module 202 , a positioning module 203 , and a viewing module 204 .
[0058] The allocation module is used to periodically collect logs from each server, and each time a log is collected, a unique self-incrementing identification code is allocated to the log, as well as identification information of the generated log;
[0059] A storage module, used to store the collected logs and corresponding identification codes and identification information in a log storage engine;
[0060] A positioning module is used to locate the fault log according to the log query information when receiving the log query information from the user;
[0061] The viewing module is used to obtain the target identification code and target identification information of the fault log, and view the context of the fault log according to the target identification code and target identification information.
[0062] In this embodiment, logs of each server are collected periodically, and each time a log is collected, a unique self-incrementing identification code is assigned to the log, as well as identification information of the generated log; the collected logs and the corresponding identification code and identification information are stored in the log storage engine; when the user's log query information is received, the fault log is located according to the log query information; the target identification code and target identification information of the fault log are obtained, and the context of the fault log is viewed according to the target identification code and target identification information. Based on this, by actively collecting logs and assigning a unique self-incrementing identification code to the collected logs and the identification information of the generated log, when the log context is subsequently viewed, the context adjacent to the fault log can be found according to the identification code, thereby improving the viewing speed of the log context.
[0063] Furthermore, the allocation module is specifically used for:
[0064] Each time a log is collected, a unique self-incrementing UUID is assigned to the log, and the UUID is determined as the identification code of the log;
[0065] The host name field, IP field, and file path file name field corresponding to the log are obtained, and the host name field, IP field, and file path file name field are determined as identification information of the log.
[0066] Furthermore, the storage module is specifically used for:
[0067] For any collected log, map the log with the corresponding identification code and identification information to obtain the mapping information of the log;
[0068] Store the mapping information in the log storage engine.
[0069] Furthermore, the device is also specifically used for:
[0070] When a keyword is detected to be input into the search box, the keyword and search information are determined as the user's log query information.
[0071] Furthermore, the positioning module is specifically used for:
[0072] The logs are searched using the keywords in the log query information to obtain the fault logs containing the keywords.
[0073] Furthermore, the identification information includes a host name field, an IP field, and a file path file name field. The viewing module is specifically used for:
[0074] Obtain the occurrence time of the fault log and determine the time period to be viewed based on the occurrence time;
[0075] Search for all logs within the time period to be viewed based on the host name field, IP field, and file path file name field in the target identification information;
[0076] Search all logs for the logs corresponding to the target number of ascending and descending target numbers of target identification codes, and obtain the context of the fault log.
[0077] Embodiment 3
[0078] Figure 3 A schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present application is shown in FIG. Figure 3 As shown, the electronic device includes a processor 310, a memory 320, an input device 330 and an output device 340; the number of the processor 310 in the electronic device can be one or more. Figure 3 A processor 310 is taken as an example; the processor 310, the memory 320, the input device 330 and the output device 340 in the electronic device can be connected via a bus or other means. Figure 3 The example of connecting through bus is taken in the following.
[0079] The memory 320, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the log context viewing method in the embodiment of the present invention. The processor 310 executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory 320, that is, implements the above-mentioned log context viewing method:
[0080] Periodically collect logs from each server, assign a unique self-incrementing identification code to each log, and generate identification information for the log;
[0081] The collected logs and corresponding identification codes and identification information are stored in the log storage engine;
[0082] When receiving the log query information from the user, locate the fault log according to the log query information;
[0083] The target identification code and target identification information of the fault log are obtained, and the context of the fault log is viewed according to the target identification code and the target identification information.
[0084] In this embodiment, logs of each server are collected periodically, and each time a log is collected, a unique self-incrementing identification code is assigned to the log, as well as identification information of the generated log; the collected logs and the corresponding identification code and identification information are stored in the log storage engine; when the user's log query information is received, the fault log is located according to the log query information; the target identification code and target identification information of the fault log are obtained, and the context of the fault log is viewed according to the target identification code and target identification information. Based on this, by actively collecting logs and assigning a unique self-incrementing identification code to the collected logs and the identification information of the generated log, when the log context is subsequently viewed, the context adjacent to the fault log can be found according to the identification code, thereby improving the viewing speed of the log context.
[0085] Furthermore, each time a log is collected, a unique self-incrementing identification code is assigned to the log, and identification information of the generated log includes:
[0086] Each time a log is collected, a unique self-incrementing UUID is assigned to the log, and the UUID is determined as the identification code of the log;
[0087] The host name field, IP field, and file path file name field corresponding to the log are obtained, and the host name field, IP field, and file path file name field are determined as identification information of the log.
[0088] Furthermore, the collected logs and the corresponding identification codes and identification information are stored in the log storage engine, including:
[0089] For any collected log, map the log with the corresponding identification code and identification information to obtain the mapping information of the log;
[0090] Store the mapping information in the log storage engine.
[0091] Furthermore, the method also includes:
[0092] When a keyword is detected to be input into the search box, the keyword and search information are determined as the user's log query information.
[0093] Furthermore, the fault log is located based on the log query information, including:
[0094] The logs are searched using the keywords in the log query information to obtain the fault logs containing the keywords.
[0095] Furthermore, the identification information includes a host name field, an IP field, and a file path file name field. The context of the fault log is viewed according to the target identification code and the target identification information, including:
[0096] Obtain the occurrence time of the fault log and determine the time period to be viewed based on the occurrence time;
[0097] Search for all logs within the time period to be viewed based on the host name field, IP field, and file path file name field in the target identification information;
[0098] Search all logs for the logs corresponding to the target number of ascending and descending target numbers of target identification codes, and obtain the context of the fault log.
[0099] The memory 320 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 320 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 320 may further include a memory remotely arranged relative to the processor 310, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0100] Embodiment 4
[0101] Embodiment 4 of the present application further provides a storage medium including computer executable instructions, which are used to execute a log context viewing method when executed by a computer processor, the method comprising:
[0102] Periodically collect logs from each server, assign a unique self-incrementing identification code to each log, and generate identification information for the log;
[0103] The collected logs and corresponding identification codes and identification information are stored in the log storage engine;
[0104] When receiving the log query information from the user, locate the fault log according to the log query information;
[0105] The target identification code and target identification information of the fault log are obtained, and the context of the fault log is viewed according to the target identification code and the target identification information.
[0106] In this embodiment, logs of each server are collected periodically, and each time a log is collected, a unique self-incrementing identification code is assigned to the log, as well as identification information of the generated log; the collected logs and the corresponding identification code and identification information are stored in the log storage engine; when the user's log query information is received, the fault log is located according to the log query information; the target identification code and target identification information of the fault log are obtained, and the context of the fault log is viewed according to the target identification code and target identification information. Based on this, by actively collecting logs and assigning a unique self-incrementing identification code to the collected logs and the identification information of the generated log, when the log context is subsequently viewed, the context adjacent to the fault log can be found according to the identification code, thereby improving the viewing speed of the log context.
[0107] Furthermore, each time a log is collected, a unique self-incrementing identification code is assigned to the log, and identification information of the generated log includes:
[0108] Each time a log is collected, a unique self-incrementing UUID is assigned to the log, and the UUID is determined as the identification code of the log;
[0109] The host name field, IP field, and file path file name field corresponding to the log are obtained, and the host name field, IP field, and file path file name field are determined as identification information of the log.
[0110] Furthermore, the collected logs and the corresponding identification codes and identification information are stored in the log storage engine, including:
[0111] For any collected log, map the log with the corresponding identification code and identification information to obtain the mapping information of the log;
[0112] Store the mapping information in the log storage engine.
[0113] Furthermore, the method also includes:
[0114] When a keyword is detected to be input into the search box, the keyword and search information are determined as the user's log query information.
[0115] Furthermore, the fault log is located based on the log query information, including:
[0116] The logs are searched using the keywords in the log query information to obtain the fault logs containing the keywords.
[0117] Furthermore, the identification information includes a host name field, an IP field, and a file path file name field. The context of the fault log is viewed according to the target identification code and the target identification information, including:
[0118] Obtain the occurrence time of the fault log and determine the time period to be viewed based on the occurrence time;
[0119] Search for all logs within the time period to be viewed based on the host name field, IP field, and file path file name field in the target identification information;
[0120] Search all logs for the logs corresponding to the target number of ascending and descending target numbers of target identification codes, and obtain the context of the fault log.
[0121] Of course, the storage medium containing computer executable instructions provided in the embodiment of the present application, whose computer executable instructions are not limited to the above method operations, can also execute related operations in the log context viewing method provided in any embodiment of the present application.
[0122] Through the above description of the implementation method, the technicians in the relevant field can clearly understand that the present application can be implemented with the help of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application can be essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
[0123] It is worth noting that in the embodiment of the above-mentioned search device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application.
[0124] Note that the above are only preferred embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present application is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.
Claims
1. A log context viewing method, characterized in that: The method comprises: Periodically collecting logs of each server, assigning a unique self-incrementing identification code to each log collected, and generating identification information of the log; The collected logs and corresponding identification codes and identification information are stored in the log storage engine; When receiving the log query information from the user, locate the fault log according to the log query information; The target identification code and target identification information of the fault log are obtained, and the context of the fault log is checked according to the target identification code and target identification information.
2. The method according to claim 1, characterized in that Each time a log is collected, a unique self-incrementing identification code is assigned to the log, and identification information of the log is generated, including: Each time a log is collected, a unique self-incrementing UUID is assigned to the log, and the UUID is determined as an identification code of the log; The host name field, IP field and file path file name field corresponding to the log are obtained, and the host name field, IP field and file path file name field are determined as identification information of the log.
3. The method according to claim 1, characterized in that The step of storing the collected logs and the corresponding identification codes and identification information in the log storage engine includes: For any collected log, mapping the log with the corresponding identification code and identification information to obtain mapping information of the log; The mapping information is stored in a log storage engine.
4. The method according to claim 1, characterized in that: The method further comprises: When it is detected that a keyword is input into the search box, the keyword and the search information are determined as the log query information of the user.
5. The method according to claim 4, characterized in that The locating the fault log according to the log query information includes: The logs are searched using the keywords in the log query information to obtain the fault logs containing the keywords.
6. The method according to claim 1, characterized in that The identification information includes a host name field, an IP field, and a file path file name field, and the checking the context of the fault log according to the target identification code and the target identification information includes: Obtaining the occurrence time of the fault log, and determining a time period to be viewed based on the occurrence time; Searching for all logs within the time period to be viewed according to the host name field, IP field, and file path file name field in the target identification information; The logs corresponding to the target number of ascending and descending target number of the target identification code are searched from all the logs to obtain the context of the fault log.
7. A log context viewing device, characterized in that: The device comprises: An allocation module, used for periodically collecting logs of each server, assigning a unique self-incrementing identification code to each log collected, and generating identification information of the log; A storage module, used to store the collected logs and corresponding identification codes and identification information in a log storage engine; A positioning module, configured to locate the fault log according to the log query information received from the user; The viewing module is used to obtain the target identification code and target identification information of the fault log, and view the context of the fault log according to the target identification code and target identification information.
8. The device according to claim 7, characterized in that The allocation module is specifically used for: Each time a log is collected, a unique self-incrementing UUID is assigned to the log, and the UUID is determined as an identification code of the log; The host name field, IP field and file path file name field corresponding to the log are obtained, and the host name field, IP field and file path file name field are determined as identification information of the log.
9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the log context viewing method as described in any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the log context viewing method as described in any one of claims 1 to 6 is implemented.