CN111488230A - Method and device for modifying log output level, electronic equipment and storage medium - Google Patents

Method and device for modifying log output level, electronic equipment and storage medium Download PDF

Info

Publication number
CN111488230A
CN111488230A CN201910088227.9A CN201910088227A CN111488230A CN 111488230 A CN111488230 A CN 111488230A CN 201910088227 A CN201910088227 A CN 201910088227A CN 111488230 A CN111488230 A CN 111488230A
Authority
CN
China
Prior art keywords
log
target
output level
modification
frame
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910088227.9A
Other languages
Chinese (zh)
Inventor
李旭
余欢
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201910088227.9A priority Critical patent/CN111488230A/en
Publication of CN111488230A publication Critical patent/CN111488230A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • G06F11/0775Content or structure details of the error report, e.g. specific table structure, specific error fields
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • G06F11/0787Storage of error reports, e.g. persistent data storage, storage using memory protection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/079Root cause analysis, i.e. error or fault diagnosis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the invention discloses a method and a device for modifying log output level, electronic equipment and a storage medium. Detecting a modification indication of a log output level, and acquiring a log frame type corresponding to a currently running service; determining a target log frame according to the log frame type, and acquiring a log object corresponding to a service in the target log frame; and determining a target log object to be modified in the log objects based on the modification indication, modifying the log output level of the target log object, and sending the modified target log object to the target log frame to indicate the target log frame to modify the log output level of the log object corresponding to the target log object. By adopting the technical scheme, the embodiment of the invention overcomes the defects that the modification can not be immediately effective, the log output level of a specific log object can not be modified, and thread resources are occupied for a long time.

Description

