Log configuration method and device, storage medium and electronic equipment

By scanning data packet files and updating configuration information in real time, target log files are generated, solving the problem of low efficiency in log differentiation configuration and achieving efficient and flexible log printing and operation and maintenance optimization.

CN114780367BActive Publication Date: 2026-07-24INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
INDUSTRIAL AND COMMERCIAL BANK OF CHINA
Filing Date
2022-05-06
Publication Date
2026-07-24

Smart Images

  • Figure CN114780367B_ABST
    Figure CN114780367B_ABST
Patent Text Reader

Abstract

The application discloses a log configuration method and device, a storage medium and an electronic device, relates to the technical field of data processing, and provides the following technical scheme: a target program tool is used to scan a data packet file to obtain a target object; first configuration information corresponding to the target object is determined, wherein the first configuration information at least includes an instance name corresponding to a log file, an output address corresponding to the log file, a cleaning strategy of the log file, and a target interface associated with the first configuration information; and a target log file is generated according to the first configuration information. Through the application, the problem of low efficiency of log differential configuration in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and more specifically, to a log configuration method, apparatus, storage medium, and electronic device. Background Technology

[0002] Internet applications mechanically generate a large number of logs every moment, but due to physical storage space limitations, we cannot archive all the recorded logs; we can only keep logs from the last few days or a fixed size.

[0003] As our business expands and regulatory oversight intensifies, we hope to dynamically adjust our logging methods to make logging more accurate and differentiated. For example, we may need to retain logs for certain services for longer periods, record call logs for certain customers in greater detail, or even anonymize or exclude sensitive information from logging.

[0004] Existing logging frameworks can only achieve dynamic variability at the logging level, and cannot instantiate more fine-grained logging strategies for different logging objects.

[0005] To implement more granular differentiation strategies, the industry typically chooses to add filters based on static or database configurations to the business code. While this highly coupled design achieves the functionality, it increases the system's operational costs and fails to meet flexible requirements such as real-time activation, hierarchical control, and rule approval.

[0006] There is currently no effective solution to the problem of low efficiency in log differential configuration in related technologies. Summary of the Invention

[0007] The main objective of this application is to provide a log configuration method, apparatus, storage medium, and processor to solve the problem of low efficiency in log differentiation configuration in related technologies.

[0008] To achieve the above objectives, according to one aspect of this application, a log configuration method is provided. The method includes: scanning a data packet file using a target program tool to obtain a target object; determining first configuration information corresponding to the target object, wherein the first configuration information includes at least: an instance name corresponding to the log file, an output address corresponding to the log file, a log file cleanup policy, and a target interface associated with the first configuration information; and generating a target log file based on the first configuration information.

[0009] Furthermore, by scanning the data packet file using the target program tool, the target object is obtained by: reading the file path in the data packet file; determining the file configuration name of the data packet file based on the file path; and determining the target object based on the file configuration name.

[0010] Furthermore, after determining the first configuration information corresponding to the target object, the method also includes: detecting whether the first configuration information contains the target first configuration information corresponding to the target log file, and obtaining the detection result.

[0011] Furthermore, generating the target log file based on the first configuration information includes: generating the target log file based on the target first configuration information if the detection result contains the target first configuration information; and generating the target log file based on the preset first configuration information if the detection result does not contain the target first configuration information.

[0012] Furthermore, after determining the first configuration information corresponding to the target object, the method further includes: comparing the first configuration information with the original configuration attributes of the target object to obtain a comparison result; if the comparison result indicates that the original configuration attributes have been modified, obtaining the modified configuration parameters from the first configuration information; and updating the original configuration attributes of the target object through the configuration parameters.

[0013] Furthermore, before comparing the first configuration information with the original configuration attributes of the target object, the method also includes: calling the API interface of the target interface; and using the API interface to obtain the original configuration attributes.

