Log processing method, device, equipment and storage medium

By obtaining the operating environment and application scenario information of the mobile terminal and adopting differentiated log recording, storage and upload strategies, the problem of single log strategy in the iOS system is solved, and the operability and management efficiency of mobile terminal logs are improved.

CN115269537BActive Publication Date: 2025-09-30CHINA PING AN LIFE INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210933415.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-04
Publication Date
2025-09-30
Estimated Expiration
2042-08-04

AI Technical Summary

Technical Problem

All apps in the iOS system use the same NSLog logging strategy, resulting in poor log operability and the inability to adopt different recording, storage, and upload strategies based on different situations.

Method used

By obtaining the mobile terminal's operating environment information, context type information, and application scenario type, different log recording, storage, and upload strategies are adopted, including recording logs of different levels, splitting and storing log files, and choosing automatic or manual log upload according to the application scenario type.

Benefits of technology

It implements optimized log processing strategies based on different situations, improving the operability and management efficiency of mobile terminal logs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115269537B_ABST
    Figure CN115269537B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a log processing method, apparatus, device, and storage medium, which obtain operating environment information of a mobile terminal and record a log corresponding to the log level and the operating environment information; obtain context type information of the log and store the log according to a storage policy corresponding to the context type information; obtain the application scenario type of the mobile terminal and upload the log according to an upload policy corresponding to the application scenario type of the mobile terminal; and can adopt different recording strategies, storage strategies, and upload strategies for different situations to achieve a more optimal log processing strategy and improve the operability of the log of the mobile terminal.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of log processing, and in particular to log processing methods, devices, equipment, and storage media. Background Art

[0002] The current iOS system includes NSLog, which outputs information to the standard error console and system log. Internally, NSLog uses the Apple System Logger (ASL) application programming interface (API) to store log messages directly on disk. The ASL interface is the iOS system's logging interface. Regardless of the situation, all iOS apps use the same NSLog logging system, with the same logging, storage, and upload policies. This impacts the operability of logs on mobile devices. Summary of the Invention

[0003] The purpose of this application is to solve one of the technical problems existing in the related art to at least a certain extent.

[0004] To this end, one purpose of the embodiments of the present application is to provide a log processing method, apparatus, device and storage medium, which can adopt different recording strategies, storage strategies and upload strategies for different situations to achieve a better log processing strategy.

[0005] To achieve the above objectives, a first aspect of an embodiment of the present application provides a log processing method, which is applied to a mobile terminal. The log processing method includes:

[0006] Obtaining the operating environment information of the mobile terminal, and recording a log with a log level corresponding to the operating environment information;

[0007] Obtaining context type information of the log, and storing the log according to a storage policy corresponding to the context type information;

[0008] The application scenario type of the mobile terminal is obtained, and the log is uploaded according to an upload strategy corresponding to the application scenario type of the mobile terminal.

[0009] In some embodiments, obtaining the operating environment information of the mobile terminal and recording a log having a log level corresponding to the operating environment information includes:

[0010] When the operating environment information is in the test state, a log with a verbose level and a log with a debug level are recorded; wherein the log with a verbose level records the detailed process of all operating steps of the mobile terminal, and the log with a debug level records the detailed process of key operating steps of the mobile terminal;

[0011] When the operating environment information is the online application status, logs with an information level, a warning level, and an error level are recorded; wherein, the logs with an information level record the attention information of the mobile terminal, the logs with a warning level record the operating alarm information, and the logs with an error level record the operating error information.

[0012] In some embodiments, the context type information of the log includes a data statistics type for batch usage data records; obtaining the context type information of the log and storing the log according to a storage policy corresponding to the context type information includes:

[0013] According to the storage policy corresponding to the data statistics type, the file segmentation size of the log is determined to be a first segmentation value, the maximum number of files of the log is determined to be a first file number value, the maximum disk storage size of the file of the log is determined to be a first storage value, and the file segmentation period of the log is determined to be a first period value;

[0014] The log is stored according to the first segmentation value, the first file quantity value, the first storage value, and the first period value.

[0015] In some embodiments, the context type information of the log includes a business logic type for identifying business logic issues; obtaining the context type information of the log and storing the log according to a storage policy corresponding to the context type information includes:

[0016] According to the storage policy corresponding to the business logic type, the file segmentation size of the log is determined to be a second segmentation value, the maximum number of files of the log is determined to be a second file number value, the maximum disk storage size of the file of the log is determined to be a second storage value, and the file segmentation period of the log is determined to be a second period value;

[0017] storing the log according to the second segmentation value, the second file quantity value, the second storage value, and the second period value;

[0018] Among them, the second segmentation value is smaller than the first segmentation value; the second file quantity value is larger than the first file quantity value; the second storage value is larger than the first storage value; and the second period value is equal to the first period value.

[0019] In some embodiments, the context type information of the log includes a performance monitoring type for monitoring the performance of the mobile terminal; and obtaining the context type information of the log and storing the log according to a storage policy corresponding to the context type information includes:

[0020] According to the storage policy corresponding to the performance monitoring type, determining the file segmentation size of the log to be a third segmentation value, determining the maximum number of files of the log to be a third file number value, determining the maximum disk storage size of the file of the log to be a third storage value, and determining the file segmentation period of the log to be a third period value;

[0021] storing the log according to the third segmentation value, the third file quantity value, the third storage value, and the third period value;

[0022] Among them, the third segmentation value is smaller than the second segmentation value; the third file quantity value is larger than the first file quantity value and smaller than the second file quantity value; the third storage value is smaller than the first storage value; and the third period value is smaller than the first period value.

