Log management and control method and device, equipment and medium
By selecting appropriate log management methods to intercept log data output when the log level storage capacity exceeds the threshold, the problems of insufficient memory and low processing efficiency caused by the surge in log data volume are solved, and effective control of log output and improvement of system performance are achieved.
Patent Information
- Application Number
- CN202510059135.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-09-23
AI Technical Summary
In the existing technology, the surge in log data volume leads to problems such as insufficient memory and low processing efficiency, and manual processing of log output is inefficient.
By determining the storage capacity of the target log level, judging whether it exceeds the threshold, selecting the appropriate log control method, and intercepting log data output from the log control method set, the generation and storage pressure of log data can be reduced.
Effectively control the amount and growth rate of log output, reduce storage pressure, improve system processing efficiency, and enhance the flexibility of log management and control.
Smart Images

Figure CN120687425A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a log management method, apparatus, device, and medium. Background Art
[0002] In computer systems, logs, as recorders of system behavior, play a vital role in troubleshooting, performance monitoring, and business verification. For example, when a program encounters an error, logs can quickly pinpoint the problem. As business scale and system complexity increase, the volume of log data generated surges. To address this challenge, related technologies primarily employ the following two approaches to process the massive amounts of log data generated.
[0003] The first approach is to store log data directly in memory. However, this approach can quickly consume system memory resources, leading to insufficient computer memory and thus affecting processing efficiency. The second approach is to manually annotate some of the statements in the log output, thereby reducing the amount of log data generated. However, this approach relies on manual processing and requires users to spend a lot of time and effort writing and modifying code, resulting in poor log processing efficiency. Failure to effectively control log output will affect computer processing efficiency. Summary of the Invention
[0004] In view of the above, it is necessary to provide a log management method, device, equipment and medium that can solve the technical problem of difficulty in effectively controlling log output.
[0005] On the one hand, the present application provides a log control method, which includes: determining the storage capacity occupied by the log data of the target application, wherein the log data belongs to the target log level, the target log level has a corresponding log control method set, and the log data is obtained through the log control method records in the log control method set. If the storage capacity is greater than the storage threshold corresponding to the target log level, the target log control method is determined from the log control method set, and the output of the log data corresponding to the target log control method is intercepted. On the other hand, the present application provides a log control device, which includes: a determination module for determining the storage capacity occupied by the log data of the target application, wherein the log data belongs to the target log level, the target log level has a corresponding log control method set, and the log data is obtained through the log control method records in the log control method set. The determination module is also used to determine the target log control method from the log control method set if the storage capacity is greater than the storage threshold corresponding to the target log level, and an interception module for intercepting the output of the log data corresponding to the target log control method.
[0006] On the other hand, the present application provides an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the log management method when executing the computer program. On the other hand, the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the log management method is implemented.
[0007] In the log control method provided in the embodiment of the present application, when the storage capacity is greater than the storage threshold, it can be determined that the storage pressure caused by the log data is large. Since the log data is obtained from the log control method records in the log control method set, determining the target log control method from the log control method set corresponding to the target log level to which the log data belongs, and intercepting the output of the log data corresponding to the target log control method can effectively reduce the amount of log data output and control the growth rate of log data, thereby alleviating the storage pressure caused by the log data and achieving effective control of log output. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] Figure 1 This is a flow chart of a log management method provided in one embodiment of the present application.
[0009] Figure 2 This is a schematic diagram of a log management method provided in an embodiment of the present application.
[0010] Figure 3 This is a flowchart of a method for determining a target log management method provided by another embodiment of the present application.
[0011] Figure 4 This is a schematic diagram of the structure of a log management and control device provided in one embodiment of the present application.
[0012] Figure 5 It is a structural diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0013] It should be noted that, in this application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A alone, A and B together, and B alone, where A and B can be singular or plural. The terms "first," "second," "third," "fourth," and so on (if any) in the specification, claims, and drawings of this application are used to distinguish similar objects, not to describe a specific order or precedence.
[0014] In the embodiments of the present application, words such as "exemplarily" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a concrete manner. The following embodiments and features in the embodiments may be combined with each other unless there is a conflict.
[0015] The present application provides a log management method that effectively controls log output. The log management method provided in the present application can be applied to one or more electronic devices, including embedded devices, laptops, mobile phones, computers, and servers. The present application does not limit the type of electronic device.
[0016] like Figure 1 The figure is a flow chart of the log control method provided by an embodiment of the present application. According to different requirements, the order of each step in the flow chart can be adjusted according to actual requirements, and some steps can be omitted. The method is applied to electronic devices, such as Figure 5 An electronic device 50 is shown.
[0017] S11, determining the storage capacity occupied by log data of the target application, wherein the log data belongs to a target log level, the target log level has a corresponding log control method set, and the log data is recorded by the log control method in the log control method set.
[0018] In some embodiments of the present application, the target application can be any application program, and the present application does not limit the type of the target application. The log level of the log data can be used to reflect or measure the urgency of the log data or log message. The log level of the log data can include, but is not limited to, debug, info, warn, error, and critical. Exemplarily, the target log level can be any one of the log levels of debug, info, warn, error, and critical.
[0019] In some embodiments of the present application, the electronic device can read configuration information from a database and determine the status of the first monitoring switch and the status of the second monitoring switch corresponding to the target log level, the statistical period and storage threshold and other information through the configuration information.
[0020] Among them, the database can be an internal database of the electronic device or a database of an external device, and this application does not impose any restrictions on this. The configuration information can be written by the user. For example, the user can write the configuration information to the database of the electronic device through the configuration management terminal. The first monitoring switch is used to control the opening and closing of the log monitoring function of the electronic device for log data of all log levels. For example, when the first monitoring switch is on, the electronic device can monitor the occupancy of storage resources by log data corresponding to all log levels. When the first monitoring switch is off, the electronic device does not monitor the occupancy of storage resources by log data corresponding to any log level. The statistical period can be the time period for performing log data statistics for the target log level. The second monitoring switch corresponding to the target log level is used to control whether the storage capacity occupied by the log data of the target log level is compared with the corresponding storage threshold, so as to determine whether to control the output of the log data of the target log level.
[0021] The configuration information corresponding to the target log level can be customized, and this application does not impose any restrictions on this. For example, if the state of the second monitoring switch corresponding to the target log level can be on, the corresponding statistical period can be 10 minutes, and the corresponding storage threshold can be 3 gigabytes (GB). Alternatively, the state of the second monitoring switch corresponding to the target log level can be off, the corresponding statistical period can be 5 minutes, and the corresponding storage threshold can be 1GB. The state of the second monitoring switch corresponding to the error level can be on, the corresponding statistical period can be 3 minutes, and the corresponding storage threshold can be 1GB. The above is only an example of the state, statistical period, storage threshold and other information of the second monitoring switch corresponding to the target log level, and there is no limitation in actual application.
[0022] Exemplarily, the electronic device determines the storage capacity occupied by the log data of the target application, including: determining whether the first monitoring switch is on; if the first monitoring switch is on, determining the storage capacity based on the size of the storage space occupied by the log data of the target log level within the statistical period.
[0023] Among them, the electronic device can directly determine the size of the storage space occupied by the log data of the target log level during the statistical period as the storage capacity occupied by the log data. The storage space occupied by the log data can be the memory space in the electronic device, or it can be cloud storage space and flash memory space, etc. This application does not limit the type of storage space. For example, if the storage space occupied by the log data is memory space, the storage capacity can be the size of the memory occupied by the log data.
[0024] In this embodiment, since the configuration information corresponding to the target log level can be personalized, the flexibility of log management and control can be improved.
[0025] In some embodiments of the present application, the set of log control methods corresponding to the target log level may include multiple log control methods. Each log control method may correspond to a programming class. Log control methods may also be referred to as logging classes, and the set of log control methods may be a collection of classes. Log data may be obtained by recording various types of information generated by the target application during operation using the log control methods in the set of log control methods.
[0026] S12, determining whether the storage capacity is greater than a storage threshold corresponding to the target log level.
[0027] In some embodiments of the present application, before determining whether the storage capacity occupied by the log data of the target log level is greater than the storage threshold corresponding to the target log level in the configuration information, the electronic device can determine whether the second monitoring switch corresponding to the target log level is in the on state. If the corresponding second monitoring switch is in the on state, the electronic device can compare the storage capacity with the storage threshold.
[0028] Among them, the electronic device can determine whether the second monitoring switch corresponding to the target log level is in the on state based on the state of the second monitoring switch corresponding to the target log level. Exemplarily, when the second monitoring switch corresponding to the target log level is in the on state, the electronic device can compare the storage capacity occupied by the log data of the target log level with the corresponding storage threshold. When the second monitoring switch corresponding to the target log level is in the off state, the electronic device does not compare the storage capacity occupied by the log data of the target log level with the corresponding storage threshold.
[0029] For example, following the above embodiment, if the state of the second monitoring switch corresponding to the target log level is on, the statistical period is 10 minutes, and the storage threshold is 3GB, when the storage capacity of the warn level log data within 10 minutes is 3.5GB, the electronic device compares 3GB with 3.5GB.
[0030] In this embodiment, if the storage capacity occupied by the log data of the target log level is greater than the corresponding storage threshold, step S13 is executed. For example, continuing with the above embodiment, if the storage capacity of 3.5 GB is greater than 3 GB, step S13 is executed.
[0031] S13: Determine a target log control method from the log control method set.
[0032] In some embodiments of the present application, multiple log control methods in a log control method set are polled according to a first preset order. The first preset order can be customized, and this application does not limit this. For example, if the log control method set includes a first log control method, a second log control method, and a third log control method, the polling order among the three log control methods can be the first log control method → the third log control method → the second log control method. Exemplarily, the electronic device may determine a target log control method from a plurality of log control methods in a log control method set according to a first preset order.
[0033] The electronic device may determine the current polling position according to the first preset order and determine the log control method corresponding to the current polling position as the target log control method. For example, if the log control method corresponding to the current polling position is the third log control method in the log control method set, the electronic device may determine the third log control method as the target log control method.
[0034] The electronic device can track the dynamically changing polling location using a pointer or counter to determine the current polling location. The value of the counter or pointer can be updated during each polling cycle to indicate the location of the next log control method. Based on the value of the pointer or counter, the electronic device can quickly determine the log control method corresponding to the current polling location and use the determined log control method as the target log control method.
[0035] In this embodiment, through the polling mechanism, each log control method in the log control method set has the opportunity to be selected as the target log control method, thereby avoiding poor log control effect due to the same log control method being frequently selected.
[0036] In other embodiments of the present application, the log control methods in the log control method set can be arranged according to a second preset order, wherein the second preset order can be customized, and this application does not impose any restrictions on this. Each log control method in the log control method set can correspond to an index, and the index corresponding to each log control method can be determined based on the order in which the log control method is arranged in the corresponding log control method set.
[0037] The electronic device may determine a target log control method from multiple log control methods in the log control method set based on an index corresponding to each log control method in the log control method set.
[0038] Exemplarily, the electronic device can count the number of log control methods in the log control method set, determine the target numerical range based on the number of log control methods, generate a first random number based on the target numerical range, determine the index that matches the first random number, and determine the log control method corresponding to the matching index as the target log control method.
[0039] Among them, the upper limit of the target numerical range can be the number of log control methods, and the lower limit can be zero. For example, if the number of log control methods in the log set is 3, the target numerical range can be [0, 3). The electronic device can generate the first random number through a variety of methods, and the present application does not limit the method for generating the first random number. For example, the first random number can be generated using the random number generation function random. The index that matches the first random number can be the same index as the first random number. For example, if the first random number is 2, the log control method corresponding to the index that is the same as the first random number is the second log control method in the log set, and the electronic device can determine that the second log control method is the target log control method.
[0040] In this embodiment, a matching index is selected by generating a first random number within a target numerical interval, so that the target log control method can be determined based on the matching index. This introduces a random selection mechanism, allowing the target log control method to be automatically and quickly determined. Since the target numerical interval covers the indexes of all log control methods, generating a first random number based on the target numerical interval and determining the target log control method based on the index corresponding to the first random number ensures that the probability of each log control method being selected as the target log control method is uniform. This uniformity makes the target log control method representative.
[0041] S14, intercepting the output of log data corresponding to the target log control method. In some embodiments of the present application, an electronic device may intercept the output of log data corresponding to a target log control method based on the configuration of a log component. The log component may be a logback module. The electronic device may intercept the output of log data corresponding to the target log control method using a variety of methods. This application does not limit the method for intercepting the output of log data. The output of log data may also be referred to as printing.
[0042] For example, the electronic device can configure a filter in logback to intercept the output of log data corresponding to the target log control method. The electronic device can configure the corresponding filter in logback based on information such as the class name of the target log control method.
[0043] In this embodiment, by intercepting the output of log data corresponding to the target log management method, the output of log data can be effectively reduced, and the growth rate of log data can be controlled, thereby alleviating the storage pressure of log data and achieving effective control of log output.
[0044] In other embodiments of the present application, the electronic device may delete all or part of the log data corresponding to the target log control method in the storage space. For example, if the log data is located in the memory, the log data corresponding to the target log control method may be deleted from the memory.
[0045] In this embodiment, deleting all or part of the log data corresponding to the target log management and control method in the storage space can effectively reduce storage pressure.
[0046] like Figure 2 The figure is a schematic diagram of a log management method provided by an embodiment of the present application. Figure 2 In the embodiment, configuration information is read, and whether the first monitoring switch is in the on state is determined according to the configuration information. When the first monitoring switch is in the on state, the storage capacity occupied by the log data corresponding to the target log level in the target application is determined. According to the configuration information, whether the second monitoring switch corresponding to the target log level is in the on state is determined. When the second monitoring switch corresponding to the target log level is in the on state, it is determined whether the storage capacity occupied by the log data of the target log level is greater than the storage threshold corresponding to the target log level in the configuration information. When the storage capacity corresponding to the target log level is greater than the storage threshold corresponding to the target log level, the target log control method is determined from the log control method set corresponding to the target log level, and the output of the log data corresponding to the target log control method is intercepted.
[0047] In the log control method provided in the embodiment of the present application, when the storage capacity is greater than the storage threshold, it can be determined that the storage pressure caused by the log data is large. Since the log data is obtained from the log control method records in the log control method set, the target log control method is determined from the log control method set corresponding to the target log level to which the log data belongs, and the output of the log data corresponding to the target log control method is intercepted. This can effectively reduce the output amount of log data and control the growth rate of log data, thereby slowing down the storage pressure caused by the log data and achieving effective control of log output. In addition, since the configuration information corresponding to the target log level can be personalized, the flexibility of log control can be improved.
[0048] like Figure 3 FIG. 1 is a flowchart of a method for determining a target log management method according to another embodiment of the present invention, including the following steps: S131 , determining a weight range corresponding to each log control method according to preset weights corresponding to multiple log control methods in the log control method set.
[0049] In some embodiments of the present application, the electronic device determines, for each log control method, a first target weight corresponding to the log control method based on the preset weight corresponding to the log control method and the preset weight corresponding to the log control method before the log control method, calculates the second target weight corresponding to the log control method based on the first target weight and the preset weight corresponding to the log control method, and determines the weight interval corresponding to the log control method based on the first target weight and the second target weight corresponding to the log control method.
[0050] Among them, the preset weights corresponding to multiple log control methods in the configuration information can be in the form of a ratio. For example, continuing the above embodiment, if the log control method set includes the first log control method, the second log control method and the third log control method, then the ratio of the preset weights corresponding to the first log control method, the second log control method and the third log control method can be 1:7:2. Among them, the greater the preset weight corresponding to the log control method, the greater the probability that the log control method is selected as the target log control method. The electronic device can accumulate and calculate the preset weights corresponding to the multiple log control methods to obtain the first target weight corresponding to each log control method.
[0051] In other embodiments of the present application, in order to ensure the accuracy of the determination of the target log control method, before accumulating and calculating the preset weights, the preset weights corresponding to multiple log control methods can be normalized to obtain the normalized weights corresponding to each log control method, so that the normalized weights can be on a uniform scale. Among them, the preset value range can be customized, and this application does not impose any restrictions on this. For example, the preset value range can be 0~1.
[0052] Exemplarily, following the above embodiment, the ratio of the preset weights corresponding to the first log control method, the second log control method and the third log control method can be normalized to 1:7:2 according to the range of 0~1, and the ratio of the normalized weights corresponding to the first log control method, the second log control method and the third log control method can be obtained as 0.1:0.7:0.2, where 0.1 represents the normalized weight corresponding to the first log control method, 0.7 represents the normalized weight corresponding to the second log control method, and 0.2 represents the normalized weight corresponding to the weight of the third log control method.
[0053] In some embodiments of the present application, the first The weight interval corresponding to each log control method is expressed as ;in, Indicates the The second target weight corresponding to each log control method, Indicates the The first target weight corresponding to each log control method, Indicates the The preset weight corresponding to each log control method, or the preset value interval for the first The normalized weight is obtained by normalizing the preset weights corresponding to the log control methods. Indicates the The preset weight corresponding to each log control method or the preset value range of the first The normalized weight is obtained by normalizing the preset weights corresponding to the log control methods.
[0054] Among them, by adding the preset weight or normalized weight corresponding to each log control method to the preset weight or normalized weight of all log control methods before the log control method, the first target weight corresponding to the log control method can be obtained. By subtracting the first target weight corresponding to each log control method from the preset weight, the second target weight corresponding to each log control method can be obtained. The second target weight corresponding to each log control method can be used as the lower limit of the corresponding target numerical range, and the first target weight corresponding to the log control method can be used as the upper limit of the corresponding target numerical range, so as to obtain the target numerical range corresponding to the log control method.
[0055] For example, continuing with the above embodiment, if the ratio of the normalized weights corresponding to the first log control method, the second log control method, and the third log control method is 0.1:0.7:0.2, the first target weight corresponding to the first log control method can be 0.1=0.1+0, the first target weight corresponding to the second log control method can be 0.8=0.1+0.7, and the first target weight corresponding to the third log control method can be 1=0.1+0.7+0.2. The second target weight corresponding to the first log control method is 0=0.1-0.1, the second target weight corresponding to the second log control method is 0.1=0.8-0.7, and the second target weight corresponding to the third log control method is 0.8=1-0.2. Therefore, according to the second target weight of 0 and the first target weight of 0.1 corresponding to the first log control method, the weight interval corresponding to the first log control method can be obtained [0.0, 0.1); according to the second target weight of 0.1 and the first target weight of 0.8 corresponding to the second log control method, the weight interval corresponding to the second log control method can be obtained [0.1, 0.8); according to the second target weight of 0.8 and the first target weight of 1 corresponding to the third log control method, the weight interval corresponding to the third log control method can be obtained [0.8, 1).
[0056] In this embodiment, the size of the preset weight corresponding to each log control method can reflect whether the user wants to prioritize intercepting the output of the log control method. The larger the preset weight, the higher the priority. The second target weight corresponding to each log control method is calculated by the first target weight and the preset weight corresponding to each log control method. The weight interval corresponding to each log control method is determined based on the first target weight and the second target weight corresponding to each log control method. A larger weight interval can be generated for log control methods corresponding to larger preset weights. In addition, since the preset weight corresponding to each log control method can be customized, the flexibility of log control can be improved.
[0057] S132: Generate a second random number within a preset numerical range.
[0058] In some embodiments of the present application, the preset numerical interval can be customized, for example, the preset numerical interval can be [0, 1]. The method for generating the second random number can refer to the method for generating the first random number, and will not be repeated in this application.
[0059] S133: Determine the weight interval in which the second random number is located, and determine the log control method corresponding to the weight interval as the target log control method.
[0060] For example, continuing with the above embodiment, if the second random number is 0.5, the weight interval of the second random number 0.5 is the weight interval [0.1, 0.8) corresponding to the second log control method, and the electronic device can determine the second log control method as the target log control method.
[0061] In this embodiment, since the size of the preset weight corresponding to each log control method can reflect whether the user wants to prioritize intercepting the output of the log control method, the larger the preset weight, the higher the priority. Therefore, by generating a larger weight interval for the log control method corresponding to the larger preset weight, the probability of the second random number falling within the weight interval can be increased, thereby increasing the probability of the log control method being selected as the target log control method. By intercepting the output of the log data of the target log control method, the accuracy of log control can be ensured.
[0062] See also Figure 4 , is a structural diagram of a log control device provided by an embodiment of the present application, which can implement the details of the log control method in the above embodiment and achieve the same effect. Figure 4 As shown, the log control device 40 can be run on an electronic device with a log control function. The device 40 includes: Determination module 401 is used to determine the storage capacity occupied by the log data of the target application, wherein the log data belongs to the target log level, the target log level has a corresponding log control method set, and the log data is obtained by recording the log control method in the log control method set.
[0063] The determination module 401 is further configured to determine a target log management method from the log management method set if the storage capacity is greater than a storage threshold corresponding to the target log level.
[0064] The interception module 402 is used to intercept the output of log data corresponding to the target log control method.
[0065] In some embodiments of the present application, each log control method in the log control method set corresponds to an index, and the determination module 401 is also used to count the number of log control methods in the log control method set, determine the target numerical range based on the number, and generate a first random number based on the target numerical range, determine the index that matches the first random number, and determine the log control method corresponding to the matching index as the target log control method.
[0066] In some embodiments of the present application, multiple log control methods in the log control method set are polled according to a first preset order, and the determination module 401 is also used to determine the current polling position according to the first preset order, and determine the log control method corresponding to the current polling position as the target log control method.
[0067] In some embodiments of the present application, the determination module 401 is also used to determine the weight interval corresponding to each log control method based on the preset weights corresponding to multiple log control methods in the log control method set, generate a second random number within the preset numerical interval, determine the weight interval in which the second random number is located, and determine the log control method corresponding to the weight interval as the target log control method.
[0068] In some embodiments of the present application, multiple log control methods in the log control method set are arranged in a second preset order; the determination module 401 is also used to determine, for each log control method, the first target weight corresponding to the log control method according to the preset weight corresponding to the log control method and the preset weight corresponding to the log control method located before the log control method, calculate the second target weight corresponding to the log control method according to the first target weight and the preset weight corresponding to the log control method, and determine the weight interval corresponding to the log control method according to the first target weight and the second target weight corresponding to the log control method.
[0069] In some embodiments of the present application, the target log level has a corresponding first monitoring switch and statistical period, and the determination module 401 is also used to determine whether the first monitoring switch is in the on state. If the first monitoring switch is in the on state, the storage capacity is determined based on the size of the storage space occupied by the log data of the target log level during the statistical period.
[0070] In some embodiments of the present application, the target log level has a corresponding second monitoring switch, and the determination module 401 is also used to determine whether the second monitoring switch is in the on state. If the second monitoring switch is in the on state, the storage capacity is compared with the storage threshold.
[0071] See also Figure 5, is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Figure 5 In the embodiment, the electronic device 50 includes but is not limited to: a radio frequency unit 501, a network module 502, an audio output unit 503, an input unit 504, a sensor 505, a display unit 506, a user input unit 507, an interface unit 508, a memory 509, a processor 510, and a power supply 511. It will be understood by those skilled in the art that Figure 5 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or arrange the components differently. In the embodiments of this application, the electronic device includes but is not limited to mobile phones, tablet computers, laptop computers, PDAs, vehicle-mounted terminals, servers, wearable devices, and pedometers.
[0072] Among them, the processor 510 is used to: determine the storage capacity occupied by the log data of the target application, wherein the log data belongs to the target log level, the target log level has a corresponding log control method set, and the log data is obtained through the log control method record in the log control method set; if the storage capacity is greater than the storage threshold corresponding to the target log level, then determine the target log control method from the log control method set; intercept the output of the log data corresponding to the target log control method.
[0073] The embodiment of the present application also has the same Figures 1 to 3 The same beneficial technical effects as those in the illustrated embodiments are not described in detail here.
[0074] It should be understood that in the embodiments of the present application, the RF unit 501 may be used to receive and transmit signals during information transmission or calls. Specifically, it receives downlink data from the base station and transmits it to the processor 510 for processing; in addition, it transmits uplink data to the base station. Typically, the RF unit 501 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier, a duplexer, and the like. Furthermore, the RF unit 501 may communicate with the network and other devices via a wireless communication system.
[0075] The electronic device provides users with wireless broadband Internet access through the network module 502, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0076] The audio output unit 503 can convert audio data received by the RF unit 501 or the network module 502 or stored in the memory 509 into an audio signal and output it as sound. In addition, the audio output unit 503 can also provide audio output related to a specific function performed by the electronic device 50 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 503 includes a speaker, a buzzer, a receiver, etc.
[0077] The input unit 504 is used to receive audio or video signals. The input unit 504 may include a graphics processing unit (GPU) 5041 and a microphone 5042. The graphics processor 5041 processes image data of a still picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frames can be displayed on the display unit 506. The image frames processed by the graphics processor 5041 can be stored in the memory 509 (or other storage medium) or transmitted via the radio frequency unit 501 or the network module 502. The microphone 5042 can receive sound and process such sound into audio data. The processed audio data can be converted into a format that can be sent to a mobile communication base station via the radio frequency unit 501 in the case of a telephone call mode.
[0078] The electronic device 50 also includes at least one sensor 505, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 5061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 5061 and / or the backlight when the electronic device 50 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 505 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0079] The display unit 506 is used to display information input by the user or information provided to the user. The display unit 506 may include a display panel 5061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0080] The user input unit 507 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the electronic device. Specifically, the user input unit 507 includes a touch panel 5071 and other input devices 5072. The touch panel 5071, also known as a touch screen, can collect user touch operations on or near it (such as operations performed by the user using any suitable object or accessory such as a finger, stylus, etc. on or near the touch panel 5071). The touch panel 5071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction and detects the signal caused by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device and converts it into touch point coordinates, which are then sent to the processor 510, which receives and executes the command sent by the processor 510. In addition, the touch panel 5071 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 5071, the user input unit 507 may also include other input devices 5072. Specifically, other input devices 5072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which are not described in detail here.
[0081] Furthermore, the touch panel 5071 may be overlaid on the display panel 5061. When the touch panel 5071 detects a touch operation on or near it, it transmits the information to the processor 510 to determine the type of touch event. Subsequently, the processor 510 provides corresponding visual output on the display panel 5061 according to the type of touch event. Figure 5 In the figure, the touch panel 5071 and the display panel 5061 are two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 5071 and the display panel 5061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.
[0082] The interface unit 508 is an interface for connecting external devices to the electronic device 50. For example, the external devices may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 508 may be used to receive input (e.g., data information, power, etc.) from the external device and transmit the received input to one or more elements within the electronic device 50, or may be used to transmit data between the electronic device 50 and the external device.
[0083] The memory 509 can be used to store software programs and various data. The memory 509 may primarily include a program storage area and a data storage area. The program storage area may store application programs 5091 required for at least one function (such as a sound playback function, an image playback function, etc.), an operating system 5092, etc.; the data storage area may store data generated based on the use of the electronic device 50 (such as audio data, a phone book, etc.). Furthermore, the memory 509 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device.
[0084] The processor 510 is the control center of the electronic device. It connects the various components of the electronic device 50 using various interfaces and circuits. By running or executing software programs and / or modules stored in the memory 509 and accessing data stored in the memory 509, it performs various functions of the electronic device and processes data, thereby monitoring the entire electronic device. The processor 510 may include one or more processing units; preferably, the processor 510 may integrate an application processor and a modem processor, wherein the application processor primarily processes the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into the processor 510.
[0085] The electronic device 50 may also include a power supply 511 (such as a battery) to supply power to each component. Preferably, the power supply 511 may be logically connected to the processor 510 through a power management system, thereby enabling the power management system to manage functions such as charging, discharging, and power consumption.
[0086] Preferably, an embodiment of the present application also provides an electronic device, including a processor 510, a memory 509, and a computer program stored in the memory 509 and executable on the processor 510. When the computer program is executed by the processor 510, the various processes of the above-mentioned log management method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0087] It should be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device 50. In other embodiments of the present application, the electronic device 5 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0088] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. The computer program includes program instructions. The method implemented when the program instructions are executed can refer to the log control method in the above-mentioned embodiments of the present application.
[0089] The computer-readable storage medium may be the internal memory of the electronic device described in the above embodiments, such as the hard disk or memory of the electronic device. The computer-readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash memory card, etc. equipped on the electronic device.
[0090] In some embodiments, the computer-readable storage medium may include a program storage area and a data storage area, wherein the program storage area may store an operating system, applications required for at least one function, etc.; the data storage area may store data created according to the use of the electronic device, etc.
[0091] The present application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the log management method described above in the present application.
[0092] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the module division is merely a logical function division, and other division methods may be used in actual implementation.
[0093] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed across multiple network elements. Some or all of the modules may be selected to achieve the purpose of the solution of this embodiment according to actual needs.
[0094] In addition, the functional modules in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0095] Therefore, the embodiments should be considered in all respects as illustrative and non-restrictive, and the scope of the present application is defined by the appended claims rather than the foregoing description, and all changes that come within the meaning and range of equivalents of the claims are intended to be embraced therein. Any reference to a figure in a claim should not be construed as limiting the claim to which it relates.
[0096] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in this application may also be implemented by a single unit or device through software or hardware. Terms such as first and second are used to indicate names and do not imply any particular order.
[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit the present application. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present application.
Claims
1. A log management method, characterized in that: The method comprises: Determining a storage capacity occupied by log data of a target application, wherein the log data belongs to a target log level, the target log level has a corresponding log control method set, and the log data is recorded using a log control method in the log control method set; If the storage capacity is greater than the storage threshold corresponding to the target log level, determining the target log control method from the log control method set; Intercept the output of log data corresponding to the target log control method.
2. The log management method according to claim 1, wherein: Each log control method in the log control method set corresponds to an index, and determining a target log control method from the log control method set includes: Counting the number of log control methods in the log control method set; determining a target numerical interval according to the quantity, and generating a first random number according to the target numerical interval; An index that matches the first random number is determined, and a log control method corresponding to the matching index is determined as a target log control method.
3. The log management method according to claim 1, wherein: The multiple log control methods in the log control method set are polled according to a first preset order, and determining the target log control method from the log control method set includes: A current polling position is determined according to the first preset order, and a log control method corresponding to the current polling position is determined as a target log control method.
4. The log management method according to claim 1, wherein: Determining a target log control method from the log control method set includes: Determine a weight interval corresponding to each log control method according to preset weights corresponding to multiple log control methods in the log control method set; generating a second random number within a preset numerical range; Determine the weight interval in which the second random number is located, and determine the log control method corresponding to the weight interval as the target log control method.
5. The log management method according to claim 4, wherein: The multiple log control methods in the log control method set are arranged in a second preset order; The step of determining a weight interval corresponding to each log control method according to preset weights corresponding to multiple log control methods in the log control method set includes: For each log control method, determine a first target weight corresponding to the log control method based on the preset weight corresponding to the log control method and the preset weight corresponding to the log control method before the log control method; According to the first target weight and the preset weight corresponding to the log control method, the second target weight corresponding to the log control method is calculated, and according to the first target weight and the second target weight corresponding to the log control method, the weight range corresponding to the log control method is determined.
6. The log management method according to claim 1, wherein: The target log level has a corresponding first monitoring switch and a statistical period, and determining the storage capacity occupied by the log data of the target application includes: Determining whether the first monitoring switch is in an on state; If the first monitoring switch is in the on state, the storage capacity is determined according to the size of the storage space occupied by the log data of the target log level within the statistical period.
7. The log management method according to claim 1, wherein: The target log level has a corresponding second monitoring switch, and the method further includes: Determining whether the second monitoring switch is in an on state; If the second monitoring switch is in the on state, the storage capacity is compared with the storage threshold.
8. A log management and control device, characterized in that: The log management and control device includes: a determination module, configured to determine a storage capacity occupied by log data of a target application, wherein the log data belongs to a target log level, the target log level has a corresponding log control method set, and the log data is recorded using a log control method in the log control method set; The determining module is further configured to determine a target log control method from the log control method set if the storage capacity is greater than a storage threshold corresponding to the target log level; The interception module is used to intercept the output of log data corresponding to the target log control method.
9. An electronic device, characterized in that: The electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the log control method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the log management and control method according to any one of claims 1 to 7 is implemented.