CN114218047A - Log output method and device of Java Web application - Google Patents

Log output method and device of Java Web application Download PDF

Info

Publication number
CN114218047A
CN114218047A CN202111554755.2A CN202111554755A CN114218047A CN 114218047 A CN114218047 A CN 114218047A CN 202111554755 A CN202111554755 A CN 202111554755A CN 114218047 A CN114218047 A CN 114218047A
Authority
CN
China
Prior art keywords
program
connection point
log
java
notification
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
CN202111554755.2A
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.)
China Construction Bank Corp
Original Assignee
China Construction Bank Corp
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 China Construction Bank Corp filed Critical China Construction Bank Corp
Priority to CN202111554755.2A priority Critical patent/CN114218047A/en
Publication of CN114218047A publication Critical patent/CN114218047A/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/30Monitoring
    • G06F11/3089Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents
    • G06F11/3093Configuration details thereof, e.g. installation, enabling, spatial arrangement of the probes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3065Monitoring arrangements determined by the means or processing involved in reporting the monitored data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/32Monitoring with visual or acoustical indication of the functioning of the machine
    • G06F11/323Visualisation of programs or trace data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Quality & Reliability (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Computer Hardware Design (AREA)
  • Data Mining & Analysis (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the disclosure provides a log output method and device for Java Web application, which relate to the technical field of data analysis and comprise the following steps: monitoring a running Java program to obtain monitoring information, if the monitoring information represents a program monitoring a connection point in the Java program, acquiring a notification corresponding to the connection point from a Spring frame of a Java Web application, wherein the connection point is used for indicating the preset position of log output of the Java program, and the notification is used for indicating the time and content of the log output.

Description

Log output method and device of Java Web application
Technical Field
The embodiment of the disclosure relates to the technical field of data analysis, in particular to a log output method and device for Java Web application.
Background
In computer software applications and computer systems, log output is always a concern. The log output is helpful for the development and operation and maintenance of computer software, and the problems of finding, positioning and tracking by means of the log can not be avoided in the development and operation and maintenance.
In the prior art, a conventional and common method for outputting a log in computer software is to manually write log output logic in a specific computer program where the log needs to be output.
However, this method is very confusing and difficult to manage in large software applications, requires manual writing, is inconvenient, and has low efficiency.
Disclosure of Invention
The embodiment of the disclosure provides a method and a device for outputting a log of a Java Web application, which are used for solving the problem of low efficiency.
In a first aspect, an embodiment of the present disclosure provides a method for outputting a log of a Java Web application, including:
monitoring the running Java program to obtain monitoring information;
if the monitoring information represents a program monitoring a connection point in the Java program, acquiring a notification corresponding to the connection point from a Spring framework of a Java Web application; the connection point is used for indicating the preset position of the log output of the Java program, the notification is used for indicating the time and the content of the log output, and the connection point and the notification are arranged in a Spring framework of the Java Web application;
and generating and outputting a log according to the program of the connection point and the notification.
In some embodiments, generating and outputting a log from the program of the connection point and the notification comprises:
registering a software component model of Java of a wrapper for outputting a log in a Spring framework of the Java Web application;
acquiring a position parameter of a program of the connection point and an execution parameter of the program of the connection point based on the wrapper, and acquiring time and content indicated by the notification based on the wrapper;
and generating and outputting a log according to the position parameter, the execution parameter and the time and content indicated by the notification.
In some embodiments, monitoring the running Java program to obtain monitoring information includes:
monitoring the running Java program by adopting the wrapper to obtain a monitored program segment, and redirecting the monitored program segment to obtain the position of the monitored program segment;
and if the monitored position of the program segment is the same as the log output position of the Java program indicated by the connection point, determining that the monitoring information is information representing the program of the connection point in the Java program.
In some embodiments, generating and outputting a log from the program of the connection point and the notification comprises:
determining an output level of the log output according to the content of the log output indicated by the notification, wherein the output level comprises a compiling level, an alarm level and an error level;
determining the integrity degree of the output log according to the output level, wherein the level is in direct proportion to the integrity degree, and the output levels of the compiling level, the alarm level and the error level are sequentially increased;
and generating and outputting a log according to the program of the connection point, the integrity degree and the time indicated by the notification.
In some embodiments, generating and outputting a log according to the program of the connection point, the completeness, and the time indicated by the notification includes:
if the time indicated by the notification is the time before the program of the connection point is executed, acquiring previous running information before the program of the connection point is executed, and generating and outputting a log according to the previous running information and the integrity degree, wherein the previous running information comprises related information when the program before the program of the connection point is executed;
and if the time indicated by the notification is the time after the program of the connection point is executed, executing the program of the connection point, acquiring the subsequent operation information after the program of the connection point is executed, and generating and outputting a log according to the subsequent operation information and the integrity degree, wherein the subsequent operation information comprises the previous operation information and the related information during the execution of the program of the connection point.
In some embodiments, further comprising:
acquiring each section of code program of the Java program, and determining each section of code program of the Java program to determine a common code program of the Java program;
and acquiring the position of the public code program, and determining the position of the public code program as the log output position of the Java program.
In some embodiments, the common code program comprises: requesting one or more of a code program of a Java Web application, a code program calling an external application interface, and a code program executing a database.
In a second aspect, an embodiment of the present disclosure provides a log output apparatus for a Java Web application, including:
the monitoring unit is used for monitoring the running Java program to obtain monitoring information;
a first obtaining unit, configured to obtain, if the monitoring information represents a program that monitors a connection point in the Java program, a notification corresponding to the connection point from a Spring framework of a Java Web application; the connection point is used for indicating the preset position of the log output of the Java program, the notification is used for indicating the time and the content of the log output, and the connection point and the notification are arranged in a Spring framework of the Java Web application;
a generation unit configured to generate a log according to the program of the connection point and the notification;
and the output unit is used for outputting the log.
In some embodiments, the generating unit includes:
a registration subunit, configured to register a software component model of Java of a wrapper for outputting a log in a Spring framework of the Java Web application;
an acquisition subunit configured to acquire, based on the wrapper, a position parameter of a program of the connection point and an execution parameter of a program of the connection point, and acquire, based on the wrapper, a time and content indicated by the notification;
a first generation subunit configured to generate a log according to the location parameter, the execution parameter, and the time and content indicated by the notification.
In some embodiments, the listening unit includes:
the monitoring subunit is used for monitoring the running Java program by adopting the wrapper to obtain a monitored program segment;
the processing subunit is used for carrying out redirection processing on the monitored program segment to obtain the position of the monitored program segment;
and the first determining subunit is configured to determine, if the monitored position of the program segment is the same as the log output position of the Java program indicated by the connection point, that the monitored information is information representing a program in which the connection point in the Java program is monitored.
In some embodiments, the generating unit includes:
a second determining subunit, configured to determine an output level of the log output according to the content of the log output indicated by the notification, wherein the output level includes a compiling level, an alarm level, and an error level;
a third determining subunit, configured to determine a completeness of the output log according to the output level, where a level is proportional to the completeness, and the output levels of the compiling level, the alarm level, and the error level are sequentially incremented;
and the second generation subunit is used for generating a log according to the program of the connection point, the integrity degree and the time indicated by the notification.
In some embodiments, the second generating subunit is configured to, if the time indicated by the notification is a time before the program of the connection point is executed, obtain previous running information before the program of the connection point is executed, and generate and output a log according to the previous running information and the integrity degree, where the previous running information includes information about the program before the program of the connection point when executed;
the second generating subunit is further configured to, if the time indicated by the notification is time after the execution of the program of the connection point, execute the program of the connection point, acquire post-operation information after the execution of the program of the connection point, and generate and output a log according to the post-operation information and the integrity degree, where the post-operation information includes the prior-operation information and related information when the program of the connection point is executed.
In some embodiments, the apparatus further comprises:
a second acquisition unit configured to acquire each code program of the Java program;
a determining unit, configured to determine that each code program of the Java program determines a common code program of the Java program;
the second obtaining unit is further configured to obtain a location of the common code program;
the determination unit is further configured to determine a location of the common code program as a log output location of the Java program.
In some embodiments, the common code program comprises: requesting one or more of a code program of a Java Web application, a code program calling an external application interface, and a code program executing a database.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including: a memory, a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to perform the method of the first aspect.
In a fourth aspect, the present disclosure provides a computer-readable storage medium having stored therein computer-executable instructions for implementing the method according to the first aspect when executed by a processor.
In a fifth aspect, the disclosed embodiments provide a computer program product comprising a computer program that, when executed by a processor, implements the method according to the first aspect.
The log output method and device for the Java Web application provided by the embodiment of the disclosure comprise the following steps: monitoring a running Java program to obtain monitoring information, and if the monitoring information represents a program monitoring a connection point in the Java program, acquiring a notification corresponding to the connection point from a Spring frame of a Java Web application, wherein the connection point is used for indicating the preset position of log output of the Java program, and the notification is used for indicating the time and content of the log output, and the connection point and the notification are configured in the Spring frame of the Java Web application to generate and output the log according to the program and the notification of the connection point.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
FIG. 1 is a schematic diagram of a log output method for a Java Web application, according to one embodiment of the present disclosure;
FIG. 2 is a schematic diagram of a log output method of a Java Web application according to another embodiment of the present disclosure;
FIG. 3 is a schematic diagram of a log output method of a Java Web application according to another embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a log output device of a Java Web application according to one embodiment of the present disclosure;
FIG. 5 is a schematic diagram of a log output device of a Java Web application according to another embodiment of the present disclosure;
fig. 6 is a block diagram of an electronic device of a log output method of a Java Web application according to an embodiment of the present disclosure.
With the foregoing drawings in mind, certain embodiments of the disclosure have been shown and described in more detail below. These drawings and written description are not intended to limit the scope of the disclosed concepts in any way, but rather to illustrate the concepts of the disclosure to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
In computer software applications and computer systems, a log refers to an event record called log generated during operation of the computer software applications and computer systems, and generally, description of related operations such as date, time, user and action is recorded in the log. Therefore, the log output is helpful for the development and operation and maintenance of computer software, and the problems of finding, positioning and tracking by means of the log can not be avoided in the development and operation and maintenance.
In consideration of resource consumption and the like, based on the scene requirements of computer software applications, computer systems and the like, in a specific computer program, a worker can determine the position where the log needs to be output, and manually write the log output logic at the position where the log needs to be output in a manner of manually writing the log output logic.
However, the manual writing method has the problems of high labor cost and low efficiency, and the output of the log is easily interfered by human factors, resulting in low reliability and accuracy of log output,
in order to avoid at least one of the above technical problems, the inventors of the present disclosure have made creative efforts to obtain the inventive concept of the present disclosure: the method comprises the steps of presetting the position of log output in a Spring framework of the Java Web application, monitoring the running Java program when the Java program runs, and outputting the log when the program at the position of the log output is monitored.
The following describes the technical solutions of the present disclosure and how to solve the above technical problems in specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present disclosure will be described below with reference to the accompanying drawings.
According to an aspect of the disclosed embodiments, the disclosed embodiments provide a method for outputting a log of a Java Web application.
Referring to fig. 1, fig. 1 is a schematic diagram illustrating a log output method of a Java Web application according to an embodiment of the present disclosure.
As shown in fig. 1, the method includes:
s101: and monitoring the running Java program to obtain monitoring information.
For example, an execution subject of this embodiment is a log output device (hereinafter, simply referred to as a log output device) of a Java Web application, where the log output device may be a device supporting the Java Web application, for example, the log output device may be a server (such as a local server or a cloud server), a computer, a terminal device, a processor, a chip, and the like, and this embodiment is not limited.
S102: and if the monitoring information represents the program monitoring the connection point in the Java program, acquiring a notification corresponding to the connection point from a Spring framework of the Java Web application.
The connection point is used for indicating the preset position of the log output of the Java program, and the time and the content for indicating the log output are notified, and the connection point and the notification are configured in the Spring framework of the Java Web application.
Java Web application is a technical stack for solving the application problem in the related Web Internet field by using Java technology. The Spring framework is a lightweight control inversion (IoC) and cut-plane oriented (AOP) container framework created due to the complexity of software development.
In this embodiment, when the Java program runs, the log output apparatus listens to the running of the Java program to determine whether the currently running program of the Java program is a program of a connection point, that is, whether the position of the currently running program hits the position of log output, and if so, obtains the time and content of log output to generate and output a log subsequently, that is, generates and outputs a log in a manner of "log output position + time of log output + content of log output + listen".
S103: and generating and outputting a log according to the program and the notification of the connection point.
Based on the above analysis, an embodiment of the present disclosure provides a log output method for a Java Web application, where the method includes: monitoring a running Java program to obtain monitoring information, and if the monitoring information represents a program monitoring a connection point in the Java program, acquiring a notification corresponding to the connection point from a Spring frame of a Java Web application, wherein the connection point is used for indicating a preset position of log output of the Java program, the notification is used for indicating time and content of the log output, the connection point and the notification are configured in the Spring frame of the Java Web application, and the log is generated and output according to the program and the notification of the connection point, in the embodiment, the following steps are introduced: the method has the technical characteristics that the Java program in operation is monitored to obtain monitoring information, and when the current program in operation of the Java program is the log output position according to the monitoring information, the time and the content of log output are obtained to generate and output the log, so that the defects of low efficiency and low reliability caused by manual intervention generation and log output in the related technology are overcome, the automation of log output is realized, the effectiveness and the reliability of log output are particularly realized in huge computer application, the efficiency of log output is greatly improved, and the technical effects of manpower resources and cost are saved.
Referring to fig. 2, fig. 2 is a schematic diagram illustrating a log output method of a Java Web application according to another embodiment of the present disclosure.
As shown in fig. 2, the method includes:
s201: the software component model of Java for the wrapper of the output log is registered in the Spring framework of the Java Web application.
For example, the technical features of this embodiment that are the same as those of the above embodiment are not described in detail in this embodiment.
This step can be understood as: the log output apparatus configures a wrapper (LogWrapper) for log processing (such as log output in the present embodiment) in advance, registers the wrapper in the Spring framework to register the wrapper as a software component model (bean) of Java in the Spring framework.
S202: and monitoring the running Java program to obtain monitoring information.
For example, in conjunction with the above embodiments, the wrapper may listen to the running Java program to obtain the listening information.
In some embodiments, S202 may include the steps of:
the first step is as follows: and monitoring the running Java program by adopting the wrapper to obtain a monitored program segment, and redirecting the monitored program segment to obtain the position of the monitored program segment.
The second step is as follows: and if the monitored position of the program segment is the same as the log output position of the Java program indicated by the connection point, determining the monitored information as the information representing the program of the connection point in the monitored Java program.
Illustratively, the Java program includes multiple segments of programs, such as multiple segments of programs that constitute a Java program for implementing a business service. The wrapper may listen to each program segment and redirect each program segment to obtain the location of each program segment.
After monitoring the position of a program, the wrapper may match the position with the log output position of the Java program indicated by the connection point to determine whether the two are the same position, and if the two are the same position, the program segment is the program segment corresponding to the connection point.
In the embodiment, the wrapper monitors and determines the position of the program segment, and matches the monitored position with the log output position, so that when the monitored position is the same as the log output position, the output log is determined, and the accuracy and reliability of log output are improved.
S203: and if the monitoring information represents the program monitoring the connection point in the Java program, acquiring a notification corresponding to the connection point from a Spring framework of the Java Web application.
The connection point is used for indicating the preset position of the log output of the Java program, and the time and the content for indicating the log output are notified, and the connection point and the notification are configured in the Spring frame of the Java Web application.
S204: location parameters of a program that connects the points and execution parameters of a program that executes the connection points are acquired based on the wrapper, and the time and content indicated by the notification are acquired based on the wrapper.
S205: and generating and outputting a log according to the position parameter, the execution parameter and the time and content indicated by the notification.
For example, if the monitoring information represents a program that monitors a connection point in the Java program, that is, a program that monitors a position of the log output, the wrapper may acquire a notification corresponding to the connection point from the Spring frame, and acquire the time of the log output and the content of the log output from the notification.
Of course, the wrapper may also obtain the location parameter of the program of the connection point and the parameter related to execution (i.e., execution parameter) when the program of the connection point is executed.
Accordingly, the wrapper generates and outputs the log according to the acquired four-dimensional information (i.e., the position information about the position of the log output, the information about execution when the program of the log output is executed, the information about time of the log output, and the information about the content of the log output), so as to ensure the accuracy and reliability of the log output while automatically outputting the log.
Referring to fig. 3, fig. 3 is a schematic diagram illustrating a log output method of a Java Web application according to another embodiment of the present disclosure.
As shown in fig. 3, the method includes:
s301: and monitoring the running Java program to obtain monitoring information.
For example, the technical features of this embodiment that are the same as those of the above embodiment are not described in detail in this embodiment.
S302: and if the monitoring information represents the program monitoring the connection point in the Java program, acquiring a notification corresponding to the connection point from a Spring framework of the Java Web application.
The connection point is used for indicating the preset position of the log output of the Java program, and the time and the content for indicating the log output are notified, and the connection point and the notification are configured in the Spring framework of the Java Web application.
In some embodiments, the location of the Java program's log output may be achieved by:
the first step is as follows: and acquiring each section of code program of the Java program, and determining each section of code program of the Java program to determine the common code program of the Java program.
The second step is as follows: the location of the common code program is acquired, and the location of the common code program is determined as the log output location of the Java program.
The common code program is a code program having an association relationship with other code programs in each code program segment.
In some embodiments, the common code program includes: requesting one or more of a code program of a Java Web application, a code program calling an external application interface, and a code program executing a database.
By determining the public code program and determining the log output position of the Java program based on the public code program, the load of a developer can be greatly reduced, so that the developer developing the application logic is liberated from the attention on the operation and maintenance requirements, the labor cost and manual intervention are reduced, and the reliability and efficiency of log output are improved.
S303: an output level of the log output is determined according to the content of the log output indicated by the notification.
The output levels include, among other things, a compile (Debug) level (which may also be referred to as a Debug level), an alarm (Warn) level, and an Error (Error) level.
For example, the Spring frame includes a plurality of connection points, that is, there are positions in a Java program where a plurality of output logs are needed, a position of one output log corresponds to one connection point, and correspondingly, the Spring frame includes a plurality of notifications, one connection point corresponds to one notification, and the contents of log output indicated by the notifications corresponding to different connection points may be different, that is, output levels of log output applied by different connection points may be different.
For example, the output level of the log output of one connection point is a compile level, while the output level of the log output of another connection point is an alarm level.
S304: and determining the completeness of the output log according to the output level. Wherein the level is proportional to the degree of integrity, and the output levels of the compilation level, the alarm level, and the error level are sequentially increased.
Illustratively, the alarm level is higher than the compilation level, and accordingly, the integrity of the log corresponding to the alarm level is higher than the integrity of the log corresponding to the compilation level, i.e., the content of the log corresponding to the alarm level is relative to the content of the log corresponding to the compilation level.
Similarly, the error level is higher than the alarm level, and accordingly, the integrity of the log corresponding to the alarm level is higher than that of the log corresponding to the alarm level, that is, the content of the log corresponding to the alarm level is relative to that of the log corresponding to the alarm level.
S305: a log is generated and output based on the program of the connection point, the degree of completeness, and the time indicated by the notification.
In the embodiment, by determining the complete program and combining the complete degree to generate and output the log, the flexibility and diversity of log output can be realized, the requirements of different scenes are met, the application range of log output is widened, and the effectiveness and reliability of log output are improved.
In some embodiments, S305 may include two implementations as follows:
implementation mode 1: and if the time indicated by the notification is the time before the program of the connection point is executed, acquiring previous running information before the program of the connection point is executed, and generating and outputting a log according to the previous running information and the integrity. Wherein the pre-run information includes information about a program before the program of the connection point is executed.
Implementation mode 2: and if the time indicated by the notification is the time after the program of the connection point is executed, executing the program of the connection point, acquiring the post-operation information after the program of the connection point is executed, and generating and outputting a log according to the post-operation information and the integrity degree. Wherein the post-run information includes the pre-run information and related information when executing the program of the connection point.
For example, there may be two cases where the time indicated by the notification is the time before the program of the connection point is executed, that is, a log of the program before the program of the connection point needs to be generated; the other is that the time indicated by the notification is the time after the program of the connection point is executed, that is, a log after the program of the connection point needs to be generated for execution.
For example, the Java program includes n segments, the current program is the kth segment program, that is, the program of the connection point is the kth segment program, and if the time indicated by the notification is the time before the execution of the program of the connection point, it indicates that the log to be output may be the log generated by executing the first segment program to the kth-1 segment program, or may be the log generated by executing the kth-1 segment program; if the time indicated by the notification is the time after the execution of the program of the connection point, it is described that the log to be output may be the log generated by executing the first to k-th programs or the log generated by executing the k-th program.
Here, the notification indicating that the time is the time before the program of the connection point is executed may be referred to as a pre-notification. The notification indicating that the time is the time after the program of the connection point is executed may be referred to as a post notification.
That is, the notification may also be used to indicate a pre-notification, a post-notification (which may include post-return notifications and post-exception notifications), a post-end notification, and a surround notification.
Wherein pre-notification may be understood as outputting a log prior to execution of the program. Post notification may be understood as outputting a log after execution of a program. Post-return notification may be understood as outputting a log when the result of execution is obtained after execution of the program. Post exception notification may be understood as outputting a log if the executing program is abnormal (e.g., fails or fails to run, etc.). Surround notifications may be understood as a combination of front notifications and back notifications.
It should be noted that, in this embodiment, by generating and outputting the log at the time indicated by the notification, the log output can have strong pertinence in time, so that the output log has the technical effects of high reliability and traceability.
It should be understood that some technical features of the present embodiment may be combined with the foregoing embodiments to obtain a new embodiment, and similarly, some technical features of the foregoing embodiments may also be combined with the present embodiment to obtain a new embodiment, and the present embodiment is not limited to the combination manner.
According to another aspect of the embodiments of the present disclosure, a log output apparatus for a Java Web application is also provided.
Referring to fig. 4, fig. 4 is a schematic diagram of a log output device of a Java Web application according to an embodiment of the present disclosure.
As shown in fig. 4, the log output apparatus 400 of the Java Web application includes:
the monitoring unit 401 is configured to monitor the running Java program to obtain monitoring information.
A first obtaining unit 402, configured to, if the monitoring information represents a program that monitors a connection point in the Java program, obtain a notification corresponding to the connection point from a Spring framework of a Java Web application; the connection point is used for indicating the preset position of the log output of the Java program, the notification is used for indicating the time and the content of the log output, and the connection point and the notification are arranged in a Spring framework of the Java Web application.
A generating unit 403, configured to generate a log according to the program of the connection point and the notification.
An output unit 404, configured to output the log.
Referring to fig. 5, fig. 5 is a schematic diagram of a log output device of a Java Web application according to another embodiment of the present disclosure.
As shown in fig. 5, the log output apparatus 500 of the Java Web application includes:
and a monitoring unit 501, configured to monitor the running Java program to obtain monitoring information.
As can be seen in fig. 5, in some embodiments, the listening unit 501 includes:
the monitoring subunit 5011 is configured to monitor the running Java program by using the wrapper, so as to obtain a monitored program segment.
The processing subunit 5012 is configured to perform redirection processing on the monitored program segment, so as to obtain a position of the monitored program segment.
The first determining subunit 5013 is configured to determine, if the position of the monitored program segment is the same as the log output position of the Java program indicated by the connection point, that the monitored information is information representing a program that monitored the connection point in the Java program.
A second obtaining unit 502, configured to obtain each code segment of the Java program.
A determining unit 503, configured to determine each code program of the Java program to determine a common code program of the Java program.
The second obtaining unit 502 is further configured to obtain a location of the common code program.
The determination unit 503 is further configured to determine the location of the common code program as a log output location of the Java program.
In some embodiments, the common code program comprises: requesting one or more of a code program of a Java Web application, a code program calling an external application interface, and a code program executing a database.
A first obtaining unit 504, configured to obtain, if the monitoring information represents a program that monitors a connection point in the Java program, a notification corresponding to the connection point from a Spring framework of a Java Web application; the connection point is used for indicating the preset position of the log output of the Java program, the notification is used for indicating the time and the content of the log output, and the connection point and the notification are arranged in a Spring framework of the Java Web application.
A generating unit 505, configured to generate a log according to the program of the connection point and the notification.
As can be seen in fig. 5, in some embodiments, the generating unit 505 includes:
a registration subunit 5051, which is used for registering the Java software component model of the wrapper for the output log in the Spring framework of the Java Web application.
A acquiring sub-unit 5052 acquires location parameters of the program of the connection point and execution parameters of the program of the connection point based on the wrapper, and acquires the time and content indicated by the notification based on the wrapper.
A first generation sub-unit 5053 generates a log based on the location parameter, the execution parameter, and the time and content indicated by the notification.
As can be seen in fig. 5, in some embodiments, the generating unit 505 includes:
a second determination sub-unit 5054 determines an output level of the log output according to the content of the log output indicated by the notification, wherein the output level includes a compilation level, an alarm level, and an error level.
A third determining sub-unit 5055 determines the integrity of the output log according to the output level, wherein the level is proportional to the integrity, and the output levels of the compiling level, the alarm level, and the error level are sequentially increased.
A second generation sub-unit 5056 is used for generating a log according to the program of the connection point, the integrity level, and the time indicated by the notification.
In some embodiments, the second generation sub-unit 5056 is configured to, if the time indicated by the notification is a time before the program of the connection point is executed, acquire previous running information before the program of the connection point is executed, and generate and output a log according to the previous running information and the completeness, where the previous running information includes information about the program before the program of the connection point is executed.
The second generation subunit 5056 is further configured to, if the time indicated by the notification is time after the execution of the program of the connection point, execute the program of the connection point, acquire post-operation information after the execution of the program of the connection point, and generate and output a log according to the post-operation information and the integrity, where the post-operation information includes the pre-operation information and information related to the execution of the program of the connection point.
An output unit 506, configured to output the log.
The present disclosure also provides an electronic device and a readable storage medium according to an embodiment of the present disclosure.
According to an embodiment of the present disclosure, the present disclosure also provides a computer program product comprising: a computer program, stored in a readable storage medium, from which at least one processor of the electronic device can read the computer program, the at least one processor executing the computer program causing the electronic device to perform the solution provided by any of the embodiments described above.
As shown in fig. 6, is a block diagram of an electronic device of a method for logging output of a Java Web application according to an embodiment of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 6, the electronic apparatus includes: one or more processors 601, memory 602, and interfaces for connecting the various components, including a high-speed interface and a low-speed interface. The various components are interconnected using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions for execution within the electronic device, including instructions stored in or on the memory to display graphical information of a GUI on an external input/output apparatus (such as a display device coupled to the interface). In other embodiments, multiple processors and/or multiple buses may be used, along with multiple memories and multiple memories, as desired. Also, multiple electronic devices may be connected, with each device providing portions of the necessary operations (e.g., as a server array, a group of blade servers, or a multi-processor system). In fig. 6, one processor 601 is taken as an example.
The memory 602 is a non-transitory computer readable storage medium provided by the present disclosure. Wherein the memory stores instructions executable by at least one processor to cause the at least one processor to perform the log output method of the Java Web application provided by the present disclosure. The non-transitory computer-readable storage medium of the present disclosure stores computer instructions for causing a computer to execute a log output method of a Java Web application provided by the present disclosure.
The memory 602, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the log output method of the Java Web application in the embodiments of the present disclosure. The processor 601 executes various functional applications of the server and data processing, i.e., implements the log output method of the Java Web application in the above-described method embodiments, by running non-transitory software programs, instructions, and modules stored in the memory 602.
The memory 602 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to use of the electronic device of the log output method of the Java Web application, and the like. Further, the memory 602 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory 602 optionally includes memory located remotely from the processor 601, and these remote memories may be connected over a network to an electronic device that logs output methods for Java Web applications. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The electronic device of the log output method of the Java Web application may further include: an input device 603 and an output device 604. The processor 601, the memory 602, the input device 603 and the output device 604 may be connected by a bus or other means, and fig. 6 illustrates the connection by a bus as an example.
The input device 603 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the electronic apparatus of the log output method of the Java Web application, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, a pointing stick, one or more mouse buttons, a track ball, a joystick, or the like. The output devices 604 may include a display device, auxiliary lighting devices (e.g., LEDs), and tactile feedback devices (e.g., vibrating motors), among others. The display device may include, but is not limited to, a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display, and a plasma display. In some implementations, the display device can be a touch screen.
Various implementations of the systems and techniques described here can be realized in digital electronic circuitry, integrated circuitry, application specific ASICs (application specific integrated circuits), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
These computer programs (also known as programs, software applications, or code) include machine instructions for a programmable processor, and may be implemented using high-level procedural and/or object-oriented programming languages, and/or assembly/machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and/or device (e.g., magnetic discs, optical disks, memory, Programmable Logic Devices (PLDs)) used to provide machine instructions and/or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal used to provide machine instructions and/or data to a programmable processor.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (11)

1. A log output method of a Java Web application comprises the following steps:
monitoring the running Java program to obtain monitoring information;
if the monitoring information represents a program monitoring a connection point in the Java program, acquiring a notification corresponding to the connection point from a Spring framework of a Java Web application; the connection point is used for indicating the preset position of the log output of the Java program, the notification is used for indicating the time and the content of the log output, and the connection point and the notification are arranged in a Spring framework of the Java Web application;
and generating and outputting a log according to the program of the connection point and the notification.
2. The method of claim 1, wherein generating and outputting a log from the program of the connection point and the notification comprises:
registering a software component model of Java of a wrapper for outputting a log in a Spring framework of the Java Web application;
acquiring a position parameter of a program of the connection point and an execution parameter of the program of the connection point based on the wrapper, and acquiring time and content indicated by the notification based on the wrapper;
and generating and outputting a log according to the position parameter, the execution parameter and the time and content indicated by the notification.
3. The method of claim 2, wherein monitoring the running Java program to obtain monitoring information comprises:
monitoring the running Java program by adopting the wrapper to obtain a monitored program segment, and redirecting the monitored program segment to obtain the position of the monitored program segment;
and if the monitored position of the program segment is the same as the log output position of the Java program indicated by the connection point, determining that the monitoring information is information representing the program of the connection point in the Java program.
4. The method of claim 1, wherein generating and outputting a log from the program of the connection point and the notification comprises:
determining an output level of the log output according to the content of the log output indicated by the notification, wherein the output level comprises a compiling level, an alarm level and an error level;
determining the integrity degree of the output log according to the output level, wherein the level is in direct proportion to the integrity degree, and the output levels of the compiling level, the alarm level and the error level are sequentially increased;
and generating and outputting a log according to the program of the connection point, the integrity degree and the time indicated by the notification.
5. The method of claim 4, wherein generating and outputting a log according to the program of the connection points, the completeness, and the time indicated by the notification comprises:
if the time indicated by the notification is the time before the program of the connection point is executed, acquiring previous running information before the program of the connection point is executed, and generating and outputting a log according to the previous running information and the integrity degree, wherein the previous running information comprises related information when the program before the program of the connection point is executed;
and if the time indicated by the notification is the time after the program of the connection point is executed, executing the program of the connection point, acquiring the subsequent operation information after the program of the connection point is executed, and generating and outputting a log according to the subsequent operation information and the integrity degree, wherein the subsequent operation information comprises the previous operation information and the related information during the execution of the program of the connection point.
6. The method of any of claims 1-5, further comprising:
acquiring each section of code program of the Java program, and determining each section of code program of the Java program to determine a common code program of the Java program;
and acquiring the position of the public code program, and determining the position of the public code program as the log output position of the Java program.
7. The method of claim 6, wherein the common code program comprises: requesting one or more of a code program of a Java Web application, a code program calling an external application interface, and a code program executing a database.
8. A log output apparatus of a Java Web application, comprising:
the monitoring unit is used for monitoring the running Java program to obtain monitoring information;
a first obtaining unit, configured to obtain, if the monitoring information represents a program that monitors a connection point in the Java program, a notification corresponding to the connection point from a Spring framework of a Java Web application; the connection point is used for indicating the preset position of the log output of the Java program, the notification is used for indicating the time and the content of the log output, and the connection point and the notification are arranged in a Spring framework of the Java Web application;
a generation unit configured to generate a log according to the program of the connection point and the notification;
and the output unit is used for outputting the log.
9. An electronic device, comprising: a memory, a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to perform the method of any one of claims 1-7.
10. A computer-readable storage medium having stored therein computer-executable instructions for implementing the method of any one of claims 1-7 when executed by a processor.
11. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-7.
CN202111554755.2A 2021-12-17 2021-12-17 Log output method and device of Java Web application Pending CN114218047A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111554755.2A CN114218047A (en) 2021-12-17 2021-12-17 Log output method and device of Java Web application

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111554755.2A CN114218047A (en) 2021-12-17 2021-12-17 Log output method and device of Java Web application

Publications (1)

Publication Number Publication Date
CN114218047A true CN114218047A (en) 2022-03-22

Family

ID=80703808

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111554755.2A Pending CN114218047A (en) 2021-12-17 2021-12-17 Log output method and device of Java Web application

Country Status (1)

Country Link
CN (1) CN114218047A (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20190041192A (en) * 2017-10-12 2019-04-22 에스케이텔레콤 주식회사 Method and device for collecting log based on rule
CN109670316A (en) * 2018-12-19 2019-04-23 杭州安恒信息技术股份有限公司 A kind of leak detection method and device based on Java exception
CN111679984A (en) * 2020-06-08 2020-09-18 中国银行股份有限公司 Performance analysis method and device
CN113076296A (en) * 2021-03-30 2021-07-06 咪咕文化科技有限公司 Log generation method and device, electronic equipment and storage medium
US11089000B1 (en) * 2020-02-11 2021-08-10 International Business Machines Corporation Automated source code log generation
CN113391995A (en) * 2021-04-26 2021-09-14 北京沃东天骏信息技术有限公司 Log processing method and device, equipment and storage medium
CN113467980A (en) * 2020-03-30 2021-10-01 西安诺瓦星云科技股份有限公司 Log output method, device and system and embedded equipment
CN113595975A (en) * 2021-06-15 2021-11-02 中国科学院信息工程研究所 Detection method and device for Webshell of Java memory

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20190041192A (en) * 2017-10-12 2019-04-22 에스케이텔레콤 주식회사 Method and device for collecting log based on rule
CN109670316A (en) * 2018-12-19 2019-04-23 杭州安恒信息技术股份有限公司 A kind of leak detection method and device based on Java exception
US11089000B1 (en) * 2020-02-11 2021-08-10 International Business Machines Corporation Automated source code log generation
CN113467980A (en) * 2020-03-30 2021-10-01 西安诺瓦星云科技股份有限公司 Log output method, device and system and embedded equipment
CN111679984A (en) * 2020-06-08 2020-09-18 中国银行股份有限公司 Performance analysis method and device
CN113076296A (en) * 2021-03-30 2021-07-06 咪咕文化科技有限公司 Log generation method and device, electronic equipment and storage medium
CN113391995A (en) * 2021-04-26 2021-09-14 北京沃东天骏信息技术有限公司 Log processing method and device, equipment and storage medium
CN113595975A (en) * 2021-06-15 2021-11-02 中国科学院信息工程研究所 Detection method and device for Webshell of Java memory

Similar Documents

Publication Publication Date Title
CN111338623B (en) Method, device, medium and electronic equipment for developing user interface
US9122793B2 (en) Distributed debugging of an application in a distributed computing environment
US11424984B2 (en) Autodiscovery with dynamic configuration launching
CN113900834B (en) Data processing method, device, equipment and storage medium based on Internet of things technology
US20170249126A1 (en) Easy storm topology design and execution
CN112313627B (en) Mapping mechanism of event to serverless function workflow instance
CN113238943A (en) Method and device for continuous integration test
CN111831542A (en) API application debugging method and device and storage medium
CN110620806B (en) Information generation method and device
CN114416578A (en) Test method and device
CN111367799B (en) Method, device, medium and electronic equipment for locating source code breakdown position
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN114218047A (en) Log output method and device of Java Web application
US11689630B2 (en) Request processing method and apparatus, electronic device, and computer storage medium
US20180203790A1 (en) Detection of software errors
JP7147123B2 (en) Source channel determination method, device, equipment, program and computer storage medium
CN114020513A (en) Method and device for processing log information
CN114661274A (en) Method and device for generating intelligent contract
CN112882921B (en) Fault simulation method and device
US9195704B2 (en) Automated logging for object-oriented environments
CN111338968A (en) Project function module debugging method, device, medium and electronic equipment
CN112860447A (en) Interaction method and system between different applications
US11954506B2 (en) Inspection mechanism framework for visualizing application metrics
US10977210B2 (en) Methods for implementing an administration and testing tool
US20220374331A1 (en) Method of debugging applet, electronic device, and storage medium

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