[0023] In some embodiments, obtaining the application scenario type of the mobile terminal and uploading the log according to an upload policy corresponding to the application scenario type of the mobile terminal includes:

[0024] When the application scenario type of the mobile terminal is an application for general users, uploading the log according to the automatic uploading strategy;

[0025] When the application scenario type of the mobile terminal is an application for a specified user, the log is uploaded according to a manual upload strategy.

[0026] In some embodiments, uploading the log according to the automatic upload policy includes:

[0027] Segmenting the log;

[0028] A log upload task producer adds a new log upload task and saves the log upload task in a log upload task storage center;

[0029] Obtain the log upload task from the log upload task storage center through the log upload task consumer, and call the log uploader to upload the split log;

[0030] When the log upload is successful, the log upload task is deleted from the log upload task storage center; when the log upload fails, the log upload task is obtained again from the log upload task storage center through the log upload task consumer.

[0031] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides a log processing device, which is applied to a mobile terminal. The log processing device includes:

[0032] A log recording module, configured to obtain operating environment information of the mobile terminal and record a log having a log level corresponding to the operating environment information;

[0033] a log storage module, configured to obtain context type information of the log and store the log according to a storage policy corresponding to the context type information;

[0034] The log uploading module is used to obtain the application scenario type of the mobile terminal and upload the log according to the uploading strategy corresponding to the application scenario type of the mobile terminal.

[0035] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application provides an electronic device, which includes a memory, a processor, a program stored on the memory and runnable on the processor, and a data bus for realizing connection and communication between the processor and the memory, and the program implements the above-mentioned log processing method when executed by the processor.

[0036] To achieve the above-mentioned purpose, a fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the above-mentioned log processing method.

[0037] The log processing method, apparatus, device, and storage medium disclosed in the embodiments of the present application obtain the operating environment information of the mobile terminal and record a log corresponding to the log level and the operating environment information; obtain the context type information of the log and store the log according to the storage policy corresponding to the context type information; obtain the application scenario type of the mobile terminal and upload the log according to the upload policy corresponding to the application scenario type of the mobile terminal; and can adopt different recording strategies, storage strategies, and upload strategies for different situations to achieve a better log processing strategy and improve the operability of the log of the mobile terminal. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following introduction is made to the drawings of the embodiments of the present application or the related technical solutions in the prior art. It should be understood that the drawings introduced below are only for the convenience of clearly describing some embodiments of the technical solutions of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without any creative work.

[0039] Figure 1 This is a step diagram of the log processing method provided by an embodiment of the present invention;

[0040] Figure 2 This is a step diagram of step S200 when the context type information of the log is a data statistics type;

[0041] Figure 3 This is a step diagram of step S200 when the context type information of the log is a business logic type;

[0042] Figure 4 This is a step diagram of step S200 when the context type information of the log is a performance monitoring type;

[0043] Figure 5 This is a step diagram of step S300 when the application scenario type of the mobile terminal is an application for a specified user;

[0044] Figure 6 This is a step diagram of step S300 when the application scenario type of the mobile terminal is an application for general users;

[0045] Figure 7 This is a diagram of the steps for uploading logs according to the automatic upload strategy;

[0046] Figure 8 This is a schematic diagram of the principle of uploading logs according to the automatic upload strategy;

[0047] Figure 9 is a structural diagram of a log processing device provided by an embodiment of the present invention;

[0048] Figure 10 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0049] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0050] It should be noted that although the device schematics illustrate functional module divisions and the flowcharts illustrate logical sequences, in certain circumstances, the steps shown or described may be performed in a sequence that differs from the module divisions in the device or the sequence in the flowcharts. The terms "first," "second," and so on, in the specification, claims, and drawings, are used to distinguish similar items and are not necessarily used to describe a specific sequence or precedence.

[0051] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.

[0052] The iOS system itself is equipped with NSLog, which outputs information to the standard error console and system log. Internally, NSLog uses the ASL interface, an application programming interface, to store log messages directly on disk. The ASL interface is the interface used to output logs in the iOS system. All iOS applications use the same NSLog log, making it difficult to distinguish which iOS application the output NSLog log originated from. Regardless of the situation, NSLog logs use the same recording strategy, storage strategy, and upload strategy. In addition, NSLog can only store log messages directly on disk and does not provide a server-side upload function. When you need to view the logs on a mobile terminal, you need to view the logs on the user's mobile terminal device, which is very inconvenient.

[0053] In order to solve the problems in the related technology, one purpose of the embodiments of the present application is to provide a log processing method, device, equipment and storage medium, which obtains the operating environment information of the mobile terminal, records the log level and the log corresponding to the operating environment information; obtains the context type information of the log, and stores the log according to the storage policy corresponding to the context type information; obtains the application scenario type of the mobile terminal, and uploads the log according to the upload policy corresponding to the application scenario type of the mobile terminal; and can adopt different recording strategies, storage strategies and upload strategies for different situations to achieve a better log processing strategy and improve the operability of the log of the mobile terminal.

[0054] The implementation environment of a log processing method provided in an embodiment of the present application is as follows. The hardware and software components of the implementation environment primarily include a mobile terminal. Specifically, the mobile terminal in the present application may include, but is not limited to, any one or more of a smartwatch, a smartphone, a tablet device, a personal digital assistant (PDA), a smart home appliance, or an in-vehicle terminal.