[0014] Furthermore, before generating the target log file based on the first configuration information, the method further includes: determining the inheritance chain corresponding to the target instance name of the target log file based on the first configuration information, wherein the inheritance chain includes at least: parent chain information corresponding to the target instance name and child chain information corresponding to the target instance name; determining whether the second configuration information determined based on the inheritance chain has generated a target log file; if the target log file has been generated based on the second configuration information, then performing the operation of outputting the target log file; if the target log file has not been generated based on the second configuration information, then generating a log printing instance corresponding to the target log file, wherein the log printing instance is used to generate the target log file.

[0015] To achieve the above objectives, according to another aspect of this application, a log configuration apparatus is provided. The apparatus includes: a scanning unit for scanning a data packet file using a target program tool to obtain a target object; a first determining unit for determining first configuration information corresponding to the target object, wherein the first configuration information includes at least: an instance name corresponding to the log file, an output address corresponding to the log file, a log file clearing policy, and a target interface associated with the first configuration information; and a first generating unit for generating a target log file based on the first configuration information.

[0016] Furthermore, the scanning unit includes: a reading module for reading the file path in the data packet file; a first determining module for determining the file configuration name of the data packet file based on the file path; and a second determining module for determining the target object based on the file configuration name.

[0017] Furthermore, the device also includes a detection unit, used to detect whether the first configuration information contains the target first configuration information corresponding to the target log file after determining the first configuration information corresponding to the target object, and to obtain a detection result.

[0018] Furthermore, the generation unit includes: a first generation module, used to generate a target log file based on the target first configuration information when the detection result contains the target first configuration information; and a second generation module, used to generate a target log file based on preset first configuration information when the detection result does not contain the target first configuration information.

[0019] Furthermore, the device further includes: a comparison unit, configured to compare the first configuration information with the original configuration attributes of the target object after determining the first configuration information corresponding to the target object, and obtain a comparison result; a first acquisition unit, configured to acquire the modified configuration parameters from the first configuration information if the comparison result indicates that the original configuration attributes have been modified; and an update unit, configured to update the original configuration attributes of the target object through the configuration parameters.

[0020] Furthermore, the device also includes: a calling unit, used to call the API interface of the target interface before comparing the first configuration information with the original configuration attributes of the target object; and a second obtaining unit, used to obtain the original configuration attributes using the API interface.

[0021] Furthermore, the device further includes: a second determining unit, configured to determine, before generating the target log file according to the first configuration information, the inheritance chain corresponding to the target instance name of the target log file, wherein the inheritance chain includes at least: parent chain information corresponding to the target instance name and child chain information corresponding to the target instance name; a judging unit, configured to judge whether the target log file has been generated according to the second configuration information determined according to the inheritance chain; an output unit, configured to perform an operation to output the target log file if the target log file has been generated according to the second configuration information; and a second generating unit, configured to generate a log printing instance corresponding to the target log file if the target log file has not been generated according to the second configuration information, wherein the log printing instance is used to generate the target log file.

[0022] This application employs the following steps: scanning a data packet file using a target program tool to obtain a target object; determining the first configuration information corresponding to the target object, wherein the first configuration information includes at least: the instance name corresponding to the log file, the output address corresponding to the log file, the log file's cleanup policy, and the target interface associated with the first configuration information; and generating a target log file based on the first configuration information. This application solves the problem of low efficiency in log differential configuration in related technologies. By generating a target log file based on the first configuration information, the efficiency of log differential configuration is improved. Attached Figure Description

[0023] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:

[0024] Figure 1 This is a flowchart of a log configuration method provided according to an embodiment of this application;

[0025] Figure 2 This is a schematic diagram illustrating the program startup of the log configuration method provided in the embodiments of this application;

[0026] Figure 3 This is a flowchart illustrating the overall operation of the log configuration method provided in the embodiments of this application.

[0027] Figure 4 This is a schematic diagram illustrating the configuration effect of the log configuration method provided in the embodiments of this application;

[0028] Figure 5 This is a schematic diagram illustrating the differences in the configuration implementation of the log configuration method provided in the embodiments of this application;