Method and device for modifying log output level, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a method and a device for modifying log output levels, electronic equipment and a storage medium.
Background
With the development of internet technology, services provided by various online systems are more and more diversified, and meanwhile, the performance requirements of the online systems are higher and higher in order to meet the requirements of a plurality of users for using the services. The abnormal condition of the online system can be recorded through a log, the operation path of a user is tracked, and research personnel is assisted to check online problems, so that a basis is provided for the research personnel to optimize the performance of the online system.
Since the log output affects the performance of the online system, the log output level of the online system is generally set to a higher level. For example, when the system is started, a configuration center (an online warehouse for accessing system configuration files) acquires configuration files, and log output levels are set to be not less than info levels in the configuration files. However, when an abnormal situation occurs in the online system, the log output level needs to be modified to output a lower level of log data. The log output level modification processing can be performed on the configuration file in the configuration center, and the on-line system acquires the modified configuration file from the configuration center and modifies the log output level based on the configuration file.
However, in implementing the present invention, the inventors found that the log output level modification scheme in the related art has at least the following disadvantages: firstly, the configuration file cannot be immediately effective, because the on-line system needs to acquire the configuration file from the configuration center, trigger the log output level modification event, and modify the log output level based on the configuration file to enable the configuration file to be effective, the configuration file cannot be immediately effective after modification; secondly, thread resources are occupied for a long time, and the thread resources are occupied for a long time due to the fact that a thread is required to periodically inquire whether configuration files in a configuration center are modified; and thirdly, the log output level of a specific log object cannot be modified, and because the global log output level is set in the configuration file, if the log output level in the configuration file is modified, the modification takes effect, and the log output levels of all the log objects are modified.
Disclosure of Invention
Embodiments of the present invention provide a method, an apparatus, an electronic device, and a storage medium for modifying a log output level, which can overcome the defects that modifications in the related art cannot be immediately effective, the log output level of a specific log object cannot be modified, and thread resources are occupied for a long time.
In a first aspect, an embodiment of the present invention provides a method for modifying a log output level, where the method includes:
detecting a modification instruction of a log output level, and acquiring a log frame type corresponding to a currently running service;
determining a target log frame according to the log frame type, and acquiring a log object corresponding to the service in the target log frame;
and determining a target log object to be modified in the log objects based on the modification indication, modifying the log output level of the target log object, and sending the modified target log object to the target log frame to indicate the target log frame to modify the log output level of the log object corresponding to the target log object.
In a second aspect, an embodiment of the present invention further provides an apparatus for modifying a log output level, where the apparatus includes:
the frame type determining module is used for detecting the modification indication of the log output level and acquiring the log frame type corresponding to the currently running service;
the log object acquisition module is used for determining a target log frame according to the log frame type and acquiring a log object corresponding to the service in the target log frame;
and the output level modification module is used for modifying the log output level of the target log object according to the modification indication, determining the target log object to be modified in the log objects, and sending the modified target log object to the target log frame so as to indicate the target log frame to modify the log output level of the log object corresponding to the target log object.
In a third aspect, an embodiment of the present invention further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the method for modifying a log output level according to the first aspect.
In a fourth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for modifying log output level as described in the first aspect.
The embodiment of the invention responds to a modification instruction when detecting the modification instruction of the log output level to acquire the log frame type corresponding to the currently running service, determines a target log frame used by the currently running service according to the log frame type, acquires a log object corresponding to the service in the target log frame, modifies the log output level of the log object based on the modification instruction, sends the modified target log object to the target log frame to indicate the target log frame to modify the log output level of the log object corresponding to the target log object, realizes the effect of immediate effect of modification, occupies thread resources to execute the modification operation of the log output level when detecting the modification instruction, and avoids the problem of long-time occupation of the thread resources; in addition, the embodiment of the invention obtains the log object corresponding to the target log frame, is convenient for searching the target log object to be modified and can modify the log output level of the specific log object.
Drawings
FIG. 1 is a flow chart of a method for modifying log output levels provided by an embodiment of the present invention;
FIG. 2 is a flowchart of a method for determining a type of a log frame through a static binding mechanism according to an embodiment of the present invention;
FIG. 3 is a diagram of implementation classes of a log operation interface according to an embodiment of the present disclosure;
FIG. 4 is a flowchart of a method for encapsulating a log object according to an embodiment of the present invention;
FIG. 5 is a flowchart of a method for right authentication according to an embodiment of the present invention;
FIG. 6 is a flow chart of a method for modifying log output levels provided by an embodiment of the present invention;
FIG. 7 is a block diagram of an apparatus for modifying log output levels according to an embodiment of the present invention;
fig. 8 is a block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Fig. 1 is a flowchart of a method for modifying a log output level according to an embodiment of the present invention, which may be performed by an apparatus for modifying a log output level, wherein the apparatus may be implemented by software and/or hardware, and may be generally integrated in an electronic device. As shown in fig. 1, the method includes:
step 110, detecting the modification indication of the log output level, and acquiring the log frame type corresponding to the currently running service.
The log framework is a tool for recording logs generated in the service operation and outputting the logs, and the log framework type is various and is not particularly limited by the embodiment of the invention, taking a java (a door-to-object programming language) field as an example, the commonly used log framework comprises slf j (Simple L logging Facade for java, a Simple java log door), common-logging, lo4j1, log4j2, L back or jdk-logging and the like, wherein slf4j is a Simple java log surface without log implementation, and the log framework is a unified java log surface without log implementation, and provides a unified high-level interface for a set of interfaces in the subsystem, so that the subsystem can be more easily used, such as chatting, logging system or settlement, and the like, and is considered as a service after the service is started, so that the log framework is a log framework type which is used for logging and outputting the log framework type is a facility for logging java, and is a log framework type which is not used by a user, and is also designed based on a unified log-logging model of a log-logging software, namely a unified high-logging subsystem, namely a unified portal-logging software, namely a unified portal-logging portal-.
It should be noted that the log framework at least includes a log recording module and a log output module, where the log recording module is used to create and manage the diary object. The log output level is an attribute of the log object, and since the log object is used for acquiring the log and outputting the target log higher than the log output level to the log output module, the output quantity of the log recorded with the log information can be changed by modifying the log output level.
The method includes that when a program needs to output logs (namely, executes print instructions and can also be called as a print log) during the starting or running process of a service, if the program needs to output logs, a log object (such as an object of L ogger type) is acquired from a log frame, the program sends a log object acquisition request to the log frame to output the logs by using the acquired log object.
In the embodiment of the invention, the software development kit for realizing the modification function of the log output level is added to the set directory of the service to be released so as to set the application program for realizing the modification function of the log output level into the service, so that the method has the characteristics of convenience in multiplexing and zero invasion to the original code of the service, and the problem of damaging the integrity of the code in the service is avoided. Started upon publication and run in the background to prepare to respond to user requests in real time. At service startup, the program code in the software development kit that is triggered to be under the set directory is executed, i.e., the application that implements the log output level modification function is also started.
The method includes the steps of displaying a set modification key and an exit key on a set page of the service, when the set modification key is pressed, displaying the set page of the currently running service for a user to input a modification indication of the log output level, transmitting a UR L (Uniform Resource L ocoator, Uniform Resource locator) of the set page to the application program implementing the log output level modification function through a set interface, accessing the UR L to obtain the modification indication input by the user, the application program implementing the log output level modification function is obtained from the set of the currently running service, and the log output level modification class is determined according to the log output level of the currently running service, which is obtained by the set application program implementing the log output level modification function, which is obtained by the set directory service, and the log output level of the currently running service, and the log information output class obtained by the application program implementing the log output level modification function is obtained by the currently running directory service.
Step 120, determining a target log frame according to the log frame type, and acquiring a log object corresponding to the service in the target log frame.
For example, a target log frame used by a currently running service may be determined according to the log frame type. And acquiring all log objects which are already instantiated by the currently running service according to the determined target log frame and the context of the target log frame. Wherein the log context records log objects that have been initialized for the currently running service.
Fig. 2 is a flowchart of a method for determining a log frame type through a static binding mechanism according to an embodiment of the present invention. As shown in fig. 2, the method comprises the steps of:
step 1201, acquiring a modification indication of the log output level.
Step 1202, determining the type of the log frame used by the currently running service through a static binding mechanism.
Step 1203, judging whether the log frame used by the service is lo4j1 according to the type of the log frame, if so, executing step 1204, and otherwise, executing step 1205.
Step 1204, determine the target log frame used is lo4j1, execute step 1212.
And 1205, judging whether the log frame used by the service is the lo4j2 according to the type of the log frame, if so, executing 1206, and otherwise, executing 1207.
Step 1206, determining that the target log frame used by the service is lo4j2, and executing step 1212.
Step 1207, judging whether the log frame used by the service is L g-back according to the type of the log frame, if so, executing step 1208, otherwise, executing step 1209.
And step 1208, determining that the target log frame used by the service is L g-back, and executing step 1212.
Step 1209, judging whether the log frame used by the service is common-logging according to the type of the log frame, if so, executing step 1210, otherwise, executing step 1211.
Step 1210, determining that the target log frame used by the service is common-logging, and executing step 1212.
And 1211, determining that the target log frame used by the service is other log frames, and executing step 1212.
And 1212, acquiring the context of the target log frame.
Step 1213, obtaining all instantiated log objects in the currently running service based on the context of the target log frame.
Illustratively, all log objects instantiated in the current service are taken out from the context of the target log frame, the taken out log objects are packaged, and the packaged log objects are stored. The design can shield the difference of different log frames in the implementation mode, and the effect that an external system can operate log objects under different log frames through a uniform log operation interface is achieved.
The type of the log Object after being packaged is a type for showing the log Object, taking the java field as an example, the log Object is packaged into the type of the log Object for showing, which can be named L ogVo, indicating that the Object to be packaged is related to the log, and the packaged type is a Value Object (Vo) type, that is, the packaged Object packages log objects of a logger type into log objects of a L ogVo type.
Step 130, determining a target log object to be modified from the log objects based on the modification indication, modifying the log output level of the target log object, and sending the modified target log object to the target log frame to indicate the target log frame to modify the log output level of the log object corresponding to the target log object.
It should be noted that the modification indication at least includes the identification information of the target log object of the log output level to be modified and the target output level.
It should be noted that, the modification of the log object corresponding to the target log object by the target log frame refers to a log object having the same name as the target log object in the target log frame.
Illustratively, a log operation interface corresponding to the target log frame is called to analyze the modification indication, a target log object and a target output level of a log output level to be modified are determined based on the analysis result, the target log object is searched from the packaged log objects according to the identification information of the target log object, and the log output level of the target log object is updated based on the target output level.
The interface can be named L g Opera interface, so the design meets the programming requirement of the interface, and improves the compatibility and expandability of the application program corresponding to the software development kit.
It should be noted that different log frames have different operation methods, that is, different log frames have different operation methods for log objects, and therefore, a log operation interface needs to be defined for each log frame, that is, how many log frames exist at present, several log operation interfaces need to be implemented, and implementation codes of the log operation interfaces are packaged into a software development kit.
Illustratively, after determining a log frame type corresponding to a currently running service, determining a log operation interface to be loaded according to the log frame type. The log operation interface is used for receiving a log modification instruction and executing the log modification instruction. Because the name of the log object is the full-limited name of the program using the log object, the class name can be determined based on the name of the log object in the log frame, the class name is matched with the name of the interface specific implementation class, and if the class names are the same, the log operation interface to be loaded is obtained. And analyzing the modification instruction through the log operation interface corresponding to the target log frame, and determining a target log object and a target output level of the log output level to be modified based on an analysis result. The method comprises the steps of obtaining packaged log objects, screening out target log objects of the log output levels to be modified, updating the log output levels of the target log objects based on the target output levels through a log operation interface, transmitting the target log objects with modified levels to corresponding target log frames through the log operation interface, and updating the log output levels of the corresponding log objects in the target log frames based on the log output levels of the target log objects through the target log frames.
According to the technical scheme of the embodiment of the invention, when a modification instruction of the log output level is detected, the modification instruction is responded to obtain the log frame type corresponding to the currently running service, the target log frame used by the currently running service is determined according to the log frame type, the log object corresponding to the service in the target log frame is obtained, the log output level of the log object is modified based on the modification instruction, the modified target log object is sent to the target log frame to indicate the target log frame to modify the log output level of the log object corresponding to the target log object, the effect that the modification is immediately effective is realized, and when the modification instruction is detected, the thread resource is occupied to execute the modification operation of the log output level, so that the problem that the thread resource is occupied for a long time is avoided; in addition, the embodiment of the invention obtains the log object corresponding to the target log frame, is convenient for searching the target log object to be modified and can modify the log output level of the specific log object.
On the basis of the technical scheme, the storage of the encapsulated log object can be realized by adopting the following mode: and storing the packaged log object through a hash table by taking the name of the packaged log object as a key. Fig. 4 is a flowchart of a method for encapsulating a log object according to an embodiment of the present invention. As shown in fig. 4, the method includes:
and step 410, acquiring all log objects instantiated by the currently running service.
For example, the type of log object may be L ogger type.
And step 420, packaging the acquired log object.
Illustratively, a log object of L ogger type is converted to a log object of L ogVo type.
And step 430, storing the packaged log object through a hash table by taking the name of the packaged log object as a key.
Illustratively, the name of a log object of L ogVo type is used as a key, the value is a log object of L ogVo type, and the log object is stored in a hash table (i.e., HashMap) in the form of a key-value pair.
The method has the advantages that the log object after being packaged is stored in the hash table, so that the searching efficiency of the log object can be improved, the paging processing of the log object is facilitated, and the duplicate removal can be effectively realized.
On the basis of the technical scheme, after the modification indication of the log output level is detected, the prompt information for carrying out identity authentication operation is further added; acquiring identity authentication information input by a user, and judging whether the user has modification authority of a log output level according to the identity authentication information; and if so, executing the operation of acquiring the log frame type corresponding to the currently running service. Otherwise, guiding the user to input identity authentication information, verifying the identity authentication information again, and judging whether to intercept the modification instruction or not based on the verification result of the identity authentication information. Fig. 5 is a flowchart of a method for authenticating a right according to an embodiment of the present invention. As shown in fig. 5, the method includes:
and step 510, acquiring a modification instruction of the log output level sent by the user.
And step 520, outputting prompt information for performing identity authentication operation.
And 530, acquiring identity authentication information input by a user, judging whether the user has a modification authority of a log output level according to the identity authentication information, if so, executing a step 540, and otherwise, executing a step 550.
The identity authentication information may include a user name and a password. And comparing the user name and the password input by the user with the pre-stored standard authentication information, and judging whether the user has the modification authority of the log output level according to the comparison result.
And 540, acquiring the log frame type corresponding to the currently running service.
And 550, outputting prompt information for guiding the user to input the identity authentication information.
Step 560, determining whether the user passes the authentication within the set time, if so, executing step 540, otherwise, executing step 570.
And step 570, intercepting the modification indication to abandon the modification operation corresponding to the modification indication.
The method has the advantages that the authentication step is added after the modification indication of the log output level sent by the user, so that the authority control is realized, and the problem that the normal work of the system is influenced because the attribute of the log object is modified by a malicious user is prevented.
On the basis of the technical scheme, after the log output level of the target log object is modified, a result display interface is further invoked to output a modification result when a result display event is detected to be triggered. Illustratively, different command issuing channels are provided for different types of services for a user to issue modification indications of log output levels. Types include, but are not limited to, JAVAEE and AVASE. JAVAEE is mainly used for enterprise development, such as a common website. JAVASE is mainly used for desktop application development. For the service realized by JAVAEE technology, the html page is provided based on Servlet technology, and the user inputs a modification instruction for modifying the log output level of a specific log object by clicking a form of the html page (the form is mainly responsible for the data acquisition function in a webpage). The Servlet is a server-side program written in Java, and has the main function of interactively browsing and modifying data to generate dynamic Web content. For services implemented by the JAVASE technique, an operation interface is provided by way of a command line through which a user inputs a modification instruction to modify the log output level of a particular log object. Illustratively, a result display event is triggered when a completion of a modification operation to a log output level of a target log object is detected. And when detecting that the result display event is triggered, calling a result display interface to output a modification result to the html page or the command line. The method has the advantages that the modification result can be displayed conveniently and timely, so that a user can see the modification result of the log output level timely, and the problem that the modification effect can not be directly observed after modification and can be known only by looking up the service log is avoided
Fig. 6 is a flowchart of a method for modifying a log output level according to an embodiment of the present invention, where the method includes:
step 601, obtaining a modification indication of the log output level.
For example, for the service realized by JAVAEE technology, when the state of a setting modification key is detected to change, the currently running service informs an application program for realizing the log output level modification function of the existence of the log output level modification indication through a setting interface, the application program acquires a pre-stored UR L link, and acquires form data submitted by a corresponding page based on the UR L link, wherein the form data comprises relevant information of the modification indication of the log output level.
For services implemented by JAVASE technology, a modification indication of the log output level is obtained through a command line operation interface.
And step 602, outputting prompt information for performing identity authentication operation.
Step 603, obtaining identity authentication information input by a user, and judging whether the user has a modification authority of a log output level according to the identity authentication information, if so, executing step 604, otherwise, executing step 611.
Step 604, obtaining the log frame type corresponding to the currently running service.
Illustratively, upon detecting a modification indication for the log output level, a level modification thread is created to perform the operations of steps 605 through 608 based on the level modification thread.
Step 605, determining a target log frame according to the log frame type, and acquiring a log object corresponding to the service in the target log frame.
And 606, packaging the log object, taking the name of the packaged log object as a key, and storing the packaged log object through a hash table.
Step 607, invoking a log operation interface corresponding to the target log frame to analyze the modification indication, determining a target log object and a target output level of the log output level to be modified based on the analysis result, searching the target log object from the packaged log objects, and updating the log output level of the target log object based on the target output level.
It should be noted that the log output levels generally include debug, info, war, Error and total, and the order of the levels from low to high is debug < info < war < Error < total. If the log output level is debug, the logs with the info, war, Error and Fatal grades with the log output level higher than debug can also be output when responding to the log output instruction. The lowest debug level is mainly used in the development and debugging stage, and any log higher than the debug level is printed. The Info (important) is mainly used for displaying the execution state of the system after the system is on line, and the log information higher than the Info level is printed. The last three, warning, error, and critical error, should all detect an abnormal condition while the system is running. Warning indicates repairable, and the system can continue to run; log information above the war level is printed. Error indicates repairability, but it cannot be certain that the system will work properly; log information at a level higher than Error is output. Fatal (Fatal error) indicates considerable severity, and it can be certain that such an error has not been repaired and the consequences are severe if the system continues to operate.
Step 608, sending the modified target log object to the target log frame through the log operation interface, so as to instruct the target log frame to modify the log output level of the log object corresponding to the target log object according to the log output level of the target log object.
And step 609, calling a result display interface to output a modification result when the result display event is triggered.
For example, the currently running service may display the modification result through the html page, and the modification result includes, but is not limited to, the success of modification or the failure of modification, so that the user can directly know the effect of modification. As another example, the currently running service displays the modification result through the command line.
Step 610, when the resource clearing indication is detected, ending the level modification thread.
When the resource clearing indication is detected, the level modification thread is ended so as to release the thread resource occupied when the log output level is modified, and the memory space is saved.
Step 611, outputting a prompt message for guiding the user to input the identity authentication information.
Step 613, determining whether the user passes the identity authentication within the set time, if so, executing step 604, otherwise, executing step 613.
And step 612, intercepting the modification instruction to abandon the modification operation corresponding to the modification instruction.
According to the technical scheme of the embodiment of the invention, identity authentication is carried out when the modification indication of the log output level is detected, so that the problem that the normal work of the system is influenced because a malicious user modifies the attribute of the log object is prevented; responding to the modification indication to acquire the log frame type corresponding to the currently running service if the identity authentication is passed, determining a target log frame used by the currently running service according to the log frame type, acquiring a log object corresponding to the service in the target log frame, packaging the log object, to mask implementation differences between different log frames and to send modified target log objects to the target log frame based on modification indications to modify log output levels of the encapsulated log objects, to instruct the target log framework to modify the log output level of the log object corresponding to the target log object, to achieve an effect that the modification takes effect immediately, and when the modification indication is detected, occupying thread resources to execute modification operation of log output level, releasing thread resources after the modification is completed, and avoiding the problem of occupying the thread resources for a long time; in addition, the embodiment of the invention obtains the log object corresponding to the target log frame, is convenient for searching the target log object to be modified and can modify the log output level of the specific log object; because the configuration center does not need to obtain the configuration file, the problem that the server bandwidth is occupied for a long time is avoided.
In some embodiments, all log objects instantiated by the service can be stored in the configuration file, and when the log output level of a specific log object needs to be modified, the log framework acquires the modified configuration file and modifies the log output level of the log object based on the configuration file.
Fig. 7 is a block diagram of an apparatus for modifying a log output level according to an embodiment of the present invention, where the apparatus may be implemented by software and/or hardware, and is generally integrated in an electronic device, and may dynamically modify a log output level of a log object by performing a method for modifying the log output level. As shown in fig. 7, the apparatus includes:
a frame type determining module 710, configured to detect a modification indication of a log output level, and obtain a log frame type corresponding to a currently running service;
a log object obtaining module 720, configured to determine a target log frame according to the log frame type, and obtain a log object corresponding to the service in the target log frame;
an output level modification module 730, configured to modify, based on the modification indication, the log output level of the target log object determined to be modified in the log objects, and send the modified target log object to the target log frame, so as to indicate the target log frame to modify the log output level of the log object corresponding to the target log object.
The device for modifying the log output level provided by the embodiment of the invention has the advantages that when the modification indication of the log output level is detected, in response to the modification indication, to obtain the log frame type corresponding to the currently running service, and according to the log frame type, determining the target log frame used by the currently running service, and obtaining the log object corresponding to the service in the target log frame, and based on the log output level indicating modification of the log object, sending the modified target log object to the target log frame, to instruct the target log framework to modify the log output level of the log object corresponding to the target log object, to achieve an effect that the modification takes effect immediately, when the modification instruction is detected, the modification operation of the log output level is executed by occupying the thread resource, so that the problem of occupying the thread resource for a long time is avoided; in addition, the embodiment of the invention obtains the log object corresponding to the target log frame, is convenient for searching the target log object to be modified and can modify the log output level of the specific log object.
Optionally, the frame type determining module 710 is specifically configured to:
and when the modification instruction of the log output level is detected, acquiring the log frame type corresponding to the currently running service from the setting catalog of the currently running service.
Optionally, the frame type determining module 710 is specifically configured to:
and when the modification indication of the log output level is detected, determining the log frame type corresponding to the service according to the log frame implementation class loaded in the starting process of the currently running service.
Optionally, the method further includes:
the packaging module is used for packaging the log object after the log object corresponding to the service in the target log frame is obtained, and storing the packaged log object;
and, the output level modification module 730 is specifically configured to:
calling a log operation interface corresponding to the target log frame to analyze the modification indication, determining a target log object and a target output level of a log output level to be modified based on an analysis result, searching the target log object from the packaged log object, and updating the log output level of the target log object based on the target output level.
Optionally, the encapsulation module is specifically configured to:
and storing the packaged log object through a hash table by taking the name of the packaged log object as a key.
Optionally, the method further includes:
the identity authentication module is used for outputting prompt information for identity authentication operation after detecting the modification indication of the log output level; acquiring identity authentication information input by a user, and judging whether the user has modification authority of a log output level according to the identity authentication information; and if so, executing the operation of acquiring the log frame type corresponding to the currently running service.
Optionally, the method further includes:
and the result output module is used for calling the result display interface to output the modification result when the result display event is triggered.
Optionally, the method further includes:
the thread creating module is used for creating a level modification thread after a modification instruction of a log output level is detected so as to obtain a log frame type corresponding to a currently running service, determining a target log frame according to the log frame type, obtaining a log object corresponding to the service in the target log frame, determining a target log object to be modified in the log object based on the modification instruction, modifying the log output level of the target log object, and sending the modified target log object to the target log frame so as to indicate the target log frame to modify the log output level of the log object corresponding to the target log object;
and the thread ending module is used for ending the level modification thread when the resource clearing indication is detected.
The embodiment of the invention also provides electronic equipment, and the device for modifying the log output level provided by the embodiment of the invention can be integrated in the electronic equipment. Fig. 8 is a block diagram of an electronic device according to an embodiment of the present invention. The electronic device may include a memory 810, a processor 820, and a computer program stored on the memory 810 and executable on the processor 820, the processor 820 implementing a method of modifying log output levels according to an embodiment of the present invention when executing the computer program.
The electronic device provided in the embodiment of the present invention, by detecting a modification instruction of the log output level, in response to the modification instruction, to obtain the log frame type corresponding to the currently running service, and according to the log frame type, determining the target log frame used by the currently running service, and obtaining the log object corresponding to the service in the target log frame, and based on the log output level indicating modification of the log object, sending the modified target log object to the target log frame, to instruct the target log framework to modify the log output level of the log object corresponding to the target log object, to achieve an effect that the modification takes effect immediately, when the modification instruction is detected, the modification operation of the log output level is executed by occupying the thread resource, so that the problem of occupying the thread resource for a long time is avoided; in addition, the embodiment of the invention obtains the log object corresponding to the target log frame, is convenient for searching the target log object to be modified and can modify the log output level of the specific log object.
Embodiments of the present invention also provide a storage mechanism comprising computer-executable instructions, which when executed by a computer processor, perform a method of modifying log output levels, the method comprising:
detecting a modification instruction of a log output level, and acquiring a log frame type corresponding to a currently running service;
determining a target log frame according to the log frame type, and acquiring a log object corresponding to the service in the target log frame;
and determining a target log object to be modified in the log objects based on the modification indication, modifying the log output level of the target log object, and sending the modified target log object to the target log frame to indicate the target log frame to modify the log output level of the log object corresponding to the target log object.
Of course, the storage medium containing the computer-executable instructions provided by the embodiments of the present invention is not limited to the operation of modifying the log output level as described above, and may also perform related operations in the method of modifying the log output level provided by any embodiment of the present invention.
Note that storage medium-any of various types of memory devices or storage devices. The term "storage medium" is intended to include: mounting media such as CD-ROM, floppy disk, or tape devices; computer system memory or random access memory such as DRAM, DDRRAM, SRAM, EDORAM, Lanbas (Rambus) RAM, etc.; non-volatile memory such as flash memory, magnetic media (e.g., hard disk or optical storage); registers or other similar types of memory elements, etc. The storage medium may also include other types of memory or combinations thereof. In addition, the storage medium may be located in a first computer system in which the program is executed, or may be located in a different second computer system connected to the first computer system through a network (such as the internet). The second computer system may provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media that may reside in different locations, such as in different computer systems that are connected by a network. The storage medium may store program instructions (e.g., embodied as a computer program) that are executable by one or more processors.
The device, the storage medium and the electronic device for modifying the log output level provided by the above embodiments can execute the method for modifying the log output level provided by any embodiment of the present invention, and have corresponding functional modules and beneficial effects for executing the method. Technical details that are not described in detail in the above embodiments may be referred to a method of modifying a log output level provided by any embodiment of the present invention.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (11)

