Application log extraction method and device, electronic equipment and readable medium

By running background threads in mobile devices to obtain application logs in real time and extracting logs when application exceptions, the problem of difficulty in extracting application logs in mobile devices is solved, realizing timely and convenient log acquisition and analysis.

CN119739587APending Publication Date: 2025-04-01GREE ELECTRIC APPLIANCE INC OF ZHUHAI +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411628873.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2025-04-01

AI Technical Summary

Technical Problem

Difficulty in extracting application logs in mobile devices, especially in the event of application abnormality, which leads to difficulties in subsequent analysis.

Method used

Run background threads in mobile devices, get the application's logs in real time, and respond to the tester's log extraction instructions when the application is abnormal, extracting the retrieved logs.

Benefits of technology

It realizes convenient and timely acquisition of application logs in mobile devices, supports real-time acquisition and log extraction in abnormal situations, and simplifies application exception analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119739587A_ABST
    Figure CN119739587A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an application log extraction method and device, electronic equipment and a readable medium. The method comprises the following steps: if the application program is started, running a background thread in the mobile equipment; acquiring a log of the application program through the background thread; and if the application program is abnormal, in response to a log extraction instruction sent to the mobile device by a tester, extracting the obtained log of the application program from the mobile device. Therefore, the application program log can be captured in the mobile equipment. According to the method, the application program log is collected in real time in the running process of the application program, and if the application program is abnormal, a tester can send a log extraction instruction to the mobile equipment in time to obtain the collected application program log. Logs of the application program are extracted timely, accurately and conveniently, assistance of other equipment is not needed, and research and development personnel can analyze application program abnormity conveniently.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a method for extracting an application log, a device for extracting an application log, an electronic device, and a computer-readable medium. Background Art

[0002] Generally speaking, during the application testing process of mobile devices, there may be occasional application anomalies. If the relevant log information of these occasional application anomalies cannot be collected in time, it is easy to make the subsequent analysis of application anomalies more difficult.

[0003] Traditional collection of application logs from mobile devices usually requires the assistance of a computer. However, due to reasons such as device crashes and log recording delays, collecting application logs from mobile devices through a computer may not be able to obtain the relevant logs when an application exception occurs, resulting in the inability to analyze the application exception well. Summary of the invention

[0004] The embodiment of the present invention provides a method, device, electronic device and computer-readable storage medium for extracting application logs, so as to solve the problem of difficulty in extracting application logs in mobile devices.

[0005] An embodiment of the present invention discloses a method for extracting an application log, which is applied to a mobile device, wherein the mobile device has an application installed therein, and the method comprises:

[0006] If the application is started, a background thread is run in the mobile device;

[0007] Obtaining the log of the application program through the background thread;

[0008] If an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the obtained log of the application is extracted in the mobile device.

[0009] Optionally, the step of obtaining the log of the application through the background thread includes:

[0010] After the logs of the application program acquired historically are cleared through the background thread, the logs of the application program are started to be acquired.

[0011] Optionally, the step of obtaining the log of the application through the background thread includes:

[0012] In response to a tag filtering instruction issued by a tester, a target tag is determined from among preset tags;

[0013] The log containing the target tag in the application is obtained through the background thread.

[0014] Optionally, if an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the step of extracting the acquired log of the application in the mobile device includes:

[0015] If the application program exits abnormally, determining that an abnormality occurs in the application program;

[0016] In response to a log extraction instruction issued by a tester to the mobile device, the obtained log of the application is extracted in the mobile device.

[0017] Optionally, the method further comprises:

[0018] Running a daemon process in the mobile device;

[0019] The daemon process is used to monitor whether the application program exits abnormally.

[0020] Optionally, if the application program exits abnormally, the step of determining that the application program is abnormal includes:

[0021] If a notification of abnormal exit of the application program sent by the daemon process is received, it is determined that an abnormality occurs in the application program.

[0022] Optionally, in response to a log extraction instruction issued by a tester to the mobile device, the step of extracting the acquired log of the application in the mobile device includes:

[0023] In response to the tester's notification of abnormal exit of the application, a log extraction instruction is issued to the mobile device, and the obtained log of the application is extracted through a background process in the mobile device.

[0024] Optionally, if an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the step of extracting the acquired log of the application in the mobile device includes:

[0025] If the application state is abnormal, determining that an abnormality occurs in the application;

[0026] In response to a log extraction instruction issued by a tester to the mobile device, the obtained log of the application is extracted in the mobile device.

[0027] Optionally, in response to a log extraction instruction issued by a tester to the mobile device, the step of extracting the acquired log of the application in the mobile device includes:

[0028] In response to a log extraction instruction issued by a tester by touching a log extraction control preset in the application, the acquired log of the application is extracted through a background process in the mobile device.

[0029] An embodiment of the present invention further provides a device for extracting an application log, which is applied to a mobile device, wherein the mobile device has an application installed therein, and the device comprises:

[0030] A background thread running module, used for running a background thread in the mobile device if the application is started;

[0031] A log extraction module, used to obtain the log of the application through the background thread;

[0032] The log acquisition module is used to extract the acquired log of the application program in the mobile device in response to a log extraction instruction issued by a tester to the mobile device if an exception occurs in the application program.

[0033] Optionally, the log extraction module includes:

[0034] The log extraction submodule is used to start acquiring the log of the application program after clearing the log of the application program acquired historically through the background thread.

[0035] Optionally, the log extraction module includes:

[0036] The tag determination submodule is used to determine the target tag among the preset tags in response to the tag filtering instruction issued by the tester;

[0037] The tag filtering submodule is used to obtain the log containing the target tag in the application through the background thread.

[0038] Optionally, the log acquisition module includes:

[0039] A first exception identification submodule, used to determine that an exception occurs in the application program if the application program exits abnormally;

[0040] The first log sub-acquisition module is used to extract the acquired log of the application program in the mobile device in response to a log extraction instruction issued by a tester to the mobile device.

[0041] Optionally, the device further comprises:

[0042] A daemon process running module, used for running a daemon process in the mobile device;

[0043] The daemon process monitoring module is used to monitor whether the application program exits abnormally through the daemon process.

[0044] Optionally, the first abnormality identification submodule includes:

[0045] The notification receiving unit is used to determine that an abnormality occurs in the application upon receiving an abnormal application exit notification sent by the daemon process.

[0046] Optionally, the first log sub-obtaining module includes:

[0047] The first log acquisition unit is used to respond to the tester's abnormal exit notification of the application and send a log extraction instruction to the mobile device, and extract the acquired log of the application through the background process in the mobile device.

[0048] Optionally, the log acquisition module includes:

[0049] A second abnormality identification submodule, used for determining that an abnormality occurs in the application if the application state is abnormal;

[0050] The second log sub-acquisition module is used to extract the acquired log of the application program in the mobile device in response to a log extraction instruction issued by a tester to the mobile device.

[0051] Optionally, the second log sub-obtaining module includes:

[0052] The second log acquisition unit is used to extract the acquired log of the application program through the background process in the mobile device in response to the log extraction instruction issued by the tester by touching the log extraction control preset in the application program.

[0053] The embodiment of the present invention further discloses 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;

[0054] The memory is used to store computer programs;

[0055] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.

[0056] The embodiment of the present invention further discloses one or more computer-readable media on which instructions are stored. When executed by one or more processors, the processors are enabled to execute the method described in the embodiment of the present invention.

[0057] The embodiments of the present invention include the following advantages:

[0058] According to the method for extracting application logs provided by the embodiment of the present invention, if the application is started, a background thread is run in the mobile device; the log of the application is obtained through the background thread; if an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the obtained log of the application is extracted in the mobile device. In this way, it is possible to capture application logs in a mobile device, and to collect application logs in real time during the operation of the application. If the application is abnormal, the tester can issue a log extraction instruction to the mobile device in time to obtain the collected application logs. The application log extraction is timely and accurate, and the extraction is convenient, without the assistance of other equipment, which is convenient for R&D personnel to analyze application anomalies. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] Figure 1 is a flowchart of a method for extracting application logs provided in an embodiment of the present invention;

[0060] Figure 2 It is a flowchart of a method for extracting application logs provided in an embodiment of the present invention;

[0061] Figure 3 is a structural block diagram of an application log extraction device provided in an embodiment of the present invention;

[0062] Figure 4 is a block diagram of an electronic device provided in an embodiment of the present invention;