[0029] Figure 6 This is a log printing diagram illustrating the log configuration method provided in the embodiments of this application;

[0030] Figure 7 This is a code configuration example for log generation based on the log configuration method provided in the embodiments of this application. Figure 1 ;

[0031] Figure 8 This is a code configuration example for log generation based on the log configuration method provided in the embodiments of this application. Figure 2 ;

[0032] Figure 9 This is a schematic diagram of a log configuration device provided according to an embodiment of this application;

[0033] Figure 10This is a schematic diagram of the network architecture of an electronic device for configuring logs according to an embodiment of this application. Detailed Implementation

[0034] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0035] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0036] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application 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 for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0037] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.

[0038] The present invention will now be described in conjunction with preferred implementation steps. Figure 1 This is a flowchart of a log configuration method provided according to an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:

[0039] Step S101: Scan the data packet file using the target program tool to obtain the target object.

[0040] like Figure 2 As shown, when a JAVA program calls a service process, the program starts the startup process through autowiring, generates a registrar, scans the data package file through the registrar to obtain the program's configuration class, and generates an instance object corresponding to the configuration class (corresponding to the target object in this application) based on the static configuration file.

[0041] Optionally, in the log configuration method provided in this application embodiment, scanning the data packet file with a target program tool to obtain the target object includes: reading the file path in the data packet file; determining the file configuration name of the data packet file based on the file path; and determining the target object based on the file configuration name.

[0042] Specifically, after scanning the package file, the path in the package file is obtained, the configuration name of the file is determined based on the path, and then the target object is identified, which improves the accuracy of the target object search and improves the efficiency of log differential printing configuration.

[0043] Step S102: Determine the first configuration information corresponding to the target object, wherein the first configuration information includes at least: the instance name corresponding to the log file, the output address corresponding to the log file, the log file clearing strategy, and the target interface associated with the first configuration information.

[0044] Step S103: Generate the target log file based on the first configuration information.

[0045] Specifically, a fixed space is allocated in memory to store the mapping between the first configuration information and the target object corresponding to the configuration class.

[0046] Optionally, in the log configuration method provided in the embodiments of this application, after determining the first configuration information corresponding to the target object, the method further includes: detecting whether the first configuration information contains the target first configuration information corresponding to the target log file, and obtaining the detection result.

[0047] Specifically, such as Figure 3 As shown, the program responds to service calls and executes relevant business logic. Whenever log printing is required, it checks whether the first configuration information includes a personalized policy (corresponding to the target first configuration information in this application) and obtains the detection result. This application further improves the efficiency of differentiated log printing by detecting the personalized policy of the target object before log printing.

[0048] Optionally, in the log configuration method provided in this application embodiment, generating a target log file based on the first configuration information includes: generating a target log file based on the target first configuration information when the detection result contains the target first configuration information; and generating a target log file based on preset first configuration information when the detection result does not contain the target first configuration information.

[0049] Specifically, such as Figure 3As shown, if the first configuration information includes a personalized policy, the personalized configuration is read and logs are printed according to the configured personalized policy to generate a target log file; otherwise, the default rules (corresponding to the preset first configuration information in this application) are used for printing, and the relevant business logic continues to be executed. Whenever logs are printed, the above steps are repeated and the result of the service call is returned. This application further improves the efficiency of differentiated log printing by printing logs according to the detection results and the configured personalized policy.

[0050] Optionally, in the log configuration method provided in the embodiments of this application, after determining the first configuration information corresponding to the target object, the method further includes: comparing the first configuration information with the original configuration attributes of the target object to obtain a comparison result; if the comparison result indicates that the original configuration attributes have been modified, obtaining the modified configuration parameters from the first configuration information; and updating the original configuration attributes of the target object through the configuration parameters.

[0051] Specifically, before comparing the first configuration information with the original configuration attributes of the target object, the method further includes: calling the API interface of the target interface; and using the API interface to obtain the original configuration attributes.