[0055] Reference Figure 1 , Figure 1 This is a step diagram of a log processing method. The embodiment of the present application provides a log processing method, which includes but is not limited to the following steps:

[0056] Step S100: Obtain the operating environment information of the mobile terminal and record a log corresponding to the log level and the operating environment information;

[0057] Step S200: Obtain context type information of the log, and store the log according to a storage policy corresponding to the context type information;

[0058] Step S300: Acquire the application scenario type of the mobile terminal, and upload the log according to the upload policy corresponding to the application scenario type of the mobile terminal.

[0059] In step S100, the operating environment information of the mobile terminal is obtained, and the log corresponding to the log level and the operating environment information is recorded, including:

[0060] When the operating environment information is in the test state, logs with a verbose level and a debug level are recorded; wherein the verbose level log records the detailed process of all operating steps of the mobile terminal, and the debug level log records the detailed process of the key operating steps of the mobile terminal;

[0061] When the operating environment information is an online application status, logs with an information level, a warning level, and an error level are recorded; among them, logs with an information level record the attention information of the mobile terminal, logs with a warning level record the operating alarm information, and logs with an error level record the operating error information.

[0062] It is understood that the testing state is a state in which the mobile terminal is being tested by a developer, or a state in which the mobile terminal is in a developer mode. The online application state is a state in which the mobile terminal is being used by a user for online application.

[0063] When the mobile terminal is in a test state, it records a verbose log, detailing each step of the mobile terminal's operation. It also records a debug log, detailing key steps of the mobile terminal's operation.

[0064] When the mobile terminal is in an online application state, the mobile terminal records logs at the information level, recording the mobile terminal's attention information, that is, the information that the mobile terminal needs to pay attention to during operation; the mobile terminal records logs at the warning level, recording the mobile terminal's operation alarm information, that is, the information that may cause operation problems during the operation of the mobile terminal; the mobile terminal records logs at the error level, recording the mobile terminal's operation error information, that is, the information that will inevitably cause operation problems during the operation of the mobile terminal. Among them, operation problems include problems that affect program operation and business logic problems. For business logic problems, such as errors in amount calculation, the business logic problem will not affect the operation of the mobile terminal program; but if a business logic problem occurs, the mobile terminal program will run as usual.

[0065] For step S200, for log storage, the log file is split every split cycle to obtain multiple split log files, the size of the split log file is specified by the file split size, the number of split log files is limited by the maximum number of log files, the split cycle is specified by the file split cycle, and the multiple split log files are stored in the disk to achieve local storage. The disk space occupied by the multiple split log files obtained by splitting each log file is limited by the maximum value of the file disk storage size.

[0066] In one aspect, the context type information of the log includes the data statistics type used for batch usage data records. Figure 2 When the context type information of the log is a data statistics type, the context type information of the log is obtained, and the log is stored according to the storage policy corresponding to the context type information, including but not limited to the following steps:

[0067] Step S211: According to the storage policy corresponding to the data statistics type, the file segmentation size of the log is determined to be a first segmentation value, the maximum number of files in the log is determined to be a first file number value, the maximum disk storage size of the log file is determined to be a first storage value, and the file segmentation period of the log is determined to be a first period value;

[0068] Step S212: storing the log according to the first segmentation value, the first file quantity value, the first storage value, and the first period value.

[0069] The file segmentation size of the log is determined to be the first segmentation value. In this embodiment, the first segmentation value is set to 2M. Of course, in other embodiments, the first segmentation value can be set to other values ​​according to actual needs, such as 3M.

[0070] The maximum number of files in the log is determined to be the first file number value. In this embodiment, the first file number value is set to 5. Of course, in other embodiments, the first file number value can be set to other values ​​according to actual needs, such as 6.

[0071] The maximum value of the log file disk storage size is determined to be the first storage value. In this embodiment, the first storage value is set to 10M. Of course, in other embodiments, the first storage value can be set to other values ​​according to actual needs, such as 11M.

[0072] The file segmentation period of the log is determined to be a first period value. In this embodiment, the first period value is set to 24 hours. Of course, in other embodiments, the first period value can be set to other values ​​according to actual needs, such as 18 hours.

[0073] On the other hand, the context type information of the log includes the business logic type used to identify business logic problems. Figure 3 When the context type information of the log is a business logic type, the context type information of the log is obtained, and the log is stored according to the storage policy corresponding to the context type information, including but not limited to the following steps:

[0074] Step S221: According to the storage policy corresponding to the business logic type, the file segmentation size of the log is determined to be a second segmentation value, the maximum number of files in the log is determined to be a second file number value, the maximum disk storage size of the log file is determined to be a second storage value, and the file segmentation period of the log is determined to be a second period value;

[0075] Step S222, storing the log according to the second segmentation value, the second file quantity value, the second storage value, and the second period value;

[0076] The second segmentation value is smaller than the first segmentation value; the second file quantity value is larger than the first file quantity value; the second storage value is larger than the first storage value; and the second period value is equal to the first period value.

[0077] Among them, the file segmentation size of the log is determined to be the second segmentation value. In this embodiment, the second segmentation value is set to 1M; of course, in other embodiments, the second segmentation value can be set to other values ​​according to actual needs, such as 1.5M; but it is necessary to meet the premise that the second segmentation value is smaller than the first segmentation value.

[0078] The maximum value of the number of files in the log is determined to be the second file number value. In this embodiment, the second file number value is set to 30. Of course, in other embodiments, the second file number value can be set to other values ​​according to actual needs, such as 40. However, the premise that the second file number value is greater than the first file number value must be met.