1. A method of modifying log output levels, comprising:
detecting a modification instruction of a log output level, and acquiring a log frame type corresponding to a currently running service;
determining a target log frame according to the log frame type, and acquiring a log object corresponding to the service in the target log frame;
and determining a target log object to be modified in the log objects based on the modification indication, modifying the log output level of the target log object, and sending the modified target log object to the target log frame to indicate the target log frame to modify the log output level of the log object corresponding to the target log object.
2. The method of claim 1, wherein detecting an indication of a modification to a log output level, obtaining a log frame type corresponding to a currently running service comprises:
and when the modification instruction of the log output level is detected, acquiring the log frame type corresponding to the currently running service from the setting catalog of the currently running service.
3. The method of claim 1, wherein detecting an indication of a modification to a log output level, obtaining a log frame type corresponding to a currently running service comprises:
and when the modification indication of the log output level is detected, determining the log frame type corresponding to the service according to the log frame implementation class loaded in the starting process of the currently running service.
4. The method of claim 1, after obtaining the log object corresponding to the service in the target log frame, further comprising:
packaging the log object, and storing the packaged log object;
and modifying the log output level of the target log object based on the modification indication and the target log object determined to be modified in the log objects, wherein the modifying comprises:
calling a log operation interface corresponding to the target log frame to analyze the modification indication, determining a target log object and a target output level of a log output level to be modified based on an analysis result, searching the target log object from the packaged log object, and updating the log output level of the target log object based on the target output level.
5. The method of claim 4, wherein storing the log object after encapsulation comprises:
and storing the packaged log object through a hash table by taking the name of the packaged log object as a key.
6. The method of claim 1, after detecting an indication of a modification to a log output level, further comprising:
outputting prompt information for identity authentication operation;
acquiring identity authentication information input by a user, and judging whether the user has modification authority of a log output level according to the identity authentication information;
and if so, executing the operation of acquiring the log frame type corresponding to the currently running service.
7. The method of claim 1, further comprising:
and when the result display event is triggered, calling a result display interface to output a modification result.
8. The method according to any one of claims 1-7, further comprising:
when a modification instruction of a log output level is detected, a level modification thread is created to obtain a log frame type corresponding to a currently running service, a target log frame is determined according to the log frame type, a log object corresponding to the service in the target log frame is obtained, a target log object to be modified is determined from the log objects based on the modification instruction, the log output level of the target log object is modified, and the modified target log object is sent to the target log frame to indicate the target log frame to modify the log output level of the log object corresponding to the target log object;
upon detecting a clear resource indication, ending the level modification thread.
9. An apparatus for modifying log output levels, comprising:
the frame type determining module is used for detecting the modification indication of the log output level and acquiring the log frame type corresponding to the currently running service;
the log object acquisition module is used for determining a target log frame according to the log frame type and acquiring a log object corresponding to the service in the target log frame;
and the output level modification module is used for modifying the log output level of the target log object according to the modification indication, determining the target log object to be modified in the log objects, and sending the modified target log object to the target log frame so as to indicate the target log frame to modify the log output level of the log object corresponding to the target log object.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of modifying log output levels as claimed in any one of claims 1 to 8 when executing the computer program.
11. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method of modifying a log output level according to any one of claims 1 to 8.
CN201910088227.9A 2019-01-29 2019-01-29 Method and device for modifying log output level, electronic equipment and storage medium Pending CN111488230A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910088227.9A CN111488230A (en) 2019-01-29 2019-01-29 Method and device for modifying log output level, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910088227.9A CN111488230A (en) 2019-01-29 2019-01-29 Method and device for modifying log output level, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111488230A true CN111488230A (en) 2020-08-04