[0052] For example, such as Figure 4 As shown, when the program starts, a listener is generated. By polling and receiving push notifications, it obtains the first configuration information modified by the user on the front end or through the API. The comparison results mentioned above are monitored. Based on the correspondence between the target object in the registry and the first configuration information, the configuration class instance (i.e., the target object) affected by the change in the first configuration information is found. The Set function of the configuration instance is called to complete the conversion of the variable configuration parameter value and update the original attribute parameter. If the configuration change involves process services, the value of the annotation will also be modified through reflection to enable or disable the service. This application further improves the efficiency of differentiated logging by updating the first configuration information in real time.

[0053] Optionally, in the log configuration method provided in this application embodiment, before generating the target log file according to the first configuration information, the method further includes: determining the inheritance chain corresponding to the target instance name corresponding to the target log file according to the first configuration information, wherein the inheritance chain includes at least: parent chain information corresponding to the target instance name and child chain information corresponding to the target instance name; determining whether the second configuration information determined according to the inheritance chain has generated the target log file; if the target log file has been generated according to the second configuration information, then performing the operation of outputting the target log file; if the target log file has not been generated according to the second configuration information, then generating a log printing instance corresponding to the target log file, wherein the log printing instance is used to generate the target log file.

[0054] Specifically, such as Figure 5 As shown, when a service call reaches the log printing stage and hits a differential configuration rule, if the current service process hits a differential strategy (i.e., a personalized strategy), it searches for the target object and its inheritance chain corresponding to the differential strategy. Based on the fully qualified class name of the configuration class, it retrieves the inheritance chain from the cache. Based on the instance variable attributes of each class in the inheritance chain, and using the default logging strategy (at least including the personalized strategy in this application), it forms differential configuration information (i.e., the second configuration information in this application). If a target log file has been generated based on the second configuration information, it executes the operation of outputting the target log file. If a target log file has not been generated based on the second configuration information, it generates a log printing instance corresponding to the target log file. Through dynamic proxy, the log output of this service call is completed by a new log printing tool instance, outputting logs that satisfy the differential strategy. This application greatly improves the configuration efficiency of differential logs by obtaining the inheritance chain of the target object.

[0055] Optionally, Figure 6 This is a log printing diagram illustrating the log configuration method provided in the embodiments of this application, as shown below. Figure 6 As shown, when the program processes service calls, it will mechanically save log information to the hard disk. If the current log file size reaches the set threshold, it will be archived, and the archived logs will be deleted periodically.

[0056] Optionally, Figure 7 This is a code configuration example for log generation based on the log configuration method provided in the embodiments of this application. Figure 1 ,like Figure 7 As shown, CustomerLogAspectDemo is an aspect implementation of a differentiation strategy. pointCut contains no business logic and is only used to describe an aspect. matchMethodHandler is the actual differentiated log output method. This method first obtains the strategy name on the service annotation, then obtains the log printing instance based on the strategy name and the service's input parameters, and finally uses the obtained instance to print the log.

[0057] Optionally, Figure 8 This is a code configuration example for log generation based on the log configuration method provided in the embodiments of this application. Figure 2 ,like Figure 8 As shown, Figure 8 This is an example of a configuration class named StrategyVIPCustom. Its member variables represent the configuration information under this strategy, including: the log printing instance, the VIP customer name, the log output address, whether the logs should be cleaned up periodically, and the interfaces associated with this strategy.

[0058] In summary, the log configuration method provided in this application involves scanning a data packet file using a target program tool to obtain a target object; determining the first configuration information corresponding to the target object, wherein the first configuration information includes at least: the instance name corresponding to the log file, the output address corresponding to the log file, the log file clearing policy, and the target interface associated with the first configuration information; and generating a target log file based on the first configuration information. This application solves the problem of low efficiency in log differential configuration in related technologies. By generating a target log file based on the first configuration information, the efficiency of log differential configuration is improved.

[0059] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0060] This application also provides a log configuration device. It should be noted that the log configuration device of this application can be used to execute the log configuration method provided in this application. The log configuration device provided in this application will be described below.