[0079] The maximum value of the file disk storage size of the log is determined to be the second storage value. In this embodiment, the second storage value is set to 30M; of course, in other embodiments, the second storage value can be set to other values ​​according to actual needs, such as 40M; but it is necessary to meet the premise that the second storage value is greater than the first storage value.

[0080] Determine that the file segmentation period of the log is the second period value. In this embodiment, the second period value is set to 24 hours. Of course, in other embodiments, the second period value can be set to other values ​​according to actual needs, such as 18 hours. However, it is required that the second period value is equal to the first period value.

[0081] In another aspect, the context type information of the log includes a performance monitoring type for monitoring the performance of the mobile terminal. Figure 4 When the context type information of the log is a performance monitoring type, the context type information of the log is obtained, and the log is stored according to a storage policy corresponding to the context type information, including but not limited to the following steps:

[0082] Step S231: According to the storage policy corresponding to the performance monitoring type, the file segmentation size of the log is determined to be a third segmentation value, the maximum number of files in the log is determined to be a third file number value, the maximum disk storage size of the log file is determined to be a third storage value, and the file segmentation period of the log is determined to be a third period value.

[0083] Step S232, storing the log according to the third segmentation value, the third file quantity value, the third storage value, and the third period value;

[0084] The third segmentation value is smaller than the second segmentation value; the third file quantity value is larger than the first file quantity value and smaller than the second file quantity value; the third storage value is smaller than the first storage value; and the third period value is smaller than the first period value.

[0085] Among them, the file segmentation size of the log is determined to be the third segmentation value. In this embodiment, the third segmentation value is set to 500KB; of course, in other embodiments, the third segmentation value can be set to other values ​​according to actual needs, such as 100KB; but it is necessary to meet the premise that the third segmentation value is smaller than the second segmentation value.

[0086] The maximum value of the number of files in the log is determined to be the third file number value. In this embodiment, the third file number value is set to 10; of course, in other embodiments, the third file number value can be set to other values ​​according to actual needs, such as 15; but it is necessary to meet the premise that the third file number value is greater than the first file number value and less than the second file number value.

[0087] The maximum value of the file disk storage size of the log is determined to be the third storage value. In this embodiment, the third storage value is set to 5M; of course, in other embodiments, the third storage value can be set to other values ​​according to actual needs, such as 4M; but it is necessary to meet the premise that the third storage value is less than the first storage value.

[0088] Determine that the file segmentation period of the log is the third period value. In this embodiment, the third period value is set to 12 hours. Of course, in other embodiments, the third period value can be set to other values ​​according to actual needs, such as 6 hours. However, it is required that the third period value is less than the first period value.

[0089] For step S300, in one aspect, refer to Figure 5 , obtain the application scenario type of the mobile terminal, and upload the log according to the upload strategy corresponding to the application scenario type of the mobile terminal, including but not limited to the following steps:

[0090] Step S310 : When the application scenario type of the mobile terminal is an application for a designated user, the log is uploaded according to the manual upload policy.

[0091] The designated user is a user that can be contacted by the operation staff and other related personnel. When a problem occurs with the mobile terminal, the operation staff will contact the designated user and ask the designated user to click the function button on the mobile terminal interface to manually upload the log.

[0092] On the other hand, refer to Figure 6 , obtain the application scenario type of the mobile terminal, and upload the log according to the upload strategy corresponding to the application scenario type of the mobile terminal, including:

[0093] Step S320: When the application scenario type of the mobile terminal is an application for general users, the log is uploaded according to the automatic upload policy.

[0094] Operations personnel cannot and should not contact general users. Mobile terminals upload logs according to the automatic upload policy to facilitate maintenance personnel to identify problems.

[0095] Reference Figure 7 For step S320, uploading logs according to the automatic upload strategy includes but is not limited to the following steps:

[0096] Step S321, splitting the log;

[0097] Step S322: A new log upload task is created by the log upload task producer, and the log upload task is saved in the log upload task storage center;

[0098] Step S323: The log upload task consumer obtains the log upload task from the log upload task storage center and calls the log uploader to upload the segmented logs.

[0099] Step S324: When the log upload is successful, the log upload task is deleted from the log upload task storage center;

[0100] Step S325: When the log upload fails, the log upload task is obtained again from the log upload task storage center through the log upload task consumer.

[0101] Reference Figure 8 , Figure 8 This diagram illustrates the principle of uploading logs according to an automatic upload strategy. The mobile terminal outputs logs to the logger through the logging interface. The logger writes the logs to different file directories based on the context, resulting in log files. The logger also segments the logs. A log upload task producer adds a new log upload task and saves it to the log upload task storage center. Furthermore, the log upload task storage center can write the log upload task to disk for persistent storage. After persistent storage, the log upload task storage center can read the log upload task from disk. The log upload task consumer waits for log upload tasks in a loop. When a new log upload task is added to the log upload task storage center, the log upload task consumer retrieves the log upload task from the log upload task storage center and calls the log uploader to upload the segmented log. If a log upload succeeds, the log upload task is deleted from the log upload task storage center. If a log upload fails, the log upload task consumer continues to wait for the log upload task in a loop. The log upload task restorer restores the log upload task from the log upload task storage center as needed. The log upload task consumer then retrieves the log upload task from the log upload task storage center and calls the log uploader to upload the segmented log.