Family

ID=71812223

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910088227.9A Pending CN111488230A (en) 2019-01-29 2019-01-29 Method and device for modifying log output level, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111488230A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111966643A (en) * 2020-09-18 2020-11-20 成都精灵云科技有限公司 System and method for dynamically adjusting log grade according to log resource

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105843822A (en) * 2015-01-16 2016-08-10 北京神州泰岳软件股份有限公司 Method and device for changing log levels
CN108897659A (en) * 2018-06-06 2018-11-27 腾讯音乐娱乐科技(深圳)有限公司 Modify journal stage method for distinguishing, device and storage medium
CN109032881A (en) * 2017-06-09 2018-12-18 武汉斗鱼网络科技有限公司 A kind of log level dynamic method of adjustment and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105843822A (en) * 2015-01-16 2016-08-10 北京神州泰岳软件股份有限公司 Method and device for changing log levels
CN109032881A (en) * 2017-06-09 2018-12-18 武汉斗鱼网络科技有限公司 A kind of log level dynamic method of adjustment and device
CN108897659A (en) * 2018-06-06 2018-11-27 腾讯音乐娱乐科技(深圳)有限公司 Modify journal stage method for distinguishing, device and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111966643A (en) * 2020-09-18 2020-11-20 成都精灵云科技有限公司 System and method for dynamically adjusting log grade according to log resource
CN111966643B (en) * 2020-09-18 2023-05-05 成都精灵云科技有限公司 System and method for dynamically adjusting log grade according to log resource