[0061] Figure 9 This is a schematic diagram of a log configuration apparatus according to an embodiment of this application. Figure 9 As shown, the device includes: a scanning unit 901, a first determining unit 902, and a first generating unit 903.

[0062] Specifically, the scanning unit 901 is used to scan the data packet file using the target program tool to obtain the target object;

[0063] The first determining unit 902 is used to determine the first configuration information corresponding to the target object, wherein the first configuration information includes at least: the instance name corresponding to the log file, the output address corresponding to the log file, the log file clearing strategy, and the target interface associated with the first configuration information;

[0064] The first generation unit 903 is used to generate a target log file based on the first configuration information.

[0065] In summary, the log configuration apparatus provided in this application embodiment uses a scanning unit 901 to scan a data packet file using a target program tool to obtain a target object; a first determining unit 902 determines the first configuration information corresponding to the target object, wherein the first configuration information includes at least: the instance name corresponding to the log file, the output address corresponding to the log file, the log file clearing strategy, and the target interface associated with the first configuration information; and a first generating unit 903 generates a target log file based on the first configuration information, thus solving the problem of low efficiency in log differential configuration in related technologies. By generating a target log file based on the first configuration information, the efficiency of log differential configuration is improved.

[0066] Optionally, in the log configuration device provided in this application embodiment, the scanning unit includes: a reading module for reading the file path in the data packet file; a first determining module for determining the file configuration name of the data packet file based on the file path; and a second determining module for determining the target object based on the file configuration name.

[0067] Optionally, in the log configuration device provided in the embodiments of this application, the device further includes: a detection unit, used to detect whether the first configuration information contains target first configuration information corresponding to the target log file after determining the first configuration information corresponding to the target object, and obtain a detection result.

[0068] Optionally, in the log configuration device provided in the embodiments of this application, the generation unit includes: a first generation module, used to generate a target log file according to the target first configuration information when the detection result contains target first configuration information; and a second generation module, used to generate a target log file according to preset first configuration information when the detection result does not contain target first configuration information.

[0069] Optionally, in the log configuration device provided in the embodiments of this application, the device further includes: a comparison unit, configured to compare the first configuration information with the original configuration attributes of the target object after determining the first configuration information corresponding to the target object, and obtain a comparison result; a first acquisition unit, configured to acquire the modified configuration parameters from the first configuration information if the comparison result indicates that the original configuration attributes have been modified; and an update unit, configured to update the original configuration attributes of the target object through the configuration parameters.

[0070] Optionally, in the log configuration device provided in the embodiments of this application, the device further includes: a calling unit, configured to call the API interface of the target interface before comparing the first configuration information with the original configuration attributes of the target object; and a second obtaining unit, configured to obtain the original configuration attributes using the API interface.

[0071] Optionally, in the log configuration apparatus provided in this application embodiment, the apparatus further includes: a second determining unit, configured to determine, before generating the target log file according to the first configuration information, the inheritance chain corresponding to the target instance name of the target log file, wherein the inheritance chain includes at least: parent chain information corresponding to the target instance name and child chain information corresponding to the target instance name; a judging unit, configured to judge whether the target log file has been generated according to the second configuration information determined according to the inheritance chain; an output unit, configured to perform an operation to output the target log file if the target log file has been generated according to the second configuration information; and a second generating unit, configured to generate a log printing instance corresponding to the target log file if the target log file has not been generated according to the second configuration information, wherein the log printing instance is used to generate the target log file.

[0072] The log configuration device includes a processor and a memory. The scanning unit 901, the first determining unit 902, the first generating unit 903, etc., are all stored in the memory as program units. The processor executes the program units stored in the memory to realize the corresponding functions.

[0073] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and logging is achieved by adjusting kernel parameters.

[0074] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0075] This invention provides a computer-readable storage medium storing a program that, when executed by a processor, implements a log configuration method.

[0076] This invention provides a processor for running programs, wherein a method for configuring execution logs during program execution is provided.