[0063] Figure 5 is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0064] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0065] Reference Figure 1 , shows a flowchart of the steps of an application log extraction method provided in an embodiment of the present invention, which is applied to a mobile device in which an application is installed.

[0066] For example, the traditional method of collecting application logs of mobile devices with the assistance of a computer is usually to use the ADB (Android Debug Bridge) tool. ADB is a command line tool in the Android Development Kit (SDK) that allows developers to communicate with Android devices. Through ADB, it is possible to extract application logs from Android devices.

[0067] During use, you need to connect your Android device to your computer using a USB cable and make sure that developer mode and USB debugging are enabled on the device. Open a command line tool (such as the command prompt or PowerShell in Windows, the terminal in macOS and Linux), and navigate to the directory where the ADB tool is located. After confirming that the device is connected, start capturing logs and then output the logs to a file.

[0068] In a specific implementation, the embodiments of the present invention may be applied to mobile devices. Mobile devices generally refer to electronic devices that are portable, support wireless communication, and are generally battery-powered. Mobile devices generally include smart phones, tablet computers, smart watches, portable media players, handheld game consoles, etc.

[0069] Generally speaking, mobile devices can usually run an operating system suitable for mobile devices. For example, Android system, iOS (iPhone Operating System, Apple mobile phone operating system) system, etc. The operating system suitable for mobile devices is usually different from the operating system of large devices such as desktop computers and laptops. Usually, the operating system of large devices such as desktop computers and laptops can be a Windows operating system. Therefore, the traditional method of collecting application logs of mobile devices with the assistance of computers cannot be used directly in mobile devices.

[0070] In the embodiment of the present invention, in order to more conveniently and accurately obtain the application log when an application is abnormal, a method for obtaining the application log can be added to the mobile device to realize the capture of the application log in the mobile device, and the application log can be collected in real time during the operation of the application.

[0071] The method may specifically include the following steps:

[0072] Step 101, if the application is started, a background thread is run in the mobile device;

[0073] In the embodiment of the present invention, a background thread for collecting application logs can be added for the application that needs to be tested. If the application is started, the application can also start a background thread in the mobile device during the application startup process.

[0074] Step 102, obtaining the log of the application program through the background thread;

[0075] After the background thread is started, it can collect logs generated during the running of the application and store the logs of the application in the mobile device.

[0076] In a specific implementation, the background thread can collect the logs generated during the operation of the application in real time. When the application generates a new log, the application-level log is obtained and stored. The background thread can also periodically collect the logs generated during the operation of the application, for example, collecting application-level logs at intervals of 1 minute, at intervals of 5 minutes, at intervals of 1 hour, etc., and the present invention does not limit this.

[0077] Step 103: If an exception occurs in the application, in response to a log extraction instruction sent by a tester to the mobile device, extract the acquired log of the application in the mobile device.

[0078] In the specific implementation, while the application is running, the tester operates the application through manual testing, designing automated test cases, etc. to ensure that the various functions of the application can be executed according to the original design.

[0079] If an exception occurs in the application while the tester is operating the application, the tester can send a log extraction instruction to the mobile device to request the application log that has been collected by the background thread.

[0080] In a specific implementation, the tester may issue the log extraction instruction by touching the touch screen of the mobile device, inputting text instructions to the mobile device, issuing voice instructions to the mobile device, etc., and the present invention does not limit this.

[0081] After receiving the log extraction instruction issued by the tester, the mobile device can extract the log of the application that has been obtained by the background thread and stored in the mobile device. In this way, the log extraction in the event of an abnormality in the application can be conveniently completed in the mobile device. The application log extraction is timely, accurate, and convenient.

[0082] According to the method for extracting application logs provided by the embodiment of the present invention, if the application is started, a background thread is run in the mobile device; the log of the application is obtained through the background thread; if an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the obtained log of the application is extracted in the mobile device. In this way, it is possible to capture application logs in a mobile device, and to collect application logs in real time during the operation of the application. If the application is abnormal, the tester can issue a log extraction instruction to the mobile device in time to obtain the collected application logs. The application log extraction is timely and accurate, and the extraction is convenient, without the assistance of other equipment, which is convenient for R&D personnel to analyze application anomalies.

[0083] In one embodiment of the present invention, the step of obtaining the log of the application program through the background thread includes:

[0084] S11, after clearing the logs of the application program acquired historically through the background thread, start acquiring the logs of the application program.