Similar Documents

Publication Publication Date Title
US7689665B2 (en) Dynamically loading scripts
US11392461B2 (en) Method and apparatus for processing information
US9129058B2 (en) Application monitoring through continuous record and replay
US9411616B2 (en) Classloader/instrumentation approach for invoking non-bound libraries
US20150378864A1 (en) Systems and methods for instrumenting applications for performance monitoring
US10587641B2 (en) Point-wise protection of application using runtime agent and dynamic security analysis
KR101691245B1 (en) System and method for web service monitoring
US20040103394A1 (en) Mechanism for testing execution of applets with plug-ins and applications
US20110258609A1 (en) Method and system for software defect reporting
US8881296B2 (en) Marking and obscuring sensitive values in traces
US20070198705A1 (en) System and method for integrating resources in a network
US10084637B2 (en) Automatic task tracking
CN108038039B (en) Method for recording log and micro-service system
CN112035354B (en) Positioning method, device and equipment of risk codes and storage medium
CN112596932A (en) Service registration and interception method and device, electronic equipment and readable storage medium
US9026612B2 (en) Generating a custom parameter rule based on a comparison of a run-time value to a request URL
CN114116078A (en) Application data processing method, device, equipment and medium based on micro front end
US10216620B2 (en) Static code testing of active code
CN114006891A (en) Information reporting method, device, equipment and storage medium
CN110764962A (en) Log processing method and device
CN111488230A (en) Method and device for modifying log output level, electronic equipment and storage medium
CN114756435A (en) Log reading method, server, computer device and storage medium
CN114510398A (en) Anomaly monitoring method, apparatus, device, system and medium
CN112506781A (en) Test monitoring method, test monitoring device, electronic device, storage medium, and program product
US11960560B1 (en) Methods for analyzing recurring accessibility issues with dynamic web site behavior and devices thereof

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination