Application log output control method and device, electronic equipment and storage medium
By introducing the Log library function library into the Android system, real-time monitoring and dynamic adjustment of log output levels are achieved, solving the resource occupation and inefficiency problems caused by improper application log output, optimizing system resources and improving log analysis efficiency.
Patent Information
- Application Number
- CN202510822161.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-19
- Publication Date
- 2025-10-10
AI Technical Summary
In the existing technology, improper application log output leads to excessive system resource usage, increased log file disk usage, reduced analysis efficiency, log buffer overload and log loss, affecting system development efficiency, and lacks an effective dynamic control mechanism.
By introducing the Log library function library as a dynamic library in the Android system, the log output frequency and content length of each application can be monitored in real time, the log output level can be dynamically adjusted, thresholds can be set, and control strategies can be triggered, including increasing or closing the log output level, and current limiting measures can be adopted to avoid performance bottlenecks.
Effectively reduce the proportion of redundant logs, increase the proportion of valid logs, reduce the risk of log loss, improve system resource usage, improve log analysis efficiency, and ensure the complete output of key module logs.
Smart Images

Figure CN120763014A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of application log, and in particular to an application log output control method, an application log output control device, an electronic device, a storage medium and a vehicle. BACKGROUND
[0002] System logs are indispensable in development debugging and system operation and maintenance, but are often misused in actual application. There are recommended specifications for outputting logs, such as using correct log levels, outputting necessary and concise log content, etc. Since logs are controlled by individual application modules, there is a certain degree of human subjectivity in the selection of log levels and output content. For example, logs that should have been output using the debug level are output using a higher warn level, and debug logs are usually turned off in the release version of the software. However, since the related logs are still output in the release version of the software using the warn level, a large amount of redundant information is ultimately output. In addition, developers also have the subjective tendency to output more logs of the modules they develop, which makes it easier to locate the cause and troubleshoot problems when problems occur.
[0003] Too many output logs can cause many problems for the system, such as:
[0004] 1. High log output frequency or long log content can excessively occupy system resources such as CPU and memory. Especially for an Android-based intelligent vehicle system, the system provides services to users through a graphical interface, and logs are a basic capability of non-functional items that users do not directly perceive or have no direct effect on users. Excessive resource occupation by the log module can cause problems such as interface lag and accelerated power consumption.
[0005] 2. Too many output logs can increase the disk occupation of log files or shorten the log duration saved in limited disk space, which reduces the efficiency of disk space and is not conducive to problem investigation and positioning.
[0006] 3. Redundant logs can reduce the efficiency of log analysis and reduce the proportion of effective content in log content.
[0007] 4. Excessive log output by some modules can crowd out the log output of other application modules, affecting the overall development efficiency of the system.
[0008] 5. High output frequency can cause the system log buffer to be overloaded, resulting in log loss.
[0009] To address these issues, actual development requires regular manual log analysis and monitoring of log service modules to passively monitor log usage. This is time-consuming and labor-intensive, and issues can only be addressed after they occur. Log-related issues often recur. After a problem is identified and rectified in one module, similar issues may arise in other modules. Or, in the same module, the introduction of new functional code may cause excessive log output. All of these factors negatively impact development efficiency.
[0010] Therefore, a solution for application log output control is needed to dynamically control log output. Summary of the Invention
[0011] The purpose of the present invention is to provide an application log output control method, an application log output control device, an electronic device, a storage medium, and a vehicle, which at least solve the problem of dynamically controlling the log output level, the problem of dynamically controlling the log output speed limit, and the problem of avoiding log service performance bottlenecks.
[0012] The present invention provides the following solutions:
[0013] According to one aspect of the present invention, a method for controlling application log output is provided, the method comprising:
[0014] There are multiple applications in the Android system. Each application uses the log service to output its own log content.
[0015] Among them, according to the log service log service, the log content is stored in the log files log files;
[0016] Each application accesses the log service through the Log library function library and sends the pre-output logs to the log service.
[0017] Among them, the Log library function library is a dynamic library and is loaded into each application process separately;
[0018] Since the Log library function library is a dynamic library, it is loaded into each application process separately. The Log library function library consumes computing resources in each application process.
[0019] Based on the computing resources consumed by the Log library function library within each application process, add monitoring logic to the Log library function library to avoid log service performance bottlenecks.
[0020] Furthermore, the monitoring logic added to the Log library function library to avoid log service performance bottlenecks includes:
[0021] Statistics on the log output frequency and log content length of each application;
[0022] Set log output monitoring indicator thresholds;
[0023] The log output monitoring indicator thresholds include the number of output lines and byte length in a preset period;
[0024] The log control strategy is triggered based on the statistics of the log output frequency and log content length of each application, as well as the set log output monitoring indicator threshold.
[0025] Furthermore, the trigger log control strategy includes:
[0026] Get the log output level setting;
[0027] The log output level settings include, from low to high, Verbose, Debug, Info, Warn and Error levels;
[0028] Based on the current log output frequency and log content length of each application, determine whether the log output level is Verbose, Debug, Info, or Warn.
[0029] If yes, the log output level is increased by one level.
[0030] Furthermore, judging whether the log output level is at the Verbose, Debug, Info, or Warn level based on the current log output frequency and log content length of each application includes:
[0031] If not, determine whether the log output level is at the Error level based on the current log output frequency and log content length of each application;
[0032] If yes, then turn off logging output.
[0033] Furthermore, the trigger log control strategy also includes:
[0034] Increase the log output level by one level until log output is closed and current limiting measures are initiated;
[0035] The initiation of the current limiting measure includes determining whether the log output enhancement level of the application under the log control policy is higher than the log output level set illegally by the application;
[0036] If yes, then the log output is output according to the log output level upgrade of the application under the log control policy, and the log output of the log output level set illegally by the application is stopped;
[0037] If not, log output according to the log output level set for the application violation.
[0038] Furthermore, the trigger log control strategy also includes:
[0039] Set the execution window period for flow control measures;
[0040] The log output level of the application under the log control policy is increased by one level, and the execution window of the current limiting measure is timed;
[0041] Determine whether the measure execution window timing has expired;
[0042] If,completed, the log output applied under the log control policy will be returned to one level;
[0043] This includes, after the log output is closed, the log output is resumed after the action execution window expires.
[0044] According to two aspects of the present invention, there is provided an application log output control device, the application log output control device comprising:
[0045] The log output module is used to output the log content of each application through the log service based on the existence of multiple applications in the Android system;
[0046] The log file module is used to store log contents in logfiles according to the log service;
[0047] The log sending module is used by each application to access the log service through the Log library function library and send the pre-output logs to the log service;
[0048] The log loading module is used to load the Log library function library into each application process as a dynamic library.
[0049] The process loss module is used to load the Log library function library into each application process according to the dynamic library. The Log library function library consumes computing resources in each application process.
[0050] The monitoring logic module is used for consuming computing resources in each application process according to a Log library function library, and monitoring logic is added in the Log library function library to avoid performance bottleneck of a log service.
[0051] According to the three aspects of the application, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus.
[0052] The memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the application log output control method.
[0053] According to the four aspects of the application, a computer readable storage medium is provided, which stores a computer program executable by an electronic device, and when the computer program runs on the electronic device, the electronic device executes the steps of the application log output control method.
[0054] According to the five aspects of the application, a vehicle is provided, comprising:
[0055] The electronic device is used to implement the steps of the application log output control method.
[0056] The processor runs a program, and when the program runs, the steps of the application log output control method are executed on the data output from the electronic device.
[0057] The storage medium is used to store a program, and when the program runs, the steps of the application log output control method are executed on the data output from the electronic device.
[0058] Through the above scheme, the following beneficial technical effects are obtained:
[0059] The application reduces the proportion of redundant logs and improves the proportion of effective logs through dynamic control of the log output level of the application.
[0060] The application improves the cache area overload and reduces the risk of log loss through flow control.
[0061] The application avoids manufacturing the performance bottleneck of the log service by adding monitoring logic in the Log library function library. BRIEF DESCRIPTION OF DRAWINGS
[0062] Figure 1 It is a flowchart of an application log output control method provided by one or more embodiments of the application.
[0063] Figure 2This is a structural diagram of an application log output control device provided by one or more embodiments of the present invention.
[0064] Figure 3 It is a schematic diagram of log calling according to a specific embodiment of the present invention.
[0065] Figure 4 It is a schematic diagram of the algorithm flow of a specific embodiment of the present invention.
[0066] Figure 5 It is a schematic diagram of dynamic log control according to a specific embodiment of the present invention.
[0067] Figure 6 This is a structural block diagram of an electronic device according to one or more embodiments of the present invention, and an application log output control method. DETAILED DESCRIPTION
[0068] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0069] Figure 1 This is a flowchart of an application log output control method provided by one or more embodiments of the present invention.
[0070] like Figure 1 The application log output control method shown includes:
[0071] Step S1: There are multiple applications in the Android system, and each application outputs its own log content through the log service;
[0072] Step S2: storing the log content in log files according to the log service;
[0073] Step S3: Each application accesses the log service through the Log library function library and sends the pre-output log to the log service;
[0074] Step S4: Log library function library is a dynamic library and is loaded into each application process respectively;
[0075] Step S5: Since the Log library function library is a dynamic library, it is loaded into each application process respectively. The Log library function library consumes computing resources in each application process.
[0076] Step S6: Based on the computing resources consumed by the Log library in each application process, monitoring logic is added to the Log library to avoid log service performance bottlenecks.
[0077] Specifically, in one embodiment, Figure 4 The logging calls shown include:
[0078] Multiple applications in the system output their own log content through the log service. The log service then stores the log content persistently in log files.
[0079] Each application accesses the log service through the log library function library and sends the logs to be output to the log service.
[0080] The log library is a dynamic library that is loaded into each application process. The computing resources consumed by the log library are local to each application process, not concentrated in the log service. Adding monitoring logic to the log library will not cause the log service to become a performance bottleneck.
[0081] In this embodiment, monitoring logic is added to the Log library to avoid log service performance bottlenecks, including:
[0082] Statistics on the log output frequency and log content length of each application;
[0083] Set log output monitoring indicator thresholds;
[0084] Log output monitoring indicator thresholds include the number of output lines and byte length in the preset period;
[0085] The log control strategy is triggered based on the statistics of the log output frequency and log content length of each application, as well as the set log output monitoring indicator threshold.
[0086] In this embodiment, triggering the log control strategy includes:
[0087] Get the log output level setting;
[0088] The log output level settings include, from low to high, Verbose, Debug, Info, Warn and Error levels;
[0089] Based on the current log output frequency and log content length of each application, determine whether the log output level is Verbose, Debug, Info, or Warn.
[0090] If yes, the log output level is increased by one level.
[0091] In this embodiment, based on the current log output frequency and log content length of each application, determining whether the log output level is Verbose, Debug, Info, or Warn includes:
[0092] If not, determine whether the log output level is at the Error level based on the current log output frequency and log content length of each application;
[0093] If yes, then turn off logging output.
[0094] In this embodiment, triggering the log control strategy also includes:
[0095] Increase the log output level by one level until log output is closed and current limiting measures are initiated;
[0096] Initiating the current limiting measure includes determining whether the log output enhancement level of the application under the log control policy is higher than the log output level set by the application in violation of the rules;
[0097] If yes, then the log output is output according to the log output level upgrade of the application under the log control policy, and the log output of the log output level set illegally by the application is stopped;
[0098] If not, log output according to the log output level set for the application violation.
[0099] In this embodiment, triggering the log control strategy also includes:
[0100] Set the execution window period for flow control measures;
[0101] The log output level of the application under the log control policy is increased by one level, and the execution window of the current limiting measure is timed;
[0102] Determine whether the measure execution window timing has expired;
[0103] If,completed, the log output applied under the log control policy will be returned to one level;
[0104] This includes, after the log output is closed, the log output is resumed after the action execution window expires.
[0105] Specifically, in one embodiment, Figure 4 The algorithm flow shown includes:
[0106] Add monitoring logic to the log library module to count metrics such as the output frequency and log content length of each application module, such as the number of log lines output per minute and the number of bytes in the log content.
[0107] Set the log output monitoring indicator threshold, including the number of log output lines and byte length per minute. When the actual monitored indicators exceed the set threshold, the following control strategy is triggered.
[0108] Configure log control policies and take corresponding measures such as limiting or shutting down logs based on the frequency of each process log output.
[0109] 1. To facilitate the description of the process, Figure 5 The dynamic log control shown here assumes a log output limit of 50 lines per second (the specific limit needs to be adjusted based on the actual system, hardware performance, and the specific conditions of the system's application modules). When application log output exceeds the limit (for example, the actual output frequency is 100 lines per second), log control measures are implemented.
[0110] 2. If the current process log output level is one of the following: Verbose, Debug, Info, or Warn, the log output level is raised by one level. For example, if the current level is Debug (all logs at Debug and above are output), the log level is raised to Info, and Debug-level logs are no longer output, reducing the frequency of log output. If the current log level is Warn, the log level is raised to Error.
[0111] 3. If the current log level is already Error, close the log output.
[0112] 4. The above measures may continuously trigger and escalate the throttling measures. When a process's log output exceeds the limit, the log level is raised. In the following statistical week, if the limit is exceeded again (upper limit of 50 lines / second), the log level will continue to increase until log output is shut down. For example, some applications use the Info level to output debug logs (illegible use of log levels). When the log level is increased from Verbose to Debug, it will not affect the application's Info level log output and will not have the effect of reducing the frequency. The log level needs to be increased again until it reaches the Warn level, at which point Info level logs will be filtered out, initiating the effect of reducing the frequency of log output.
[0113] 5. When the log output limit is exceeded, the frequency reduction measure implemented is a temporary measure, which lasts for 10 minutes at a time, after which the log level is rolled back to the previous level. If log output is disabled, it is enabled to output Error-level logs. This measure is intended to avoid the impact of short-term output peaks. Occasional exceeding the limit triggers a frequency reduction, reduces log output, and affects development and debugging work.
[0114] 6. If a given level of log throttling is triggered multiple times (e.g., 10 or more times (not necessarily consecutively)) during a vehicle power-up cycle (from start to shutdown), the system will not revert to a lower log level. If log output is disabled 10 times, the corresponding process log will be completely disabled for the entire power-up cycle and will not be re-enabled. Repeated triggering of the throttling mechanism indicates that the corresponding process is consistently exceeding its output limit under unrestricted or low-level throttling. Therefore, fixed throttling and throttling are implemented to minimize the impact on system performance caused by repeated adjustments to the log level.
[0115] Figure 2 This is a structural diagram of an application log output control device provided by one or more embodiments of the present invention.
[0116] like Figure 2 The application log output control device shown includes: a log output module, a log file module, a log sending module, a log loading module, a process loss module, and a monitoring logic module;
[0117] The log output module is used to output the log content of each application through the log service based on the existence of multiple applications in the Android system;
[0118] The log file module is used to store log contents in logfiles according to the log service;
[0119] The log sending module is used by each application to access the log service through the Log library function library and send the pre-output logs to the log service;
[0120] The log loading module is used to load the Log library function library into each application process as a dynamic library.
[0121] The process loss module is used to load the Log library function library into each application process according to the dynamic library. The Log library function library consumes computing resources in each application process.
[0122] The monitoring logic module is used to consume computing resources within each application process based on the Log library function library. It adds monitoring logic to the Log library function library to avoid log service performance bottlenecks.
[0123] It is worth noting that although the present system only discloses a log output module, a log file module, a log sending module, a log loading module, a process loss module, and a monitoring logic module, it does not mean that the present device is limited to the above-mentioned basic functional modules. Rather, what the present invention wants to express is that, based on the above-mentioned basic functional modules, those skilled in the art can arbitrarily add one or more functional modules in combination with the existing technology to form an infinite number of embodiments or technical solutions. In other words, the present system is open rather than closed. Just because the present embodiment only discloses individual basic functional modules, it cannot be considered that the scope of protection of the claims of the present invention is limited to the above-mentioned basic functional modules.
[0124] Figure 3 It is a schematic diagram of log calling according to a specific embodiment of the present invention.
[0125] Figure 4 It is a schematic diagram of the algorithm flow of a specific embodiment of the present invention.
[0126] Figure 5 It is a schematic diagram of dynamic log control according to a specific embodiment of the present invention.
[0127] In a specific embodiment, Figure 4 The algorithm further includes a whitelist mechanism. For example, the names of critical system processes can be added to the whitelist. The algorithm then skips monitoring of these processes, ensuring that logs from critical modules are fully output and that the algorithm does not throttle traffic. The whitelist can use either exact matching of full process names or fuzzy matching of keywords.
[0128] A blacklist mechanism forcibly disables logging for listed processes based on the blacklist configuration. This mechanism can be used in specific application scenarios such as performance testing. Blacklists can use exact matching of full process names or fuzzy matching of keywords.
[0129] Monitoring records: For processes that exceed log output limits, relevant information is saved in a monitoring log file for persistent storage. This information includes the process name, process log output frequency, log frequency upper threshold, trigger time, throttling measures, or recovery actions. Based on monitoring records, targeted optimization or rectification of systems and applications can be carried out.
[0130] In a specific embodiment, Figure 3 The log call shown, such as Figure 5In the algorithm described above, if log output exceeds the upper limit, log throttling or logging disabling measures are implemented based on the log output level. For example, if the current log level is Error, log output is disabled. For example, if an application uses the Info level for debug log output (illegible log level usage), raising the log level from Verbose to Debug will not affect the application's Info level log output and will not reduce the log output. The log level needs to be increased further until it reaches Warn, at which point Info level logs are filtered out and the log output reduction effect begins. For example, if an application uses the Verbose level for debug log output (compliant log level usage), raising the log level from Verbose to Debug will reduce the log output.
[0131] In another specific embodiment, the log dynamic control algorithm is applied to the vehicle control SDK module:
[0132] Vehicle control signals (VCS signals) are used by the in-vehicle system software and the vehicle hardware to transmit data and exchange operations, such as controlling window openings and closing, air conditioning, and obtaining information about the vehicle's gear position and speed. In the vehicle's cockpit system, the hardware receives VCS signals on the signal bus. The system software, through the driver, reads the signal values and forwards and encapsulates them through multiple modules to provide upper-layer applications for use. The VCS SDK provides an interface for uploading applications. A typical vehicle contains 1,000 to 2,000 VCS signals, some of which are sent periodically (at intervals of tens of milliseconds). In actual vehicle systems, a large number of signals are constantly being sent and received, resulting in a high communication load. Each signal is independent; for example, the VCS signal and the seat adjustment signal are unrelated. To debug and troubleshoot issues, the VCS SDK module generates logs for each signal, often requiring multiple entries per signal, especially for complex signals.
[0133] During actual vehicle operation, it was found that the vehicle control SDK, responsible for transmitting a large number of signals, consumes a large amount of system resources. This, coupled with the large amount of log output, further increases resource consumption. In actual testing, without applying the dynamic log control algorithm, the vehicle control SDK occupied an average of 40% of the CPU (single-core) and output 400,000 log lines per hour. After applying the dynamic log control algorithm proposed in this patent, both log output and CPU usage were significantly reduced, with the average CPU usage reduced to around 20% (single-core) and log output reduced to less than 10 lines per second.
[0134] Because the module's log output frequency exceeds 100 lines per second, far exceeding the preset 50 lines per second, the algorithm is triggered to dynamically adjust the log output, raising the current log output level from the default Debug level to the Info level. However, the vehicle control SDK's logs are mostly output at the Info level, resulting in output still exceeding the standard even after increasing to the Info level, triggering a further increase in the log level to the Warn level. Warn-level logs are only output in rare cases, resulting in a significant reduction in the final log output volume. Each time the log level falls back to the Info level, it triggers flow control and throttling. After multiple triggering of the algorithm flow control, it is finally fixed at the Warn level, resulting in no logs below the Warn level being output by the vehicle control SDK module, which has the effect of improving the efficiency of high-frequency log output and reducing resource usage.
[0135] The above examples demonstrate the feasibility and effectiveness of the proposed solution. They demonstrate a passive detection and avoidance mechanism for improper log usage, serving as a last-ditch effort to ensure the system isn't crippled by abnormal logs. Furthermore, when problematic modules are discovered, code modifications are promptly made to address the issues, optimize program performance, and ensure that logs continue to function as intended.
[0136] This application achieves: automatic monitoring of log output frequency, dynamic adjustment of log output, including adjusting log output level or shutting down log output, etc., in order to achieve the purpose of regulating system log resource usage.
[0137] Adjustment is carried out in units of processes, with fine adjustment force, which can effectively control the process of exceeding the output standard; it has no effect on the process of normal output.
[0138] The monitoring and rate limiting logic are executed in their respective application processes, which does not put pressure on the core logging service and become a performance bottleneck.
[0139] Based on the real-time log output volume of the process, the frequency of log output can be dynamically reduced or restored. This two-way adjustment provides flexible strategies and is convenient for development and debugging. This avoids the inconvenience caused by one-way adjustment (which can only reduce the frequency).
[0140] A multi-level adjustment mechanism, rather than a one-size-fits-all approach to shutting down log output, can dynamically control the log output volume of a process within a reasonable range. While reducing the log frequency, it can ensure that the process outputs as much log content as possible, which is conducive to debugging and locating problems.
[0141] Through the system whitelist and blacklist mechanism, the algorithm is made more flexible, reducing intervention in key core processes in the whitelist, and in specific scenarios, the log output of the blacklist process can be completely blacklisted.
[0142] Monitoring records will save control record information for subsequent system evaluation and optimization and improvement.
[0143] In another specific embodiment, the following background information is provided:
[0144] System logs play a crucial role in system development. They not only provide developers and operations personnel with a deep understanding of system behavior and performance, but also provide powerful support for development debugging, performance optimization, security auditing, and other areas. System logs record key system operation events, such as system startup, error occurrences, and resource usage, helping developers understand and maintain system health from multiple perspectives. System logs are an essential tool for debugging system issues. Errors, system crashes, or abnormal behavior that occur during development can often be diagnosed and located using log information. System logs record all error information, including program errors, exception handling, and crash stack traces. Developers can quickly locate the problem's location and context from these logs. System logs also record system resource usage, including CPU, memory, disk, and network load. This information helps developers monitor performance during development and runtime, identifying performance bottlenecks and optimizing them.
[0145] Developers typically use logs by outputting them through the system's logging API, debugging, and running programs, with the logs persisted in log files. Logs provide detailed information about program runtime, helping developers quickly locate issues, trace code execution paths, capture errors, and analyze system performance. During debugging, by properly configuring log levels and structuring log output, developers can more efficiently identify and fix problems.
[0146] In the Android system, logging and management are essential tools for developing and debugging applications. The system provides a dedicated logging API to help developers record and output debugging information, error messages, performance data, and more. The common logging API, based on the Log class and provided by the Android SDK, allows developers to record log information at different levels, including debug, information, warning, and error. Log information is typically output to Logcat and can be viewed using Android Studio, the adb tool, or the device's Logcat.
[0147] As shown in Table 1, the Log class provides multiple log levels to help developers record logs according to different levels of importance.
[0148] Table 1
[0149] Log Level Purpose Description Applicable Scenario Verbose Most detailed log information, used for detailed details during development Development stage, detailed tracking of code execution Debug Debug information, helps developers understand program execution flow Debugging stage, tracking program execution and variable values Info Meaningful information during operation, non-error or warning information Meaningful information in normal operation (such as operation success, etc.) Warn Warning information, potential problems but do not affect operation Operations that may cause problems or non-critical errors Error Severe error information, errors that need to be fixed immediately Program errors, crashes, captured in exception handling
[0150] During the development process, you can use logs of different levels to capture application status and errors. When releasing a version, you can configure the log level to filter out unnecessary detailed logs, such as Verbose and Debug, while retaining more important log information such as Warn and Error.
[0151] Figure 6 This is a structural block diagram of an electronic device according to one or more embodiments of the present invention, and an application log output control method.
[0152] like Figure 6 As shown, the present application provides an electronic device, comprising: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0153] A computer program is stored in the memory. When the computer program is executed by the processor, the processor executes the steps of an application log output control method.
[0154] The present application also provides a computer-readable storage medium storing a computer program executable by an electronic device. When the computer program runs on the electronic device, the electronic device executes the steps of an application log output control method.
[0155] The present application also provides a vehicle, comprising:
[0156] An electronic device, configured to apply the steps of the log output control method;
[0157] a processor, the processor running a program, and executing the steps of the application log output control method based on data output by the electronic device when the program is running;
[0158] The storage medium is used to store a program, and when the program is running, the program executes the steps of the application log output control method for data output from the electronic device.
[0159] The communication bus mentioned in the electronic device mentioned above may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0160] The electronic device includes a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and memory. The operating system can be any one or more computer operating systems that control electronic devices through processes, such as the Linux operating system, the Unix operating system, the Android operating system, the iOS operating system, or the Windows operating system. In the embodiments of the present invention, the electronic device can be a handheld device such as a smartphone or a tablet computer, or an electronic device such as a desktop computer or a portable computer, which is not particularly limited in the embodiments of the present invention.
[0161] The execution subject of the electronic device control in the embodiment of the present invention can be an electronic device, or a functional module in the electronic device that can call a program and execute the program. The electronic device can obtain the firmware corresponding to the storage medium. The firmware corresponding to the storage medium is provided by the supplier. The firmware corresponding to different storage media can be the same or different, and is not limited here. After the electronic device obtains the firmware corresponding to the storage medium, it can write the firmware corresponding to the storage medium into the storage medium, specifically, burn the firmware corresponding to the storage medium into the storage medium. The process of burning the firmware into the storage medium can be implemented using existing technology and will not be described in detail in the embodiment of the present invention.
[0162] The electronic device can also obtain a reset command corresponding to the storage medium. The reset command corresponding to the storage medium is provided by the supplier. The reset commands corresponding to different storage media can be the same or different, and are not limited here.
[0163] In this case, the storage medium of the electronic device is a storage medium in which the corresponding firmware is written. The electronic device can respond to the reset command corresponding to the storage medium in which the corresponding firmware is written, thereby resetting the storage medium in which the corresponding firmware is written according to the reset command corresponding to the storage medium. The process of resetting the storage medium according to the reset command can be implemented in the existing technology and will not be described in detail in the embodiments of the present invention.
[0164] For the convenience of description, the above devices are described as various units and modules according to their functions. Of course, when implementing this application, the functions of each unit and module can be implemented in the same or multiple software and / or hardware.
[0165] Those skilled in the art will understand that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by those skilled in the art in the art to which the present invention pertains. It should also be understood that terms such as those defined in common dictionaries should be understood to have meanings consistent with those in the context of the prior art and, unless specifically defined, will not be interpreted in an idealized or overly formal sense.
[0166] For simplicity of description, the method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because certain steps can be performed in other orders or simultaneously according to the embodiments of the present invention. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0167] Through the description of the above embodiments, it can be seen that those skilled in the art can clearly understand that the present application can be implemented by means of software plus the necessary general hardware platform. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments of the present application or certain parts of the embodiments.
[0168] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for controlling application log output, characterized in that: The application log output control method includes: There are multiple applications in the Android system. Each application uses the log service to output its own log content. Among them, according to the log service log service, the log content is stored in the log files log files; Each application accesses the log service through the Log library function library and sends the pre-output logs to the log service. Among them, the Log library function library is a dynamic library and is loaded into each application process separately; Since the Log library function library is a dynamic library, it is loaded into each application process separately. The Log library function library consumes computing resources in each application process. Based on the computing resources consumed by the Log library function library within each application process, add monitoring logic to the Log library function library to avoid log service performance bottlenecks.
2. The application log output control method according to claim 1, characterized in that: Adding monitoring logic to the Log library to avoid log service performance bottlenecks includes: Statistics on the log output frequency and log content length of each application; Set log output monitoring indicator thresholds; The log output monitoring indicator thresholds include the number of output lines and byte length in a preset period; The log control strategy is triggered based on the statistics of the log output frequency and log content length of each application, as well as the set log output monitoring indicator threshold.
3. The application log output control method according to claim 2, characterized in that: The trigger log control strategy includes: Get the log output level setting; The log output level settings include, from low to high, Verbose, Debug, Info, Warn and Error levels; Based on the current log output frequency and log content length of each application, determine whether the log output level is Verbose, Debug, Info, or Warn. If yes, the log output level is increased by one level.
4. The application log output control method according to claim 3, characterized in that: The process of determining whether the log output level is Verbose, Debug, Info, or Warn based on the current log output frequency and log content length of each application includes: If not, determine whether the log output level is at the Error level based on the current log output frequency and log content length of each application; If yes, then turn off logging output.
5. The application log output control method according to claim 4, characterized in that: The trigger log control strategy also includes: Increase the log output level by one level until log output is closed and current limiting measures are initiated; The initiation of the current limiting measure includes determining whether the log output enhancement level of the application under the log control policy is higher than the log output level set illegally by the application; If yes, then the log output is output according to the log output level upgrade of the application under the log control policy, and the log output of the log output level set illegally by the application is stopped; If not, log output according to the log output level set for the application violation.
6. The application log output control method according to claim 5, characterized in that: The trigger log control strategy also includes: Set the execution window period for flow control measures; The log output level of the application under the log control policy is increased by one level, and the execution window of the current limiting measure is timed; Determine whether the measure execution window timing has expired; If,completed, the log output applied under the log control policy will be returned to one level; This includes, after the log output is closed, the log output is resumed after the action execution window expires.
7. An application log output control device, characterized in that: The application log output control device includes: The log output module is used to output the log content of each application through the log service based on the existence of multiple applications in the Android system; The log file module is used to store log contents in logfiles according to the log service; The log sending module is used by each application to access the log service through the Log library function library and send the pre-output logs to the log service; The log loading module is used to load the Log library function library into each application process as a dynamic library. The process loss module is used to load the Log library function library into each application process according to the dynamic library. The Log library function library consumes computing resources in each application process. The monitoring logic module is used to consume computing resources within each application process based on the Log library function library. It adds monitoring logic to the Log library function library to avoid log service performance bottlenecks.
8. An electronic device, characterized in that: include: A processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus; A computer program is stored in the memory. When the computer program is executed by the processor, the processor executes the steps of the application log output control method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that A computer program executable by an electronic device is stored, and when the computer program is run on the electronic device, the electronic device executes the steps of the application log output control method according to any one of claims 1 to 7.
10. A vehicle, characterized in that: include: An electronic device, configured to implement the steps of the application log output control method according to any one of claims 1 to 7; a processor, wherein the processor runs a program, and when the program runs, the steps of the application log output control method according to any one of claims 1 to 7 are executed based on the data output by the electronic device; A storage medium is used to store a program, and when the program is running, it executes the steps of the application log output control method according to any one of claims 1 to 7 for data output from an electronic device.