[0085] In the embodiment of the present invention, in order to better determine the cause of the application exception during the test process, the background thread collects the application log, which can be the application log collected from the time the application is started to the time the application stops running, without retaining all the logs generated during the application test process.

[0086] Therefore, if the application is started and the background thread is started, the background thread can first clear the application logs obtained historically, and start to obtain the application logs generated during the current application operation, so as to obtain the logs generated after the application exception occurs in a more targeted manner.

[0087] In one embodiment of the present invention, the step of obtaining the log of the application program through the background thread includes:

[0088] S21, in response to a tag filtering instruction issued by a tester, determining a target tag among preset tags;

[0089] S22, obtaining the log containing the target tag in the application through the background thread.

[0090] In the embodiment of the present invention, in order to specifically obtain the logs that may cause the application program exception, the application program logs may be obtained by tag filtering.

[0091] In a specific implementation, log records in an application log may have tag information, and the tag information may be used to classify and organize log information so as to make it easier to find and analyze logs of a specific type.

[0092] Generally speaking, the types of tags can include time tags, level tags, module tags, user tags, device tags, network tags, error tags, custom tags, etc.

[0093] The time tag may include a timestamp, a date, etc.

[0094] Level labels may include debug flag, general flag, warning flag, error flag, severe error flag, etc. The debug flag may indicate that the log is used to record the development and debugging stages. The general flag may indicate that the log is used to record the normal operation status of the application. The warning flag may indicate that the log is used to record potential problems or abnormal conditions. The error flag may indicate that the log is used to record errors that occur during the operation of the application. The severe error flag may indicate that the log is used to record errors that may cause the application to crash or cause severe failures.

[0095] Module tags can be used to record the name of the module or component to which the log belongs, such as "User Management", "Order Processing", etc.

[0096] User tags can be used to record the user ID that generates the log, the user's role or permission level, etc.

[0097] The device tag can be used to record the device ID that generates the log and the type of device, such as "iPhone", "Android", etc. It can also be used to record the operating system version.

[0098] The network label can be used to record the network connection type, such as "Wi-Fi", "4G", "5G", etc. It can also record the IP address of the device, the URL of the network request, etc.

[0099] Error tags can be used to record error codes or error types, detailed error messages, etc.

[0100] Custom tags can include business tags, environment tags, etc. Business tags can record tags customized according to business needs, such as "order number", "payment status", etc. Environment tags can be used to record the environment in which the application runs, such as "development", "testing", "production", etc.

[0101] Therefore, the tester can issue a tag filtering instruction, and pre-set the tag types that may be associated with application exceptions, such as error tags, level tags, etc., through the tag filtering instruction, so as to determine the target tags that need to be collected from the preset tags. Afterwards, when the background thread obtains the application log, it does not need to obtain the logs of all applications, but can specifically obtain the logs containing the target tags, thereby further improving the efficiency of log acquisition.

[0102] In one embodiment of the present invention, if an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the step of extracting the acquired log of the application in the mobile device includes:

[0103] S31, if the application program exits abnormally, determining that an abnormality occurs in the application program;

[0104] In a specific implementation, an application exception may occur in a variety of situations. Generally speaking, if an application exits abnormally under unexpected circumstances, such as a flash back during the running of the application, it can be considered that the application has an exception at this time.

[0105] S32, in response to a log extraction instruction issued by a tester to the mobile device, extracting the obtained log of the application program in the mobile device.

[0106] In the event that an exception occurs in an application, the tester can send a log extraction instruction to the mobile device, requesting the mobile device to extract the acquired log of the application, thereby completing the log extraction in the event that an exception occurs in the device.

[0107] In one embodiment of the present invention, the method further comprises:

[0108] S41, running a daemon process in the mobile device;

[0109] S42, monitoring whether the application program exits abnormally through the daemon process.

[0110] In a specific implementation, when an application exits abnormally, since the application is no longer running, the application itself cannot promptly notify the tester of the abnormality. In this case, in order to avoid the inability to obtain the application log normally, an additional daemon process can be run in the mobile device. The daemon process can be used to monitor the application and determine whether the application is in a running state. If the application exits abnormally, the daemon process can promptly find that the application is not in a running state and send a notification to the tester according to actual needs.