[0102] In this embodiment, by obtaining the operating environment information of the mobile terminal, a log corresponding to the log level and the operating environment information is recorded; the context type information of the log is obtained, and the log is stored according to the storage strategy corresponding to the context type information; the application scenario type of the mobile terminal is obtained, and the log is uploaded according to the upload strategy corresponding to the application scenario type of the mobile terminal; different recording strategies, storage strategies and upload strategies can be adopted for different situations to achieve a better log processing strategy and improve the operability of the log of the mobile terminal.

[0103] To achieve the above objectives, an embodiment of the present application further provides a log processing device, which is applied to a mobile terminal.

[0104] Reference Figure 9 , Figure 91 is a structural diagram of a log processing device, which includes a log recording module 110 , a log storage module 120 and a log upload module 130 .

[0105] Among them, the log recording module 110 is used to obtain the operating environment information of the mobile terminal and record the log level corresponding to the operating environment information; the log storage module 120 is used to obtain the context type information of the log and store the log according to the storage strategy corresponding to the context type information; the log upload module 130 is used to obtain the application scenario type of the mobile terminal and upload the log according to the upload strategy corresponding to the application scenario type of the mobile terminal.

[0106] Regarding the log recording module 110, the steps of obtaining the operating environment information of the mobile terminal and recording the log corresponding to the log level and the operating environment information executed by the log recording module 110 specifically include:

[0107] When the operating environment information is in the test state, logs with a verbose level and a debug level are recorded; wherein the verbose level log records the detailed process of all operating steps of the mobile terminal, and the debug level log records the detailed process of the key operating steps of the mobile terminal;

[0108] When the operating environment information is an online application status, logs with an information level, a warning level, and an error level are recorded; among them, logs with an information level record the attention information of the mobile terminal, logs with a warning level record the operating alarm information, and logs with an error level record the operating error information.

[0109] It is understood that the testing state is a state in which the mobile terminal is being tested by a developer, or a state in which the mobile terminal is in a developer mode. The online application state is a state in which the mobile terminal is being used by a user for online application.

[0110] When the mobile terminal is in a test state, it records a verbose log, detailing each step of the mobile terminal's operation. It also records a debug log, detailing key steps of the mobile terminal's operation.

[0111] When the mobile terminal is in an online application state, the mobile terminal records logs at the information level, recording the mobile terminal's attention information, that is, the information that the mobile terminal needs to pay attention to during operation; the mobile terminal records logs at the warning level, recording the mobile terminal's operation alarm information, that is, the information that may cause operation problems during the operation of the mobile terminal; the mobile terminal records logs at the error level, recording the mobile terminal's operation error information, that is, the information that will inevitably cause operation problems during the operation of the mobile terminal. Among them, operation problems include problems that affect program operation and business logic problems. For business logic problems, such as errors in amount calculation, the business logic problem will not affect the operation of the mobile terminal program; but if a business logic problem occurs, the mobile terminal program will run as usual.

[0112] For the log storage module 120, the log file is split every split cycle to obtain multiple split log files. The size of the split log file is determined by the file split size, the number of split log files is limited by the maximum number of log files, the split cycle is determined by the file split cycle, and the multiple split log files are stored in the disk to achieve local storage. The disk space occupied by the multiple split log files obtained by splitting each log file is limited by the maximum value of the file disk storage size.

[0113] In one aspect, the context type information of the log includes a data statistics type for batch usage data recording; the steps of obtaining the context type information of the log and storing the log according to the storage policy corresponding to the context type information performed by the log storage module 120 specifically include:

[0114] According to the storage policy corresponding to the data statistics type, the file segmentation size of the log is determined to be a first segmentation value, the maximum number of files of the log is determined to be a first file number value, the maximum disk storage size of the file of the log is determined to be a first storage value, and the file segmentation period of the log is determined to be a first period value;

[0115] Logs are stored according to the first segmentation value, the first file quantity value, the first storage value, and the first period value.

[0116] The file segmentation size of the log is determined to be the first segmentation value. In this embodiment, the first segmentation value is set to 2M. Of course, in other embodiments, the first segmentation value can be set to other values ​​according to actual needs, such as 3M.

[0117] The maximum number of files in the log is determined to be the first file number value. In this embodiment, the first file number value is set to 5. Of course, in other embodiments, the first file number value can be set to other values ​​according to actual needs, such as 6.

[0118] The maximum value of the log file disk storage size is determined to be the first storage value. In this embodiment, the first storage value is set to 10M. Of course, in other embodiments, the first storage value can be set to other values ​​according to actual needs, such as 11M.

[0119] The file segmentation period of the log is determined to be a first period value. In this embodiment, the first period value is set to 24 hours. Of course, in other embodiments, the first period value can be set to other values ​​according to actual needs, such as 18 hours.

[0120] On the other hand, the context type information of the log includes a business logic type for identifying business logic problems; the steps of obtaining the context type information of the log and storing the log according to the storage policy corresponding to the context type information performed by the log storage module 120 specifically include:

[0121] According to the storage policy corresponding to the business logic type, the file segmentation size of the log is determined to be a second segmentation value, the maximum number of files of the log is determined to be a second file number value, the maximum disk storage size of the file of the log is determined to be a second storage value, and the file segmentation period of the log is determined to be a second period value;

[0122] storing the logs according to the second segmentation value, the second file quantity value, the second storage value, and the second period value;

[0123] The second segmentation value is smaller than the first segmentation value; the second file quantity value is larger than the first file quantity value; the second storage value is larger than the first storage value; and the second period value is equal to the first period value.

[0124] Among them, the file segmentation size of the log is determined to be the second segmentation value. In this embodiment, the second segmentation value is set to 1M; of course, in other embodiments, the second segmentation value can be set to other values ​​according to actual needs, such as 1.5M; but it is necessary to meet the premise that the second segmentation value is smaller than the first segmentation value.

[0125] The maximum value of the number of files in the log is determined to be the second file number value. In this embodiment, the second file number value is set to 30. Of course, in other embodiments, the second file number value can be set to other values ​​according to actual needs, such as 40. However, the premise that the second file number value is greater than the first file number value must be met.

[0126] The maximum value of the file disk storage size of the log is determined to be the second storage value. In this embodiment, the second storage value is set to 30M; of course, in other embodiments, the second storage value can be set to other values ​​according to actual needs, such as 40M; but it is necessary to meet the premise that the second storage value is greater than the first storage value.

[0127] Determine that the file segmentation period of the log is the second period value. In this embodiment, the second period value is set to 24 hours. Of course, in other embodiments, the second period value can be set to other values ​​according to actual needs, such as 18 hours. However, it is required that the second period value is equal to the first period value.

[0128] In another aspect, the context type information of the log includes a performance monitoring type for monitoring the performance of the mobile terminal; the steps of obtaining the context type information of the log and storing the log according to the storage policy corresponding to the context type information performed by the log storage module 120 specifically include:

[0129] According to the storage policy corresponding to the performance monitoring type, the file segmentation size of the log is determined to be a third segmentation value, the maximum number of files of the log is determined to be a third file number value, the maximum disk storage size of the file of the log is determined to be a third storage value, and the file segmentation period of the log is determined to be a third period value;

[0130] storing the logs according to the third segmentation value, the third file quantity value, the third storage value, and the third period value;

[0131] The third segmentation value is smaller than the second segmentation value; the third file quantity value is larger than the first file quantity value and smaller than the second file quantity value; the third storage value is smaller than the first storage value; and the third period value is smaller than the first period value.

[0132] Among them, the file segmentation size of the log is determined to be the third segmentation value. In this embodiment, the third segmentation value is set to 500KB; of course, in other embodiments, the third segmentation value can be set to other values ​​according to actual needs, such as 100KB; but it is necessary to meet the premise that the third segmentation value is smaller than the second segmentation value.

[0133] The maximum value of the number of files in the log is determined to be the third file number value. In this embodiment, the third file number value is set to 10; of course, in other embodiments, the third file number value can be set to other values ​​according to actual needs, such as 15; but it is necessary to meet the premise that the third file number value is greater than the first file number value and less than the second file number value.

[0134] The maximum value of the file disk storage size of the log is determined to be the third storage value. In this embodiment, the third storage value is set to 5M; of course, in other embodiments, the third storage value can be set to other values ​​according to actual needs, such as 4M; but it is necessary to meet the premise that the third storage value is less than the first storage value.

[0135] Determine that the file segmentation period of the log is the third period value. In this embodiment, the third period value is set to 12 hours. Of course, in other embodiments, the third period value can be set to other values ​​according to actual needs, such as 6 hours. However, it is required that the third period value is less than the first period value.

[0136] For the log upload module 130, on one hand, the steps of obtaining the application scenario type of the mobile terminal and uploading the log according to the upload strategy corresponding to the application scenario type of the mobile terminal executed by the log upload module 130 specifically include: when the application scenario type of the mobile terminal is an application for a specified user, uploading the log according to the manual upload strategy.

[0137] The designated user is a user that can be contacted by the operation staff and other related personnel. When a problem occurs with the mobile terminal, the operation staff will contact the designated user and ask the designated user to click the function button on the mobile terminal interface to manually upload the log.

[0138] On the other hand, the log upload module 130 obtains the application scenario type of the mobile terminal and uploads the log according to the upload strategy corresponding to the application scenario type of the mobile terminal, specifically including: when the application scenario type of the mobile terminal is an application for general users, the log is uploaded according to the automatic upload strategy.

[0139] Operations personnel cannot and should not contact general users. Mobile terminals upload logs according to the automatic upload policy to facilitate maintenance personnel to identify problems.

[0140] Upload logs according to the automatic upload policy, including but not limited to the following steps:

[0141] Split the logs;

[0142] Add a new log upload task through the log upload task producer and save the log upload task in the log upload task storage center;

[0143] The log upload task consumer obtains the log upload task from the log upload task storage center and calls the log uploader to upload the split logs.

[0144] When the log upload is successful, the log upload task is deleted from the log upload task storage center; when the log upload fails, the log upload task is obtained from the log upload task storage center again through the log upload task consumer.

[0145] In this embodiment, the mobile terminal outputs the log to the logger through the log recording interface, and the logger writes the log to different file directories to obtain log files according to the context. The logger also splits the log. A new log upload task is added through the log upload task producer, and the log upload task is saved in the log upload task storage center. The log upload task consumer waits for the log upload task in a loop. When the log upload task storage center has a new log upload task, the log upload task consumer obtains the log upload task from the log upload task storage center and calls the log uploader to upload the split log. When the log upload is successful, the log upload task is deleted from the log upload task storage center; when the log upload fails, the log upload task consumer continues to wait for the log upload task in a loop. As the case may be, the log upload task restorer restores the log upload task in the log upload task storage center, and the log upload task is obtained from the log upload task storage center again through the log upload task consumer, and the log uploader is called to upload the split log.

[0146] In this embodiment, the operating environment information of the mobile terminal is obtained through the log recording module 110, and a log corresponding to the log level and the operating environment information is recorded; the context type information of the log is obtained through the log storage module 120, and the log is stored according to the storage strategy corresponding to the context type information; the application scenario type of the mobile terminal is obtained through the log uploading module 130, and the log is uploaded according to the upload strategy corresponding to the application scenario type of the mobile terminal; different recording strategies, storage strategies and upload strategies can be adopted for different situations to achieve a better log processing strategy and improve the operability of the log of the mobile terminal.

[0147] It can be understood that the contents of the log processing method embodiment are applicable to the log processing device embodiment. The functions specifically implemented by the log processing device embodiment are the same as those of the log processing method embodiment, and the beneficial effects achieved are also the same as those achieved by the log processing method embodiment.

[0148] To achieve the above-mentioned purpose, the embodiment of the present application further provides an electronic device. Figure 10 , Figure 10 2 is a structural diagram of an electronic device. The electronic device includes a memory 220, a processor 210, a program stored in the memory 220 and executable on the processor 210, and a data bus 230 for enabling communication between the processor 210 and the memory 220. When the program is executed by the processor 210, the aforementioned log processing method is implemented, namely, executing steps S100 to S300, steps S211 and S212, steps S221 and S222, steps S231 and S232, steps S310 and S320, and steps S321 to S325.

[0149] In this embodiment, by obtaining the operating environment information of the mobile terminal, a log corresponding to the log level and the operating environment information is recorded; the context type information of the log is obtained, and the log is stored according to the storage strategy corresponding to the context type information; the application scenario type of the mobile terminal is obtained, and the log is uploaded according to the upload strategy corresponding to the application scenario type of the mobile terminal; different recording strategies, storage strategies and upload strategies can be adopted for different situations to achieve a better log processing strategy and improve the operability of the log of the mobile terminal.

[0150] Memory 220, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer executable programs, such as the log processing in the above-mentioned embodiments of the present invention. Processor 210 implements the log processing in the above-mentioned embodiments of the present invention by running the non-transitory software programs and programs stored in memory 220.

[0151] The memory 220 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data required to execute the log processing in the above-mentioned embodiment of the present invention, etc. In addition, the memory 220 may include a high-speed random access memory 220, and may also include a non-volatile memory 220, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 220 may optionally include a memory 220 remotely located relative to the processor 210, and these remote memories 220 may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0152] To achieve the above-mentioned purpose, an embodiment of the present application further provides a computer-readable storage medium, which stores computer-executable instructions. The computer-executable instructions are used to enable the computer to execute the above-mentioned log processing method, that is, to execute steps S100 to S300, steps S211 and S212, steps S221 and S222, steps S231 and S232, steps S310 and S320, and steps S321 to S325.

[0153] In this embodiment, by obtaining the operating environment information of the mobile terminal, a log corresponding to the log level and the operating environment information is recorded; the context type information of the log is obtained, and the log is stored according to the storage strategy corresponding to the context type information; the application scenario type of the mobile terminal is obtained, and the log is uploaded according to the upload strategy corresponding to the application scenario type of the mobile terminal; different recording strategies, storage strategies and upload strategies can be adopted for different situations to achieve a better log processing strategy and improve the operability of the log of the mobile terminal.

[0154] Those skilled in the art will appreciate that all or some of the steps and systems in the method disclosed above can be implemented as software, firmware, hardware, and appropriate combinations thereof. Some physical components or all physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, and the computer-readable medium can include computer storage media (or non-transitory media) and communication media (or temporary media). As known to those skilled in the art, the term computer storage media is included in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data) and is volatile and non-volatile, removable, and non-removable. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory, or other memory technology, CD-ROM, digital versatile disks (DVD), or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage, or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. In addition, it is well known to those skilled in the art that communication media generally contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium. In the above description of this specification, the reference terms "one embodiment / example", "another embodiment / example" or "certain embodiments / examples" and the like are intended to mean that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0155] Although the embodiments of the present application have been shown and described, those skilled in the art will appreciate that various changes, modifications, substitutions, and variations may be made to the embodiments without departing from the principles and intent of the present application, and that the scope of the present application is defined by the claims and their equivalents.

[0156] The above is a specific description of the preferred implementation of the present application, but the present application is not limited to the embodiments. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present application, and these equivalent modifications or substitutions are all included in the scope defined by the claims of the present application.

[0157] In the description of this specification, reference to the terms "one embodiment," "another embodiment," or "certain embodiments" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in any appropriate manner in any one or more embodiments or examples.

Claims

