CN112699015B - Log output method, device, server and computer readable storage medium - Google Patents

Log output method, device, server and computer readable storage medium Download PDF

Info

Publication number
CN112699015B
CN112699015B CN202011607768.7A CN202011607768A CN112699015B CN 112699015 B CN112699015 B CN 112699015B CN 202011607768 A CN202011607768 A CN 202011607768A CN 112699015 B CN112699015 B CN 112699015B
Authority
CN
China
Prior art keywords
log
output
time
preset
logs
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.)
Active
Application number
CN202011607768.7A
Other languages
Chinese (zh)
Other versions
CN112699015A (en
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 Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet 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 Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202011607768.7A priority Critical patent/CN112699015B/en
Publication of CN112699015A publication Critical patent/CN112699015A/en
Application granted granted Critical
Publication of CN112699015B publication Critical patent/CN112699015B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present disclosure relates to a log output method, apparatus, server, and computer-readable storage medium. The log output method comprises the following steps: acquiring a first timestamp of log reaching an output interface; determining a time difference between a first time stamp and a second time stamp, wherein the second time stamp is the time stamp of the last log output by the output interface; in response to detecting that the time difference is greater than a preset time interval, outputting log information, wherein the log information at least comprises logs; in response to detecting that the time difference is less than or equal to the preset time interval, no log is output. By adopting the log output method, the log output device, the server and the computer readable storage medium, the problem that low memory consumption and strong self-adaptability cannot be achieved when a large amount of logs are output can be solved.

Description

Log output method, device, server and computer readable storage medium
Technical Field
The disclosure relates to the technical field of communication, and in particular relates to a log output method, a log output device, a server and a computer readable storage medium.
Background
In the process of software development and debugging, a large number of logs are often required to be output in order for a developer to test and locate problems. A large amount of log output consumes a large amount of memory resources and transmission resources.
Currently, in the related art, log output generally limits the amount of log output in the following manner: the output ratio of the log is set or a token bucket is used. However, when the output of the log is too large or too small, the actually output log also fluctuates, so that stable output of the log cannot be ensured, and the adaptability is not strong; the token bucket scheme consumes a significant amount of resources. That is, in the current log sampling scheme, low memory consumption and strong self-adaptability cannot be achieved.
Disclosure of Invention
The disclosure provides a log output method, a log output device, a server and a computer readable storage medium, which at least solve the problem that the low memory consumption and the strong self-adaptability cannot be achieved when a large amount of logs are output in the related art.
The technical scheme of the present disclosure is as follows:
according to a first aspect of an embodiment of the present disclosure, there is provided a log output method, including:
acquiring a first timestamp of log reaching an output interface; determining a time difference between a first time stamp and a second time stamp, wherein the second time stamp is the time stamp of the last log output by the output interface; in response to detecting that the time difference is greater than a preset time interval, outputting log information, wherein the log information at least comprises logs; in response to detecting that the time difference is less than or equal to the preset time interval, no log is output.
Optionally, after responding to detecting that the time difference is greater than the preset time interval, the method further comprises:
the second timestamp is updated to the first timestamp.
Alternatively, in response to detecting that the time difference is less than or equal to a preset time interval, a count of logs that are not output is accumulated.
Optionally, the log information further includes: a count of logs that are not output for a target period of time;
wherein the target time period is a time period from the second time stamp to the first time stamp.
Optionally, after responding to detecting that the time difference is greater than the preset time interval, the method further comprises:
resetting the count of the log that is not output to an initial value; the initial value is used to indicate the number of logs that are not output that are set in advance.
Alternatively, in response to detecting that the time difference is less than or equal to the preset time interval, a count of logs that are not output is updated.
Optionally, before determining the time difference between the second timestamp and the first timestamp, the method further comprises:
extracting characteristic parameters related to preset information from the log content under the condition that the log content is detected to comprise the preset information;
determining the characteristic parameters as log types;
and matching the second timestamp corresponding to the log type of the log according to a preset corresponding relation between the log type and the second timestamp.
According to a second aspect of the embodiments of the present disclosure, there is provided a log output device including:
an acquisition module configured to perform acquiring a first timestamp of the log reaching the output interface; a first determining module configured to perform determining a time difference between a first time stamp and a second time stamp, the second time stamp being a time stamp of a last output log of the output interface; an output module configured to perform outputting log information in response to detecting that the time difference is greater than a preset time interval, the log information including at least a log; and a non-output module configured to perform non-output of the log in response to detecting that the time difference is less than or equal to the preset time interval.
Optionally, the apparatus further comprises:
the first updating module is configured to perform updating of the second timestamp to the first timestamp.
Optionally, the apparatus further comprises:
and an accumulation module configured to perform accumulation of counts of logs not output in response to detecting that the time difference is less than or equal to a preset time interval.
Optionally, the log information further includes: a count of logs that are not output for a target period of time; wherein the target time period is a time period from the second time stamp to the first time stamp.
Optionally, the apparatus further comprises:
a reset module configured to perform resetting of a count of logs that are not output to an initial value; the initial value is used to indicate the number of logs that are not output that are set in advance.
Optionally, the apparatus further comprises:
and a second updating module configured to perform updating of the count of logs that are not output in response to detecting that the time difference is less than or equal to the preset time interval.
Optionally, the apparatus further comprises:
an extraction module configured to perform, in the event that it is detected that the log content includes preset information, extraction of a characteristic parameter related to the preset information in the log content;
a second determination module configured to perform determining the characteristic parameter as a log type;
and the matching module is configured to perform matching of the second timestamp corresponding to the log type of the log according to a preset corresponding relation between the log type and the second timestamp.
According to a third aspect of embodiments of the present disclosure, there is provided a server comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute instructions to implement the log output method as described in the first aspect.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer readable storage medium, which when executed by a processor of a server, enables the server to perform the log output method as described in the first aspect.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product, which when executed by a processor of a server, enables the server to perform the log output method as described in the first aspect.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
in an embodiment of the disclosure, outputting log information including at least a log by determining a time difference between a second time stamp of a last output log and a first time stamp of the log reaching an output interface, in response to detecting that the time difference is greater than a preset time interval; in response to detecting that the time difference is less than or equal to the preset time interval, no log is output. Therefore, no matter how many logs are to be output, a fixed number of logs can be output in a preset time. Therefore, in the log output process of continuously changing the log quantity to be output, the constant-speed stable output of the log is ensured, so that the strong adaptability of log output is ensured, whether the log is output or not is judged through the time difference between the time stamps, and the memory can be saved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure and do not constitute an undue limitation on the disclosure.
FIG. 1 is a schematic diagram of a log output method, apparatus, electronic device, and computer-readable storage medium application environment, according to an example embodiment.
Fig. 2 is a flow chart illustrating a log output method according to an example embodiment.
FIG. 3 is a flowchart illustrating a method of implementing log output according to an example embodiment.
Fig. 4 is a block diagram illustrating a log output device according to an example embodiment.
Fig. 5 is a block diagram of a server, according to an example embodiment.
FIG. 6 is a block diagram illustrating an apparatus for data processing according to an example embodiment.
Detailed Description
In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the foregoing figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the disclosure described herein may be capable of operation in sequences other than those illustrated or described herein. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the accompanying claims.
In the process of developing and debugging an application program, a developer records the occurrence of an event in the process of developing and debugging through a log in order to facilitate later debugging. Since the log records some state information, in particular error information, of the application during the running process. The software error position can be tracked and positioned quickly by means of the log, and the software error position is convenient to repair. Thus, journaling is particularly important for software developers to maintain software. The output log can assist the developer in analyzing the cause of the problem, the test result, and the like.
The log output consumes a large amount of storage resources, and if log acquisition is required later, network resources, transmission channels, centralized storage and other transmission resources are also required to be occupied. Even when the log output is too large, even the normal operation of the software itself is affected. Therefore, a plurality of sampling processes are often carried out at the entry of the log output, the output quantity of the log is as much as possible, and various problems caused by a large amount of log output are avoided.
Each application program interface has an access upper limit, and when the access frequency or the concurrency exceeds the bearing range, the usability of the interface is ensured by limiting the current, so as to prevent the system paralysis caused by the excessive pressure of unexpected requests to the system.
Currently, in the related art, log output generally limits the amount of log output in the following manner:
first, the output of the log may be limited by setting an output ratio at the log output interface. For example, 100 logs need to be output within a preset time, if the output proportion is 10%, 10 logs can be output, and the remaining 90 logs will not be output.
Because different log output orders are very different, the fixed output proportion is not adaptive, and the output log quantity is still very large when a large amount of logs are output; when the log quantity is very small, the same sampling rate may cause that the key log cannot be output for a long time, i.e. stable output of the log cannot be ensured.
Second, the output of the log may be limited by the token bucket. Given the query rate per second (QPS, queries per second) of log output, when below a predetermined QPS, the log exceeding the QPS is discarded in its entirety, according to the mechanism of the token bucket, when the QPS is exceeded. Wherein QPS is a measure of how much traffic a particular query server is handling in a specified time.
However, using token bucket implementations, the runtime costs are high, and common token bucket implementations maintain locks, resulting in a large resource consumption for token bucket runtime.
The method aims to solve the problem that the prior art cannot achieve low memory consumption and strong self-adaption when a large amount of logs are output.
The present disclosure provides a log output method, apparatus, electronic device, and computer-readable storage medium. The log output method, the log output device, the electronic equipment and the computer readable storage medium can respond to the detection that the time difference is larger than a preset time interval by determining the time difference between the second time stamp of the last log output and the first time stamp of the log arrival output interface, and output log information at least comprising the log; in response to detecting that the time difference is less than or equal to the preset time interval, no log is output. Therefore, in the log output process of continuously changing the log quantity to be output, the constant-speed stable output of the log is ensured, so that the strong adaptability of log output is ensured, whether the log is output or not is judged through the time difference between the time stamps, and the memory can be saved.
Fig. 1 is a schematic view of an application environment of a log output method, a log output device, an electronic device, and a computer readable storage medium according to one or more embodiments of the present disclosure.
As shown in fig. 1, the server 100 may be a web server, a database server, or the like. The present disclosure may be implemented with a stand-alone server or a server cluster composed of a plurality of servers.
The log output method provided by the embodiment of the present disclosure will be described in detail below.
The log output method provided in the embodiment of the present disclosure may be applied to the server 100, and for convenience of description, the embodiment of the present disclosure uses the server 100 as an execution body unless specifically described. It is to be understood that the subject of execution is not to be construed as limiting the present disclosure.
Next, a log output method provided by the present disclosure will be described first.
Fig. 2 is a flow chart illustrating a log output method according to an example embodiment.
As shown in fig. 2, the log output method may include the following steps.
S210, a first timestamp of the log reaching the output interface is obtained.
S220, determining a time difference between the first time stamp and a second time stamp, wherein the second time stamp is the time stamp of the last log output by the output interface.
S230, outputting log information in response to detecting that the time difference is larger than a preset time interval, wherein the log information at least comprises logs.
S240, in response to detecting that the time difference is less than or equal to the preset time interval, the log is not output.
The specific implementation of each of the above steps will be described in detail below.
In an embodiment of the disclosure, outputting log information including at least a log by determining a time difference between a second time stamp of a last output log and a first time stamp of the log reaching an output interface, in response to detecting that the time difference is greater than a preset time interval; in response to detecting that the time difference is less than or equal to the preset time interval, no log is output. Therefore, in the log output process of continuously changing the log quantity to be output, the constant-speed stable output of the log is ensured, so that the strong adaptability of log output is ensured, whether the log is output or not is judged through the time difference between the time stamps, and the memory can be saved.
A specific implementation of each of the above steps is described below.
First, S210 is referred to.
When the log reaches the output interface, the current timestamp, i.e. the first timestamp, is acquired. The time stamp is data generated by using a digital signature technology, and the main purpose of the time stamp is to authenticate the time of data generation by a certain technical means, so as to verify whether the data is tampered after the data is generated.
Then, S220 is referred to.
As an implementation manner of the present application, in order to more finely distinguish log types, before the above-mentioned step of determining the time difference between the second timestamp and the first timestamp, the following steps may be further included:
extracting characteristic parameters related to preset information from the log content under the condition that the log content is detected to comprise the preset information; determining the characteristic parameters as log types; and matching the second timestamp corresponding to the log type of the log according to a preset corresponding relation between the log type and the second timestamp.
Firstly, extracting characteristic parameters related to preset information from log content under the condition that the log content is detected to comprise the preset information; the characteristic parameters are determined to be of the log type.
In the case of the presence of preset information, the log is interpreted to distinguish its log type. Wherein, the above-mentioned characteristic parameters may at least include: user login behavior, user refresh behavior, user login failure behavior, user attention behavior, user comment behavior, and the like. Typically, the characteristic parameters (e.g., user follow action) in the log after the preset information (e.g., message format string) are log types.
Specifically, taking a Java log as an example, when outputting the log, the log content includes at least "message format string" (message format character string) and "ars" (parameter).
For example, a log may be: "user follow action, sed { }, tid { }. I.e. the bar log represents: user attention behavior, user identity: { } thread identification: {}.
Wherein, for example, args is 6235, 3735; the final output log content is "user follow action, sed: 6235, tid:3735". I.e. the bar log represents: user attention behavior, user identity: 6235, thread identification: 3735.
the log type of this log is "user follow action", i.e. the user is concerned about the behaviour.
Here, by taking the log type as the dimension, different types of logs can be distinguished, the distinction of the log type can be more refined, and further, the stable output of the different types of logs can be ensured.
Then, according to a preset corresponding relation between the log type and the second timestamp, the second timestamp corresponding to the log type of the log is matched.
A second timestamp may be maintained in the logger for each type of log, i.e., the timestamp of the last output of that type of log. The log type and the second timestamp have a preset corresponding relation. In the case of determining the log type, the second timestamp of the log of the type may be matched according to a preset correspondence.
Wherein the log types correspond to the second time stamps, i.e. one for each log type.
Illustratively, the second timestamp corresponding to log type M is 00:03 seconds, the second timestamp corresponding to log type N is 00:28, when determining whether the log Q of the log type M arriving at the log output interface needs to be output, it is required to compare with the preset time interval according to the time difference between the second time stamp (00:03) corresponding to the log Q and the first time stamp of the log Q arriving at the log output interface.
Therefore, the log type distinction is more refined, and the stable output of different types of logs can be ensured.
Next, S230 is referred to.
And outputting log information in response to detecting that the time difference is greater than a preset time interval, wherein the log information at least comprises logs.
The preset time interval is illustratively 2 seconds. When the log D arrives at the log output interface, the last log output before that is the log C, and the second timestamp of outputting the log C is 10:00; the first timestamp when log D arrives at the log output interface is 10:04, the time difference is 4 seconds, the log D satisfies the condition that the time difference is greater than the preset time interval, and the log D may be output.
In some embodiments of the present disclosure, in response to detecting that the time difference is less than or equal to a preset time interval, a count of logs that are not output is accumulated.
In response to detecting that the time difference is less than or equal to the preset time interval, the logs that are not output may be accumulated counted in addition to not outputting the log.
The log information related to the above further includes: a count of logs that are not output for a target period of time; the target time period is a time period from the second time stamp to the first time stamp.
The count of the logs that are not output in the target period of time may be simultaneously output at the time of outputting the logs, that is, the output log information includes: the time difference between the second time stamp of the last output log and the first time stamp of the log reaching the output interface is greater than the log of the preset time interval, and the count of logs that are not output in the time period from the second time stamp to the first time stamp.
Illustratively, the log type of the log is user login failure, and the output log information may be: the time difference between the second time stamp of the last output user login failure log and the first time stamp of the arrival of the user login failure log at the output interface is larger than the log of the user login failure of the preset time interval, and the count of the user login failure log which is not output in the time period from the second time stamp to the first time stamp.
Thus, the developer can know the overall output condition of the log in the target time period according to the output log and the count of the log which is not output.
As an implementation manner of the present application, in order to keep the update of the second timestamp, after the above-mentioned step related to the step of responding to the detection that the time difference is greater than the preset time interval, the method may further include the following steps:
the second timestamp is updated to the first timestamp.
The second timestamp is the timestamp of the last log output by the output interface, and the timestamp of the last log output is updated whenever a log is output. The second timestamp is a timestamp that would be transformed with the log output. When the detected time difference is larger than the preset time interval, the log which reaches the log output interface at the first time stamp is about to be output, and the second time stamp needs to be updated to be the first time stamp.
Illustratively, the output interface outputs the timestamp of the log last time, i.e., the second timestamp is the 3 rd second. When the log output interface outputs the log at the 4 th second (first time stamp), the second time stamp (3 rd second) is updated to the first time stamp (4 th second).
Thus, by updating the second time stamp to the first time stamp in response to detecting that the time difference is greater than the preset time interval, the update of the second time stamp can be maintained, and the log can be stably output.
As an implementation manner of the present application, in order to monitor the number of logs that are not output more accurately, after the above-mentioned steps involved in response to detecting that the time difference is greater than the preset time interval, the following steps may be further included:
resetting the count of the log that is not output to an initial value; the initial value is used for indicating the preset number of the logs which are not output.
The initial value may be the number of logs not output set by the user, or the number of logs not output set by the server. For example, the count of the log that is not output is reset to 0.
Illustratively, 100 logs arrive at the output interface every second, log A is output at 1 second, 99 logs are logs that are not output, the count of log A and logs that are not output is output at 1 second "99", and the count of logs that are not output is reset to 0; the log B was output at the 2 nd second, and 28 logs were not output, and here, the log a and the count "28" of the log not output were output.
That is, after each detection that the time difference is greater than the preset time interval, counts of the logs and the logs that are not output satisfying the condition that the time difference is greater than the preset time interval are output, and counts of the logs that are not output are reset to an initial value. When the log meeting the condition that the time difference is larger than the preset time interval is output again subsequently, the count of the log which is not output at the previous time is not accumulated again.
Therefore, the count of the logs which are not output is reset to the initial value in response to the fact that the time difference is detected to be larger than the preset time interval, the number of the logs which are not output can be accurately monitored, and a developer can know the log output condition more clearly.
Finally, S240 is concerned.
The preset time interval is illustratively 2 seconds. When the log E arrives at the log output interface, the last log output before that is the log C, and the second timestamp of the output log F is 10:00; the first timestamp when log E arrives at the log output interface is 10:01, the time difference is 1 second, the log E satisfies the condition that the time difference is less than or equal to the preset time interval, and the log E is not output.
As an implementation manner of the present application, in order to synchronize the count of the log that is not output, after the step of not outputting the log related to the above, the following steps may be further included:
in response to detecting that the time difference is less than or equal to the preset time interval, a count of logs that are not output is updated.
In response to detecting that the time difference is less than or equal to the preset time interval, i.e. each time there is a log that is not to be output, the count of the log that is not to be output is updated, 1 may be added on the basis of the count of the existing log that is not to be output.
Illustratively, the count of logs that are not output is skip count, and after no log is output, skip count=skip count+1.
Thus, the stability of log output is ensured by updating the count of logs that are not output in response to detecting that the time difference is less than or equal to the preset time interval.
In summary, the embodiments of the present disclosure output log information including at least a log in response to detecting that a time difference is greater than a preset time interval by determining a time difference between a second time stamp of a last output log and a first time stamp of a log reaching an output interface; in response to detecting that the time difference is less than or equal to the preset time interval, no log is output. Therefore, no matter how many logs are to be output, a fixed number of logs can be output in a preset time. Therefore, in the log output process of continuously changing the log quantity to be output, the constant-speed stable output of the log is ensured, so that the strong adaptability of log output is ensured, whether the log is output or not is judged through the time difference between the time stamps, and the memory can be saved.
Based on the log output method, the present disclosure also provides a method for implementing log output. This is described in detail with reference to fig. 3.
FIG. 3 is a flowchart illustrating a method of implementing log output according to an example embodiment.
S301, a first timestamp of the log reaching the output interface is obtained.
When the log arrives at the output interface, the current timestamp is acquired as the first timestamp.
S302, determining a time difference between the second time stamp and the first time stamp.
The time difference between the last time the output interface outputs the log and the first time the log arrives at the output interface is determined.
S303, judging whether the time difference is larger than a preset time interval.
If the time difference is greater than the preset time interval, executing S304;
if the time difference is not greater than the preset time interval, S305 is performed.
S304, updating the second time stamp to be the first time stamp, and outputting the log.
And outputting logs with time difference larger than a preset time interval.
S305, no log is output.
And outputting the logs with the time difference not greater than the preset time interval, namely outputting the logs with the time difference not greater than the preset time interval.
The specific implementation of each of the above steps will be described in detail below.
In summary, the embodiments of the present disclosure output log information including at least a log in response to detecting that a time difference is greater than a preset time interval by determining a time difference between a second time stamp of a last output log and a first time stamp of a log reaching an output interface; in response to detecting that the time difference is less than or equal to the preset time interval, no log is output. Therefore, no matter how many logs are to be output, a fixed number of logs can be output in a preset time. Therefore, in the log output process of continuously changing the log quantity to be output, the constant-speed stable output of the log is ensured, so that the strong adaptability of log output is ensured, whether the log is output or not is judged through the time difference between the time stamps, and the memory can be saved.
Based on the log output method, the disclosure further provides a log output device. This is described in detail with reference to fig. 4.
Fig. 4 is a block diagram illustrating a log output device according to an example embodiment. Referring to fig. 4, the log output apparatus 400 may include an acquisition module block 410, a first determination module 420, an output module 430, and a non-output module 440.
The acquisition module 410 is configured to perform a first time stamp of the arrival of the acquisition log at the output interface.
The first determining module 420 is configured to perform determining a time difference between a first time stamp and a second time stamp, the second time stamp being a time stamp of a last output log of the output interface.
The output module 430 is configured to perform outputting log information including at least a log in response to detecting that the time difference is greater than a preset time interval.
The no output module 440 is configured to perform no output of the log in response to detecting that the time difference is less than or equal to the preset time interval.
In the embodiment of the present disclosure, the log output device 400 can output log information including at least a log by determining a time difference between a second time stamp of a last output log and a first time stamp of a log reaching an output interface, in response to detecting that the time difference is greater than a preset time interval; in response to detecting that the time difference is less than or equal to the preset time interval, no log is output. Therefore, no matter how many logs are to be output, a fixed number of logs can be output in a preset time. Therefore, in the log output process of continuously changing the log quantity to be output, the constant-speed stable output of the log is ensured, so that the strong adaptability of log output is ensured, whether the log is output or not is judged through the time difference between the time stamps, and the memory can be saved.
In some embodiments of the present disclosure, the log output device 400 may further include: the first updating module is configured to perform updating of the second timestamp to the first timestamp.
In some embodiments of the present disclosure, the log output device 400 may further include: and an accumulation module configured to perform accumulation of counts of logs not output in response to detecting that the time difference is less than or equal to a preset time interval.
The log information related to the above further includes: a count of logs that are not output for a target period of time; wherein the target time period is a time period from the second time stamp to the first time stamp.
In some embodiments of the present disclosure, the log output device 400 may further include:
a reset module configured to perform resetting of a count of logs that are not output to an initial value; the initial value is used for indicating the preset number of the logs which are not output.
In some embodiments of the present disclosure, the log output device 400 may further include:
and a second updating module configured to perform updating of the count of the logs that are not output in response to detecting that the time difference is less than or equal to the preset time interval.
In some embodiments of the present disclosure, the log output device 400 may further include:
and the extraction module is configured to perform extraction of characteristic parameters related to preset information in the log content when the log content is detected to comprise the preset information.
And a second determination module configured to perform determining the characteristic parameter as the log type.
And the matching module is configured to perform matching of the second timestamp corresponding to the log type of the log according to a preset corresponding relation between the log type and the second timestamp.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
Fig. 5 is a block diagram of a server, according to an example embodiment. Referring to fig. 5, the embodiment of the present disclosure further provides a server including a processor 510, a communication interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 complete communication with each other through the communication bus 540.
The memory 530 is used for storing instructions executable by the processor 510.
The processor 510 is configured to execute the instructions stored in the memory 530, and implement the following steps:
acquiring a first timestamp of log reaching an output interface; determining a time difference between a second time stamp and the first time stamp, wherein the second time stamp is the time stamp of the last log output by the output interface; in response to detecting that the time difference is greater than a preset time interval, outputting log information, wherein the log information at least comprises logs; in response to detecting that the time difference is less than or equal to the preset time interval, no log is output.
It can be seen that, by applying the embodiment of the present disclosure, by determining a time difference between a second time stamp of a last output log and a first time stamp of a log reaching an output interface, log information including at least the log is output in response to detecting that the time difference is greater than a preset time interval; in response to detecting that the time difference is less than or equal to the preset time interval, no log is output. Therefore, no matter how many logs are to be output, a fixed number of logs can be output in a preset time. Therefore, in the log output process of continuously changing the log quantity to be output, the constant-speed stable output of the log is ensured, so that the strong adaptability of log output is ensured, whether the log is output or not is judged through the time difference between the time stamps, and the memory can be saved.
FIG. 6 is a block diagram illustrating an apparatus for data processing according to an example embodiment. For example, the device 600 may be provided as a server. Referring to fig. 6, server 600 includes a processing component 622 that further includes one or more processors and memory resources represented by memory 632 for storing instructions, such as applications, executable by processing component 622. The application programs stored in memory 632 may include one or more modules each corresponding to a set of instructions. Further, the processing component 622 is configured to execute instructions to perform the log output method described in any of the embodiments above.
The device 600 may also include a power component 626 configured to perform power management of the device 600, a wired or wireless network interface 650 configured to connect the device 600 to a network, and an input/output (I/O) interface 658. The device 600 may operate based on an operating system stored in memory 632, such as Windows Server, mac OS XTM, unixTM, linuxTM, freeBSDTM, or the like.
In some embodiments of the present disclosure, there is also provided a computer-readable storage medium, which when executed by a processor of a server, causes the server to perform the log output method of any one of the embodiments described above.
Alternatively, the computer readable storage medium may be a non-transitory computer readable storage medium, which may be, for example, a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
In some embodiments of the present disclosure, there is also provided a computer program product, which when executed by a processor of a server, enables the server to perform the log output method of any one of the embodiments described above.
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 application is intended to cover any adaptations, 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 is to be understood that the present disclosure is not limited to the precise arrangements and instrumentalities shown in the drawings, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (14)

1. A log output method, comprising:
acquiring a first timestamp of log reaching an output interface;
determining a time difference between the first time stamp and a second time stamp, wherein the second time stamp is the time stamp of the last log output by the output interface;
in response to detecting that the time difference is greater than a preset time interval, outputting log information, the log information including at least the log;
responsive to detecting that the time difference is less than or equal to the preset time interval, not outputting the log;
wherein prior to said determining the time difference between the first and second time stamps, the method further comprises:
extracting characteristic parameters related to preset information from the log content under the condition that the log content is detected to comprise the preset information;
determining the characteristic parameter as the log type;
and matching the second timestamp corresponding to the log type of the log according to a preset corresponding relation between the log type and the second timestamp.
2. The method of claim 1, wherein after said responding to detecting that said time difference is greater than a preset time interval, the method further comprises:
updating the second timestamp to the first timestamp.
3. The method according to claim 1, wherein the method further comprises:
in response to detecting that the time difference is less than or equal to the preset time interval, a count of logs that are not output is accumulated.
4. A method according to claim 3, wherein the log information further comprises: a count of the logs that are not output for a target period of time;
wherein the target time period is a time period from the second time stamp to the first time stamp.
5. The method of claim 4, wherein after said responding to detecting said time difference being greater than a preset time interval, the method further comprises:
resetting the count of the log that is not output to an initial value; the initial value is used for indicating the preset number of the logs which are not output.
6. The method according to claim 4, wherein the method further comprises:
in response to detecting that the time difference is less than or equal to the preset time interval, a count of the logs that are not output is updated.
7. A log output device, comprising:
an acquisition module configured to perform acquiring a first timestamp of the log reaching the output interface;
a first determining module configured to perform determining a time difference between a second time stamp and the first time stamp, the second time stamp being a time stamp of a last output log of the output interface;
an output module configured to perform outputting log information in response to detecting that the time difference is greater than a preset time interval, the log information including at least the log;
a non-output module configured to perform not outputting the log in response to detecting that the time difference is less than or equal to the preset time interval;
the apparatus further comprises:
an extraction module configured to perform, in a case where it is detected that the log content includes preset information, extraction of feature parameters related to the preset information in the log content;
a second determination module configured to perform determining the characteristic parameter as the log type;
and the matching module is configured to perform matching of the second timestamp corresponding to the log type of the log according to a preset corresponding relation between the log type and the second timestamp.
8. The apparatus of claim 7, wherein the apparatus further comprises:
a first updating module configured to perform updating the second timestamp to the first timestamp.
9. The apparatus of claim 7, wherein the apparatus further comprises:
and an accumulation module configured to perform accumulation of counts of logs that are not output in response to detecting that the time difference is less than or equal to the preset time interval.
10. The apparatus of claim 9, wherein the log information further comprises: a count of the logs that are not output for a target period of time; wherein the target time period is a time period from the second time stamp to the first time stamp.
11. The apparatus of claim 10, wherein the apparatus further comprises:
a reset module configured to perform resetting of the count of the log that is not output to an initial value; the initial value is used for indicating the preset number of the logs which are not output.
12. The apparatus of claim 10, wherein the apparatus further comprises:
and a second updating module configured to perform updating of the count of the logs that are not output in response to detecting that the time difference is less than or equal to the preset time interval.
13. A server, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the log output method of any one of claims 1 to 6.
14. A computer readable storage medium, characterized in that instructions in the computer readable storage medium, when executed by a processor of a server, enable the server to perform the log output method of any one of claims 1 to 6.
CN202011607768.7A 2020-12-29 2020-12-29 Log output method, device, server and computer readable storage medium Active CN112699015B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011607768.7A CN112699015B (en) 2020-12-29 2020-12-29 Log output method, device, server and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011607768.7A CN112699015B (en) 2020-12-29 2020-12-29 Log output method, device, server and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN112699015A CN112699015A (en) 2021-04-23
CN112699015B true CN112699015B (en) 2023-12-19

Family

ID=75512437

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011607768.7A Active CN112699015B (en) 2020-12-29 2020-12-29 Log output method, device, server and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN112699015B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105430161A (en) * 2015-10-29 2016-03-23 小米科技有限责任公司 Message processing method and device
CN109840178A (en) * 2017-11-28 2019-06-04 合肥杰发科技有限公司 A kind of method, mobile terminal and the device of monitoring journal information
CN111143317A (en) * 2019-12-29 2020-05-12 北京浪潮数据技术有限公司 Log storage method, device and equipment and readable storage medium
CN111711642A (en) * 2020-07-15 2020-09-25 网易(杭州)网络有限公司 Protocol request processing method and device, electronic equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200050692A1 (en) * 2018-08-10 2020-02-13 Microsoft Technology Licensing, Llc Consistent read queries from a secondary compute node

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105430161A (en) * 2015-10-29 2016-03-23 小米科技有限责任公司 Message processing method and device
CN109840178A (en) * 2017-11-28 2019-06-04 合肥杰发科技有限公司 A kind of method, mobile terminal and the device of monitoring journal information
CN111143317A (en) * 2019-12-29 2020-05-12 北京浪潮数据技术有限公司 Log storage method, device and equipment and readable storage medium
CN111711642A (en) * 2020-07-15 2020-09-25 网易(杭州)网络有限公司 Protocol request processing method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN112699015A (en) 2021-04-23

Similar Documents

Publication Publication Date Title
CN109739727B (en) Service monitoring method and device in micro-service architecture
CN109284269B (en) Abnormal log analysis method and device, storage medium and server
CN108156006B (en) Buried point data reporting method and device and electronic equipment
US10558544B2 (en) Multiple modeling paradigm for predictive analytics
US20070038896A1 (en) Call-stack pattern matching for problem resolution within software
US20140380282A1 (en) Monitoring mobile application performance
US20140143625A1 (en) Computer-readable recording medium, failure prediction device and applicability determination method
US20180143897A1 (en) Determining idle testing periods
CN107357731A (en) Process produces monitoring, analysis and the processing method of core dump problems
CN112817831A (en) Application performance monitoring method, device, computer system and readable storage medium
CN112434043A (en) Data synchronization method, device, electronic equipment and medium
US20150074808A1 (en) Rootkit Detection in a Computer Network
CN113342608A (en) Method and device for monitoring streaming computing engine task
CN112699015B (en) Log output method, device, server and computer readable storage medium
CN110347572B (en) Method, device, system, equipment and medium for outputting performance log
CN112054934A (en) Protocol detection method and device and electronic equipment
CN111552566B (en) Data processing system, method, electronic equipment and storage medium
CN113014448B (en) Login state rule extraction method and device and electronic equipment
CN112764990B (en) Target process monitoring method and device and computer equipment
CN112988776A (en) Method, device and equipment for updating text parsing rule and readable storage medium
CN115129548A (en) Alarm analysis method, device, equipment and medium
CN108764607B (en) User monthly data review method, device, equipment and storage medium
CN108255669A (en) The method and system of the batch processing of application performed in monitoring Basis of Computer Engineering facility
CN110244991B (en) Micro-service dependency analysis method and device
CN113157048B (en) Behavior data analysis method based on multi-terminal time axis and related components

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
GR01 Patent grant
GR01 Patent grant