[0111] In one embodiment of the present invention, if the application program exits abnormally, the step of determining that the application program is abnormal includes:

[0112] S51: If a notification of abnormal application exit sent by the daemon process is received, it is determined that an abnormality occurs in the application.

[0113] In a specific implementation, the daemon process can send an abnormal application exit notification to the tester by calling the notification bar in the mobile device, issuing a voice prompt, etc., so as to remind the tester that the current application has abnormally exited through the abnormal application exit notification. At the same time, when the mobile device receives the daemon process request to send the abnormal application exit notification, it can also determine that the application has an abnormality and automatically obtain the application log according to actual needs.

[0114] In one embodiment of the present invention, the step of extracting the acquired log of the application in the mobile device in response to the log extraction instruction issued by the tester to the mobile device includes:

[0115] S61, in response to a tester sending a log extraction instruction to the mobile device in response to an abnormal exit notification of the application, extracting the obtained log of the application through a background process in the mobile device.

[0116] In a specific implementation, if the tester receives a notification of abnormal application exit, he or she may send a log extraction instruction to the mobile device in response to the notification of abnormal application exit to request to obtain the application log that has been collected by the background thread.

[0117] In a specific implementation, the tester may issue a log extraction instruction for the abnormal exit notification of the application by touching the touch screen of the mobile device, inputting text instructions to the mobile device, issuing voice instructions to the mobile device, etc., and the present invention does not limit this.

[0118] After receiving the log extraction instruction issued by the tester, the mobile device can extract the log of the application that has been obtained by the background thread and stored in the mobile device. In this way, the log extraction in the event of an abnormality in the application can be conveniently completed in the mobile device. The application log extraction is timely, accurate, and convenient.

[0119] In one embodiment of the present invention, if an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the step of extracting the acquired log of the application in the mobile device includes:

[0120] S71, if the application state is abnormal, determining that the application is abnormal;

[0121] S72, in response to a log extraction instruction issued by a tester to the mobile device, extracting the obtained log of the application in the mobile device.

[0122] In one embodiment of the present invention, if the application status is abnormal, for example, the application cannot provide corresponding functions as expected, the interface display of the application is abnormal, the data in the application is abnormal, the application cannot connect to the network normally, etc., it can be confirmed that the application is abnormal.

[0123] At this time, the tester can send a log extraction instruction to the mobile device to request the application logs that have been collected by the background thread.

[0124] In a specific implementation, the tester may issue the log extraction instruction by touching the touch screen of the mobile device, inputting text instructions to the mobile device, issuing voice instructions to the mobile device, etc., and the present invention does not limit this.

[0125] In one embodiment of the present invention, the step of extracting the acquired log of the application in the mobile device in response to the log extraction instruction issued by the tester to the mobile device includes:

[0126] S81, in response to a log extraction instruction issued by a tester by touching a preset log extraction control in the application, extracting the acquired log of the application through a background process in the mobile device.

[0127] In a specific implementation, in order to facilitate testers to promptly identify anomalies and extract application logs when anomalies occur, a log extraction control can be set in the application, and the log extraction control can be triggered by a touch operation. When the tester observes an application anomaly, he can issue a log extraction instruction by touching the log extraction control in the application, and extract the acquired application logs through the background process in the mobile device, so that the application log can be quickly extracted.

[0128] As a specific example of the present invention, Figure 2 1 is a flow chart of a method for extracting application logs provided in an embodiment of the present invention. The method comprises:

[0129] Step 201, start the application.

[0130] Specifically, when a tester needs to test an application, he can launch the application in a mobile device.

[0131] In the embodiment of the present invention, a background thread for collecting application logs can be added for the application that needs to be tested. If the application is started, the application can also start a background thread in the mobile device during the application startup process.

[0132] Step 202: After the background thread clears the logs of the application program that have been historically acquired, it starts to acquire the logs of the application program.

[0133] In the embodiment of the present invention, in order to better determine the cause of the application exception during the test process, the background thread collects the application log, which can be the application log collected from the time the application is started to the time the application stops running, without retaining all the logs generated during the application test process.

[0134] Therefore, if the application is started and the background thread is started, the background thread can first clear the application logs obtained historically, and start to obtain the application logs generated during the current application operation, so as to obtain the logs generated after the application exception occurs in a more targeted manner.