[0077] like Figure 10 As shown, this embodiment of the invention provides an electronic device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: scanning a data packet file using a target program tool to obtain a target object; determining first configuration information corresponding to the target object, wherein the first configuration information includes at least: the instance name corresponding to the log file, the output address corresponding to the log file, the log file clearing policy, and the target interface associated with the first configuration information; and generating a target log file based on the first configuration information.

[0078] When the processor executes the program, it also performs the following steps: reads the file path in the data packet file; determines the file configuration name of the data packet file based on the file path; and determines the target object based on the file configuration name.

[0079] When the processor executes the program, it also performs the following steps: after determining the first configuration information corresponding to the target object, it checks whether the first configuration information contains the target first configuration information corresponding to the target log file, and obtains the detection result.

[0080] When the processor executes the program, it also performs the following steps: if the detection result contains the target first configuration information, it generates a target log file based on the target first configuration information; if the detection result does not contain the target first configuration information, it generates a target log file based on the preset first configuration information.

[0081] When the processor executes the program, it also performs the following steps: after determining the first configuration information corresponding to the target object, it compares the first configuration information with the original configuration attributes of the target object to obtain a comparison result; if the comparison result indicates that the original configuration attributes have been modified, it obtains the modified configuration parameters from the first configuration information; and updates the original configuration attributes of the target object through the configuration parameters.

[0082] When the processor executes the program, it also performs the following steps: before comparing the first configuration information with the original configuration attributes of the target object, it calls the API interface of the target interface; and uses the API interface to obtain the original configuration attributes.

[0083] When the processor executes the program, it also performs the following steps: Before generating the target log file according to the first configuration information, it determines the inheritance chain corresponding to the target instance name of the target log file according to the first configuration information, wherein the inheritance chain includes at least: the parent chain information corresponding to the target instance name and the child chain information corresponding to the target instance name; it determines whether the second configuration information determined according to the inheritance chain has generated the target log file; if the target log file has been generated according to the second configuration information, it performs the operation of outputting the target log file; if the target log file has not been generated according to the second configuration information, it generates a log printing instance corresponding to the target log file, wherein the log printing instance is used to generate the target log file.

[0084] The devices mentioned in this article can be servers, PCs, tablets, mobile phones, etc.

[0085] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program with the following method steps: scanning a data packet file using a target program tool to obtain a target object; determining first configuration information corresponding to the target object, wherein the first configuration information includes at least: the instance name corresponding to the log file, the output address corresponding to the log file, the log file clearing strategy, and the target interface associated with the first configuration information; and generating a target log file based on the first configuration information.

[0086] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: reading the file path in the data packet file; determining the file configuration name of the data packet file based on the file path; and determining the target object based on the file configuration name.

[0087] When executed on a data processing device, it is also suitable to execute an initialization program with the following steps: after determining the first configuration information corresponding to the target object, detect whether the first configuration information contains the target first configuration information corresponding to the target log file, and obtain the detection result.

[0088] When executed on a data processing device, it is also suitable to execute an initialization program with the following steps: if the detection result contains target first configuration information, generate a target log file based on the target first configuration information; if the detection result does not contain target first configuration information, generate a target log file based on preset first configuration information.

[0089] When executed on a data processing device, it is also suitable to execute an initialization program with the following steps: after determining the first configuration information corresponding to the target object, the first configuration information is compared with the original configuration attributes of the target object to obtain a comparison result; if the comparison result indicates that the original configuration attributes have been modified, the modified configuration parameters are obtained from the first configuration information; and the original configuration attributes of the target object are updated through the configuration parameters.

[0090] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: calling the API interface of the target interface before comparing the first configuration information with the original configuration properties of the target object; and using the API interface to obtain the original configuration properties.