1. A log processing method, characterized in that: Applied to a mobile terminal, the log processing method includes: Obtaining the operating environment information of the mobile terminal, and recording a log with a log level corresponding to the operating environment information; Obtaining context type information of the log, and storing the log according to a storage policy corresponding to the context type information; Obtaining an application scenario type of the mobile terminal, and uploading the log according to an upload policy corresponding to the application scenario type of the mobile terminal; The context type information of the log includes a data statistics type for batch usage data records; obtaining the context type information of the log and storing the log according to a storage policy corresponding to the context type information includes: According to the storage policy corresponding to the data statistics type, the file segmentation size of the log is determined to be a first segmentation value, the maximum number of files of the log is determined to be a first file number value, the maximum disk storage size of the file of the log is determined to be a first storage value, and the file segmentation period of the log is determined to be a first period value; storing the log according to the first segmentation value, the first file quantity value, the first storage value, and the first period value; The context type information of the log also includes a business logic type for identifying business logic problems; obtaining the context type information of the log and storing the log according to a storage policy corresponding to the context type information includes: According to the storage policy corresponding to the business logic type, the file segmentation size of the log is determined to be a second segmentation value, the maximum number of files of the log is determined to be a second file number value, the maximum disk storage size of the file of the log is determined to be a second storage value, and the file segmentation period of the log is determined to be a second period value; storing the log according to the second segmentation value, the second file quantity value, the second storage value, and the second period value; Wherein, the second segmentation value is smaller than the first segmentation value; the second file quantity value is larger than the first file quantity value; the second storage value is larger than the first storage value; and the second period value is equal to the first period value; The context type information of the log includes a performance monitoring type for monitoring the performance of the mobile terminal; and obtaining the context type information of the log and storing the log according to a storage policy corresponding to the context type information includes: According to the storage policy corresponding to the performance monitoring type, determining the file segmentation size of the log to be a third segmentation value, determining the maximum number of files of the log to be a third file number value, determining the maximum disk storage size of the file of the log to be a third storage value, and determining the file segmentation period of the log to be a third period value; storing the log according to the third segmentation value, the third file quantity value, the third storage value, and the third period value; Among them, the third segmentation value is smaller than the second segmentation value; the third file quantity value is larger than the first file quantity value and smaller than the second file quantity value; the third storage value is smaller than the first storage value; and the third period value is smaller than the first period value.

2. A log processing method according to claim 1, characterized in that: The obtaining of the operating environment information of the mobile terminal and recording a log corresponding to a log level of the operating environment information includes: When the operating environment information is in a test state, a log with a verbose level and a log with a debug level are recorded; wherein the log with a verbose level records the detailed process of all operating steps of the mobile terminal, and the log with a debug level records the detailed process of key operating steps of the mobile terminal; When the operating environment information is an online application status, logs with an information level, a warning level, and an error level are recorded; wherein, the logs with an information level record the attention information of the mobile terminal, the logs with a warning level record the operating alarm information, and the logs with an error level record the operating error information.

3. A log processing method according to claim 1, characterized in that: The obtaining the application scenario type of the mobile terminal and uploading the log according to the upload policy corresponding to the application scenario type of the mobile terminal includes: When the application scenario type of the mobile terminal is an application for general users, uploading the log according to the automatic uploading strategy; When the application scenario type of the mobile terminal is an application for a specified user, the log is uploaded according to a manual upload strategy.

4. A log processing method according to claim 3, characterized in that: Uploading the log according to the automatic upload strategy includes: Segmenting the log; A log upload task producer adds a new log upload task and saves the log upload task in a log upload task storage center; Obtain the log upload task from the log upload task storage center through the log upload task consumer, and call the log uploader to upload the split log; When the log upload is successful, the log upload task is deleted from the log upload task storage center; when the log upload fails, the log upload task is obtained again from the log upload task storage center through the log upload task consumer.

5. A log processing device, characterized in that: Applied to a mobile terminal, the log processing device includes: A log recording module, configured to obtain operating environment information of the mobile terminal and record a log having a log level corresponding to the operating environment information; a log storage module, configured to obtain context type information of the log and store the log according to a storage policy corresponding to the context type information; A log uploading module, configured to obtain an application scenario type of the mobile terminal and upload the log according to an uploading strategy corresponding to the application scenario type of the mobile terminal; The context type information of the log includes a data statistics type for batch usage data records; obtaining the context type information of the log and storing the log according to a storage policy corresponding to the context type information includes: According to the storage policy corresponding to the data statistics type, the file segmentation size of the log is determined to be a first segmentation value, the maximum number of files of the log is determined to be a first file number value, the maximum disk storage size of the file of the log is determined to be a first storage value, and the file segmentation period of the log is determined to be a first period value; storing the log according to the first segmentation value, the first file quantity value, the first storage value, and the first period value; The context type information of the log also includes a business logic type for identifying business logic problems; obtaining the context type information of the log and storing the log according to a storage policy corresponding to the context type information includes: According to the storage policy corresponding to the business logic type, the file segmentation size of the log is determined to be a second segmentation value, the maximum number of files of the log is determined to be a second file number value, the maximum disk storage size of the file of the log is determined to be a second storage value, and the file segmentation period of the log is determined to be a second period value; storing the log according to the second segmentation value, the second file quantity value, the second storage value, and the second period value; Wherein, the second segmentation value is smaller than the first segmentation value; the second file quantity value is larger than the first file quantity value; the second storage value is larger than the first storage value; and the second period value is equal to the first period value; The context type information of the log includes a performance monitoring type for monitoring the performance of the mobile terminal; and obtaining the context type information of the log and storing the log according to a storage policy corresponding to the context type information includes: According to the storage policy corresponding to the performance monitoring type, determining the file segmentation size of the log to be a third segmentation value, determining the maximum number of files of the log to be a third file number value, determining the maximum disk storage size of the file of the log to be a third storage value, and determining the file segmentation period of the log to be a third period value; storing the log according to the third segmentation value, the third file quantity value, the third storage value, and the third period value; Among them, the third segmentation value is smaller than the second segmentation value; the third file quantity value is larger than the first file quantity value and smaller than the second file quantity value; the third storage value is smaller than the first storage value; and the third period value is smaller than the first period value.

6. An electronic device, characterized in that: The electronic device includes a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for implementing connection and communication between the processor and the memory. When the program is executed by the processor, the log processing method according to any one of claims 1 to 4 is implemented.

7. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the log processing method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Log processing method, device, storage medium and terminal device

    CN108108285A

  • Log file management method and device, computer equipment and storage medium

    CN110222020A