[0135] In a specific implementation, the log records in the application log can have tag information, and the tag information can be used to classify and organize the log information so that it is easier to find and analyze specific types of logs. Testers can issue tag filtering instructions, and through tag filtering instructions, pre-set the tag types that may be associated with application exceptions, such as error tags, level tags, etc., so as to determine the target tags that need to be collected from the preset tags. Thereafter, when the background thread obtains the application log, it does not need to obtain the logs of all applications, but can specifically obtain the logs containing the target tags, thereby further improving the efficiency of log acquisition.

[0136] Step 203: Determine if an exception occurs in the application program.

[0137] In specific implementations, application exceptions may include a variety of situations. Generally speaking, if an application exits abnormally under unexpected circumstances, such as a flashback during the running of the application, it can be considered that the application has an exception. If the application status is abnormal, such as the application cannot provide the corresponding functions as expected, the application interface display is abnormal, the data in the application is abnormal, and the application cannot connect to the network normally, it can be confirmed that the application has an exception.

[0138] Step 204: stop extracting the application logs, and obtain the extracted application logs.

[0139] After the background thread is started, it can collect logs generated during the running of the application and store the logs of the application in the mobile device.

[0140] In a specific implementation, the background thread can collect the logs generated during the operation of the application in real time. When the application generates a new log, the application-level log is obtained and stored. The background thread can also periodically collect the logs generated during the operation of the application, for example, collecting application-level logs at intervals of 1 minute, at intervals of 5 minutes, at intervals of 1 hour, etc., and the present invention does not limit this.

[0141] In the specific implementation, while the application is running, the tester operates the application through manual testing, designing automated test cases, etc. to ensure that the various functions of the application can be executed according to the original design.

[0142] If an exception occurs in the application while the tester is operating the application, the tester can send a log extraction instruction to the mobile device to request the application log that has been collected by the background thread.

[0143] In a specific implementation, the tester may issue the log extraction instruction by touching the touch screen of the mobile device, inputting text instructions to the mobile device, issuing voice instructions to the mobile device, etc., and the present invention does not limit this.

[0144] After receiving the log extraction instruction issued by the tester, the mobile device can extract the log of the application that has been obtained by the background thread and stored in the mobile device. In this way, the log extraction in the event of an abnormality in the application can be conveniently completed in the mobile device. The application log extraction is timely, accurate, and convenient.

[0145] Among them, in the case of abnormal exit of the application, since the application is no longer running, the application itself cannot promptly notify the tester of the abnormality. In this case, in order to avoid the inability to obtain the application log normally, an additional daemon process can be run in the mobile device. The daemon process can be used to monitor the application and determine whether the application is in a running state. The daemon process can send an abnormal exit notification of the application to the tester by calling the notification bar in the mobile device, issuing a voice prompt, etc., so as to remind the tester of the abnormal exit of the current application through the abnormal exit notification of the application. At the same time, when the mobile device receives the request of the daemon process to issue an abnormal exit notification of the application, it can also determine that the application is abnormal and automatically execute the acquisition of the application log according to actual needs.

[0146] If the application exits abnormally, the daemon process can promptly find that the application is not in a running state and send a notification to the tester according to actual needs. If the tester receives the notification of abnormal application exit, he can respond to the notification of abnormal application exit and send a log extraction instruction to the mobile device to request to obtain the application log that has been collected by the background thread.

[0147] In the case of abnormal application status, in order to facilitate testers to promptly determine the abnormality and extract the application log when the abnormality occurs, a log extraction control can be set in the application, and the log extraction control can be triggered by touch operation. When the tester observes the abnormality of the application, he can issue a log extraction instruction by touching the log extraction control in the application, and extract the acquired log of the application through the background process in the mobile device, so that the extraction of the application log can be completed quickly.

[0148] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but 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 according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0149] Reference Figure 3 , shows a structural block diagram of an application log extraction device provided in an embodiment of the present invention, which may specifically include the following modules:

[0150] A background thread running module 301 is used to run a background thread in the mobile device if the application is started;

[0151] A log extraction module 302, used to obtain the log of the application program through the background thread;

[0152] The log acquisition module 303 is used to extract the acquired log of the application in the mobile device in response to a log extraction instruction issued by a tester to the mobile device if an exception occurs in the application.

[0153] Optionally, the log extraction module includes:

[0154] The log extraction submodule is used to start acquiring the log of the application program after clearing the log of the application program acquired historically through the background thread.

[0155] Optionally, the log extraction module includes:

[0156] The tag determination submodule is used to determine the target tag among the preset tags in response to the tag filtering instruction issued by the tester;

[0157] The tag filtering submodule is used to obtain the log containing the target tag in the application through the background thread.

[0158] Optionally, the log acquisition module includes:

[0159] A first exception identification submodule, used to determine that an exception occurs in the application program if the application program exits abnormally;

[0160] The first log sub-acquisition module is used to extract the acquired log of the application program in the mobile device in response to a log extraction instruction issued by a tester to the mobile device.

[0161] Optionally, the device further comprises:

[0162] A daemon process running module, used for running a daemon process in the mobile device;

[0163] The daemon process monitoring module is used to monitor whether the application program exits abnormally through the daemon process.

[0164] Optionally, the first abnormality identification submodule includes:

[0165] The notification receiving unit is used to determine that an abnormality occurs in the application upon receiving an abnormal application exit notification sent by the daemon process.

[0166] Optionally, the first log sub-obtaining module includes:

[0167] The first log acquisition unit is used to respond to the tester's abnormal exit notification of the application and send a log extraction instruction to the mobile device, and extract the acquired log of the application through the background process in the mobile device.

[0168] Optionally, the log acquisition module includes:

[0169] A second abnormality identification submodule, used for determining that an abnormality occurs in the application if the application state is abnormal;

[0170] The second log sub-acquisition module is used to extract the acquired log of the application program in the mobile device in response to a log extraction instruction issued by a tester to the mobile device.

[0171] Optionally, the second log sub-obtaining module includes:

[0172] The second log acquisition unit is used to extract the acquired log of the application program through the background process in the mobile device in response to the log extraction instruction issued by the tester by touching the log extraction control preset in the application program.

[0173] Through the device provided by the embodiment of the present invention, if the application is started, a background thread is run in the mobile device; the log of the application is obtained through the background thread; if an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the obtained log of the application is extracted in the mobile device. In this way, it is possible to capture the application log in the mobile device, and the application log can be collected in real time during the operation of the application. If the application is abnormal, the tester can issue a log extraction instruction to the mobile device in time to obtain the collected application log. The application log extraction is timely and accurate, and the extraction is convenient, without the assistance of other equipment, which is convenient for R&D personnel to analyze application anomalies.

[0174] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0175] In addition, an embodiment of the present invention further provides an electronic device, such as Figure 4 As shown, it includes a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404.

[0176] Memory 403, used for storing computer programs;

[0177] The processor 401 is used to execute the program stored in the memory 403 to implement the following steps:

[0178] If the application is started, a background thread is run in the mobile device;

[0179] Obtaining the log of the application program through the background thread;

[0180] If an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the obtained log of the application is extracted in the mobile device.

[0181] Optionally, the step of obtaining the log of the application through the background thread includes:

[0182] After the logs of the application program acquired historically are cleared through the background thread, the logs of the application program are started to be acquired.

[0183] Optionally, the step of obtaining the log of the application through the background thread includes:

[0184] In response to a tag filtering instruction issued by a tester, a target tag is determined from among preset tags;

[0185] The log containing the target tag in the application is obtained through the background thread.

[0186] Optionally, if an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the step of extracting the acquired log of the application in the mobile device includes:

[0187] If the application program exits abnormally, determining that an abnormality occurs in the application program;

[0188] In response to a log extraction instruction issued by a tester to the mobile device, the obtained log of the application is extracted in the mobile device.

[0189] Optionally, the method further comprises:

[0190] Running a daemon process in the mobile device;

[0191] The daemon process is used to monitor whether the application program exits abnormally.

[0192] Optionally, if the application program exits abnormally, the step of determining that the application program is abnormal includes:

[0193] If a notification of abnormal exit of the application program sent by the daemon process is received, it is determined that an abnormality occurs in the application program.

[0194] Optionally, in response to a log extraction instruction issued by a tester to the mobile device, the step of extracting the acquired log of the application in the mobile device includes:

[0195] In response to the tester's notification of abnormal exit of the application, a log extraction instruction is issued to the mobile device, and the obtained log of the application is extracted through a background process in the mobile device.

[0196] Optionally, if an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the step of extracting the acquired log of the application in the mobile device includes:

[0197] If the application state is abnormal, determining that an abnormality occurs in the application;

[0198] In response to a log extraction instruction issued by a tester to the mobile device, the obtained log of the application is extracted in the mobile device.

[0199] Optionally, in response to a log extraction instruction issued by a tester to the mobile device, the step of extracting the acquired log of the application in the mobile device includes:

[0200] In response to a log extraction instruction issued by a tester by touching a log extraction control preset in the application, the acquired log of the application is extracted through a background process in the mobile device.

[0201] With the electronic device provided by the embodiment of the present invention, if the application is started, a background thread is run in the mobile device; the log of the application is obtained through the background thread; if an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the obtained log of the application is extracted in the mobile device. In this way, it is possible to capture the application log in the mobile device, and to collect the application log in real time during the operation of the application. If the application is abnormal, the tester can issue a log extraction instruction to the mobile device in time to obtain the collected application log. The application log extraction is timely and accurate, and the extraction is convenient, without the assistance of other equipment, which is convenient for R&D personnel to analyze application anomalies.

[0202] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0203] The communication interface is used for communication between the above terminal and other devices.

[0204] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0205] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0206] like Figure 5As shown, in another embodiment provided by the present invention, a computer-readable storage medium 501 is further provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the method for extracting application logs described in the above embodiment.

[0207] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the method for extracting application logs described in the above embodiment.

[0208] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital tester line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0209] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0210] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0211] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A method for extracting application logs, characterized in that: The method is applied to a mobile device having an application installed therein, and the method comprises: If the application is started, a background thread is run in the mobile device; Obtaining the log of the application program through the background thread; If an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the obtained log of the application is extracted in the mobile device.

2. The method according to claim 1, characterized in that: The step of obtaining the log of the application program through the background thread includes: After the logs of the application program acquired historically are cleared through the background thread, the logs of the application program are started to be acquired.

3. The method according to claim 1, characterized in that The step of obtaining the log of the application program through the background thread includes: In response to a tag filtering instruction issued by a tester, a target tag is determined from among preset tags; The log containing the target tag in the application is obtained through the background thread.

4. The method according to claim 1, characterized in that: If an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the step of extracting the acquired log of the application in the mobile device includes: If the application program exits abnormally, determining that an abnormality occurs in the application program; In response to a log extraction instruction issued by a tester to the mobile device, the obtained log of the application is extracted in the mobile device.

5. The method according to claim 4, characterized in that The method further comprises: Running a daemon process in the mobile device; The daemon process is used to monitor whether the application program exits abnormally.

6. The method according to claim 5, characterized in that If the application program exits abnormally, the step of determining that the application program has an abnormality comprises: If a notification of abnormal exit of the application program sent by the daemon process is received, it is determined that an abnormality occurs in the application program.

7. The method according to claim 6, characterized in that The step of extracting the acquired log of the application program in the mobile device in response to the log extraction instruction issued by the tester to the mobile device comprises: In response to the tester's notification of abnormal exit of the application, a log extraction instruction is issued to the mobile device, and the obtained log of the application is extracted through a background process in the mobile device.

8. The method according to claim 1, characterized in that If an exception occurs in the application, in response to a log extraction instruction issued by a tester to the mobile device, the step of extracting the acquired log of the application in the mobile device includes: If the application state is abnormal, determining that an abnormality occurs in the application; In response to a log extraction instruction issued by a tester to the mobile device, the obtained log of the application is extracted in the mobile device.

9. The method according to claim 8, characterized in that The step of extracting the acquired log of the application program in the mobile device in response to the log extraction instruction issued by the tester to the mobile device comprises: In response to a log extraction instruction issued by a tester by touching a log extraction control preset in the application, the acquired log of the application is extracted through a background process in the mobile device.

10. A device for extracting application logs, characterized in that: The device is applied to a mobile device, in which an application is installed, and the device comprises: A background thread running module, used for running a background thread in the mobile device if the application is started; A log extraction module, used to obtain the log of the application through the background thread; The log acquisition module is used to extract the acquired log of the application program in the mobile device in response to a log extraction instruction issued by a tester to the mobile device if an exception occurs in the application program.

11. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 9 when executing the program stored in the memory.

12. A computer-readable medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 9.