[0091] When executed on a data processing device, it is also suitable to execute an initialization program with the following steps: before generating the target log file according to the first configuration information, determine the inheritance chain corresponding to the target instance name of the target log file according to the first configuration information, wherein the inheritance chain includes at least: parent chain information corresponding to the target instance name and child chain information corresponding to the target instance name; determine whether the second configuration information determined according to the inheritance chain has generated the target log file; if the target log file has been generated according to the second configuration information, then perform the operation of outputting the target log file; if the target log file has not been generated according to the second configuration information, then generate a log printing instance corresponding to the target log file, wherein the log printing instance is used to generate the target log file.

[0092] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0093] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0094] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0095] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0096] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0097] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0098] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0099] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0100] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0101] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A method for configuring logs, characterized in that, include: The target program tool scans the data packet file to obtain the target object, wherein the target object is an instance object corresponding to the configuration class generated based on the static configuration file; Determine the first configuration information corresponding to the target object, wherein the first configuration information includes at least: the instance name corresponding to the log file, the output address corresponding to the log file, the clearing policy of the log file, and the target interface associated with the first configuration information; Generate the target log file based on the first configuration information; Before generating the target log file based on the first configuration information, the method further includes: The inheritance chain corresponding to the target instance name of the target log file is determined based on the first configuration information, wherein the inheritance chain includes at least: the parent chain information corresponding to the target instance name and the child chain information corresponding to the target instance name; Determine whether the target log file has been generated based on the second configuration information determined according to the inheritance chain; If the target log file has been generated according to the second configuration information, then the operation of outputting the target log file is performed; If the target log file has not been generated according to the second configuration information, a log printing instance corresponding to the target log file is generated, wherein the log printing instance is used to generate the target log file.

2. The method according to claim 1, characterized in that, By scanning the data packet file using target program tools, the target objects obtained include: Read the file path from the data packet file; The file configuration name of the data packet file is determined based on the file path; The target object is determined based on the file configuration name.

3. The method according to claim 1, characterized in that, After determining the first configuration information corresponding to the target object, the method further includes: The detection result is obtained by detecting whether the first configuration information contains the target first configuration information corresponding to the target log file.

4. The method according to claim 3, characterized in that, The generation of the target log file based on the first configuration information includes: If the detection result contains the target first configuration information, the target log file is generated based on the target first configuration information; If the detection result does not contain the target first configuration information, the target log file is generated according to the preset first configuration information.

5. The method according to claim 1, characterized in that, After determining the first configuration information corresponding to the target object, the method further includes: The first configuration information is compared with the original configuration attributes of the target object to obtain a comparison result; If the comparison result indicates that the original configuration attribute has been modified, the modified configuration parameters are obtained from the first configuration information; The original configuration attributes of the target object are updated using the configuration parameters.

6. The method according to claim 5, characterized in that, Before comparing the first configuration information with the original configuration attributes of the target object, the method further includes: Call the API interface of the target interface; The original configuration attributes are obtained using the API interface.

7. A log configuration device, characterized in that, include: The scanning unit is used to scan the data packet file using the target program tool to obtain the target object, wherein the target object is an instance object corresponding to the configuration class generated based on the static configuration file; The first determining unit is used to determine the first configuration information corresponding to the target object, wherein the first configuration information includes at least: the instance name corresponding to the log file, the output address corresponding to the log file, the clearing strategy of the log file, and the target interface associated with the first configuration information; The first generation unit is used to generate a target log file based on the first configuration information; The apparatus further includes: a second determining unit, configured to determine, before generating the target log file according to the first configuration information, the inheritance chain corresponding to the target instance name of the target log file, wherein the inheritance chain includes at least: parent chain information corresponding to the target instance name and child chain information corresponding to the target instance name; a judging unit, configured to judge whether the target log file has been generated according to the second configuration information determined according to the inheritance chain; an output unit, configured to perform an operation to output the target log file if the target log file has been generated according to the second configuration information; and a second generating unit, configured to generate a log printing instance corresponding to the target log file if the target log file has not been generated according to the second configuration information, wherein the log printing instance is used to generate the target log file.

8. A computer-readable storage medium, characterized in that, The storage medium stores a program, wherein the program executes the method described in any one of claims 1 to 6.

9. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • CN113419773A