A method and device for recording application logs

By introducing software development toolkits and reading configuration files, the problem of lack of unified configuration and inability to change real-time in the recording of application logs in the prior art is solved, and efficient logging and performance optimization are achieved.

CN111949472BActive Publication Date: 2025-03-18BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201910412428.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-05-17
Publication Date
2025-03-18
Estimated Expiration
2039-05-17

AI Technical Summary

Technical Problem

The method of recording application logs in the prior art lacks unified configuration, cannot change the configuration in real time, there is duplicate code, and the performance impact is great when written directly to the database.

Method used

Introduce a software development toolkit to read configuration files, record logs based on the configuration files after the application is started, and send the logs to the storage unit to read and listen to configuration file updates periodically.

Benefits of technology

It realizes unified configuration for recording application logs, supports real-time configuration changes, avoids duplicate code, and reduces the burden on application performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111949472B_ABST
    Figure CN111949472B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for recording application logs, and relates to the field of computer technology. A specific implementation of the method includes: introducing a software development kit for recording application logs, reading a configuration file for recording application logs, and recording the log of the application after the application is started according to the configuration file, and then sending the application log to a storage unit. This implementation can provide a unified configuration for recording application logs, and support real-time changes to the configuration, avoiding duplicate codes for generating application logs, thereby reducing the adverse effects on the application itself caused by recording logs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for recording application logs. Background Art

[0002] The method of recording application logs in the existing technical solutions is basically that each application, according to business needs, adds an interceptor or a tag to directly write the application log into a database or send it to a message queue for consumption and storage.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0004] 1. There is no unified configuration, which is not conducive to subsequent auditing and analysis.

[0005] 2. The configuration of recording application logs cannot be changed in real time. For example, when you need to increase or decrease the recording of certain operation logs, you need to modify and update the application.

[0006] 3. There is duplicate code, and each application needs to add interceptors or tags, which increases the burden of application development.

[0007] 4. In the scenario where application logs are directly written to the database, when logs are generated frequently, it will have a significant adverse impact on the performance of the current application. Summary of the invention

[0008] In view of this, an embodiment of the present invention provides a method and device for recording application logs, which can provide a unified configuration for recording application logs and support real-time modification of the configuration, thereby avoiding repeated code for generating application logs, thereby reducing the adverse impact of logging on the performance of the current application.

[0009] To achieve the above-mentioned purpose, according to one aspect of an embodiment of the present invention, a method for recording application logs is provided, comprising: introducing a software development kit for recording application logs; reading a configuration file for recording application logs; recording the application logs after the application is started according to the configuration file; and sending the application logs to a storage unit.

[0010] Furthermore, after the application is started, the configuration file is read periodically.

[0011] Furthermore, after the application is started, it monitors whether the configuration file is updated, and records the application log according to the updated configuration file.

[0012] Furthermore, the log is parsed, and the parsed log information is recorded in a database.

[0013] Furthermore, the configuration file includes one or more of the following: application information, module information, and method information of the application.

[0014] Furthermore, the log is sent to the storage unit using a message queue.

[0015] According to another aspect of an embodiment of the present invention, an embodiment of the present invention provides a system for recording application logs, including an application unit, a configuration unit and a storage unit; wherein the application unit is used to introduce a software development kit for recording application logs, read a configuration file for recording application logs from the configuration unit, record application logs according to the configuration file, and send the application logs to the storage unit; the configuration unit is used to generate a configuration file; and the storage unit is used to receive and store application logs.

[0016] Furthermore, after the application is started, the application unit periodically reads the configuration file.

[0017] Furthermore, after the application is started, the application unit monitors whether the configuration file is updated, and records the application log according to the updated configuration file.

[0018] Furthermore, the storage unit parses the log and records the log information obtained after the parsing into the database.

[0019] Furthermore, the configuration file includes one or more of the following: application information, module information, and method information of the application.

[0020] Furthermore, the application unit sends the log to the storage unit using the message queue.

[0021] According to one aspect of an embodiment of the present invention, a server is provided, comprising: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement any of the methods for recording application logs as described above.

[0022] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, any one of the above-mentioned methods for recording application logs is implemented.

[0023] One embodiment of the above invention has the following advantages or beneficial effects: because a software development kit for recording application logs is introduced, a configuration file for recording application logs is read, and after the application is started, the application log is recorded according to the configuration file, and the application log is sent to a storage unit. Therefore, by introducing a software development kit for recording application logs, duplicate codes for generating application logs are effectively avoided, and the operating efficiency of the application is improved; by reading the configuration file, a unified configuration for recording application logs is provided, and the configuration can be changed in real time; by sending the application log to the storage unit, the adverse effect of recording logs on the performance of the current application is further reduced.

[0024] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0026] Figure 1 is a main flow chart of a method for recording application logs provided according to a first embodiment of the present invention;

[0027] Figure 2 is a main flow chart of a method for recording application logs provided according to a second embodiment of the present invention;

[0028] Figure 3 is a schematic diagram of the main structure of a system for recording application logs provided according to an embodiment of the present invention;

[0029] Figure 4 According to an embodiment of the present invention, the Figure 3 The main flow chart of the method for recording application logs of the recording application log system;

[0030] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0031] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0032] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0033] Figure 1 is a main flow chart of a method for recording application logs according to a first embodiment of the present invention. Figure 1 As shown, an embodiment of the present invention provides a method for recording application logs, which mainly includes the following steps:

[0034] Step S101: introducing a software development kit for recording application logs.

[0035] Furthermore, after introducing a software development kit for recording application logs, the method further includes implementing a portion of the log interface to inherit the abstract class provided by the software development kit, and implementing a method for recording application logs provided by the software development kit. Through the above steps, duplicate code for generating application logs is avoided, thereby reducing the adverse impact on the performance of the current application due to logging.

[0036] Step S102, reading a configuration file for recording application logs.

[0037] According to an implementation of an embodiment of the present invention, after the application is started, the configuration file is periodically read, thereby enabling the application to obtain the latest configuration information regularly, realizing online configuration update of the application, and avoiding additional releases.

[0038] According to an implementation of an embodiment of the present invention, the configuration file includes one or more of the following: application information, module information and method information of the application. The configuration file provides configuration information for recording application logs of each application, thereby achieving unified management of configurations of each application.

[0039] According to an implementation of an embodiment of the present invention, after the application is started, the configuration file is monitored to see if it is updated, and the application log is recorded according to the updated configuration file. Through the above steps, the application can obtain the latest configuration information in real time, which is suitable for scenarios with high requirements for the immediacy of the configuration of recording application logs.

[0040] Step S103: Record the application log according to the configuration file after the application is started.

[0041] Step S104, sending the application log to the storage unit. By sending the application log to the storage unit, the application log is avoided from being stored in the application, the operation efficiency of the application is improved, and the adverse effect of recording the log on the performance of the current application is further reduced.

[0042] According to an implementation of an embodiment of the present invention, the log is parsed, and the parsed log information is recorded in a database. By parsing the log information, the number of logs can be further screened, the efficiency of log recording is improved, and the storage space of the storage unit is increased.

[0043] According to one implementation of an embodiment of the present invention, a message queue is used to send logs to a storage unit. By sending the above logs to the storage unit by means of a message queue, the adverse effects of recording logs on the performance of the current application are further reduced. In a specific implementation, the application log is written to the message queue in an asynchronous manner. The asynchronous method ensures that the writing of the current application log is not affected by the message queue, and at the same time, the message queue can temporarily store log data, which not only avoids the loss of application logs, but also effectively reduces the peak value caused by the sharp increase in application logs, thereby improving the writing efficiency of application logs.

[0044] Because a software development kit for recording application logs is introduced, a configuration file for recording application logs is read, and after the application is started, the application log is recorded according to the configuration file, and the application log is sent to the storage unit. Therefore, by introducing a software development kit for recording application logs, duplicate codes for generating application logs are effectively avoided, and the operating efficiency of the application is improved; by reading the configuration file, a unified configuration for recording application logs is provided, and the configuration can be changed in real time; by sending the application log to the storage unit, the adverse effect of recording logs on the performance of the current application is further reduced.

[0045] Figure 2 is a main flow chart of a method for recording application logs according to a second embodiment of the present invention; Figure 2 As shown, an embodiment of the present invention provides a method for recording application logs, including:

[0046] Step S201, introduce the SDK for recording application logs. By extracting the relevant classes required for log recording into common classes and encapsulating them into SDK (Software Development Kit), each application only needs to introduce the SDK, avoiding the writing of repeated codes for generating application logs.

[0047] Step S202, implement a partial log interface. The step of implementing a partial log interface includes a log section class and a log reporting class, wherein the log section class inherits the abstract class in the public class, and is used to implement the method of obtaining the operating user and the method of calling the log reporting class. The log reporting class generates a log by calling the log recording method in the public class and reports the log to the log recording system. The SDK includes a public class for logging, and then by implementing a partial log interface, it can inherit the abstract class provided by the SDK, and can also implement the logging method of the non-public class.

[0048] Step S203, add a configuration file to complete the initialization of the class in the SDK. Since the class in the SDK cannot be automatically loaded into the application framework, the class in the SDK is defined in the configuration file and loaded when the application starts, thereby completing the initialization of the class in the SDK.

[0049] According to one implementation of an embodiment of the present invention, the classes in the SDK that need to be initialized include: a logging configuration class, which obtains the configuration information of the corresponding application from the configuration center system through the application code; a log aspect class inherits the abstract class in the public class, which is used to implement the method of obtaining the operating user and the method of calling the log reporting class. The log reporting class generates logs by calling the logging method in the public class and reports the logs to the logging system; a log AOP (Aspect Oriented Programming) related configuration, which is used to intercept the aspect instance, call the corresponding aspect embedding expression and the execution method after the aspect is embedded. In a specific implementation, after the log AOP related configuration is embedded in the aspect, the logging configuration class obtains the configuration information in the configuration file, and the log aspect class determines whether to record the log based on the configuration information. If the judgment result is yes, the log reporting class generates the log and sends the log to the log generation system.

[0050] Step S204, periodically obtain the configuration file. This allows the application to obtain the latest configuration information regularly, realizes online application configuration update, and avoids additional releases. It should be noted that in actual operation, for different application scenarios, the above steps can also monitor whether the configuration file is updated, and record the application log according to the updated configuration file.

[0051] Step S205: Record the application log according to the configuration file after the application is started.

[0052] Step S206, sending the log to the storage unit. By sending the log to the storage unit, it is avoided to store the application log in the application, the operation efficiency of the application is improved, and the adverse effect of recording the log on the performance of the current application is reduced.

[0053] In a specific implementation, after the log AOP related configuration is embedded in the aspect, the log recording configuration class obtains the configuration information in the configuration file. The log aspect class determines whether to record the log based on the configuration information. If the judgment result is yes, the log reporting class generates the log and sends the log to the log generation system.

[0054] Figure 3 is a main schematic diagram of a system for recording application logs provided according to an embodiment of the present invention; Figure 3 As shown, an embodiment of the present invention provides a system 300 for recording application logs, including:

[0055] The application unit 301 is used to introduce a software development kit for recording application logs; read a configuration file for recording application logs from the configuration unit 302; record application logs according to the configuration file; and send the application logs to the storage unit 303;

[0056] By introducing a software development kit for recording application logs, the duplication of code for generating application logs is effectively avoided, thereby improving the operating efficiency of the application. By reading configuration files, a unified configuration for recording application logs is provided, and real-time changes to the configuration are supported. By sending application logs to a storage unit, the adverse effects of logging on the application are further reduced.

[0057] According to an implementation of the present invention, after the application is started, the application unit 301 periodically reads the configuration file, thereby enabling the application to obtain the latest configuration information regularly, realizing online update configuration of the application, and avoiding additional release and release.

[0058] According to an implementation of an embodiment of the present invention, after the application is started, the application unit 301 monitors whether the configuration file is updated, and records the application log according to the updated configuration file. Through the above settings, the application can obtain the latest configuration information in real time, which is suitable for scenarios with high requirements for the immediacy of the configuration of recording application logs.

[0059] According to an implementation of the present invention, the application unit 301 uses a message queue to send the application log to the storage unit 303. Sending the application log to the storage unit by means of a message queue further reduces the adverse effect of recording the application log on the performance of the current application.

[0060] The configuration unit 302 is used to generate a configuration file. Through the above settings, online update configuration is achieved, avoiding the need to re-publish the application.

[0061] According to an implementation of an embodiment of the present invention, the configuration file includes one or more of the following: application information, module information, and method information of the application. The configuration file provides configuration information of each application, and implements unified management of configurations of each application.

[0062] The storage unit 303 is used to receive and store application logs. By storing application logs in the storage unit, the occupation of application logs on the application space is reduced, and the operation efficiency of the current application is further improved.

[0063] According to an implementation of an embodiment of the present invention, the storage unit 302 parses the log and records the parsed log information to the database. By parsing the log information, the log can be further screened as much as possible, the efficiency of log recording is improved, and the storage space of the storage unit is increased.

[0064] According to an implementation of an embodiment of the present invention, the configuration file includes one or more of the following: application information, module information and method information of the application. The above log is sent to the storage unit by means of a message queue, further reducing the adverse effect of recording the log on the current application.

[0065] According to a specific implementation of an embodiment of the present invention, after the storage unit 303 receives the application log sent by the application unit 301, it writes the log asynchronously into the message queue; then consumes the log information from the message queue; parses the log information, and judges the message structure of the log information. If the message structure is a JSON (JavaScript Object Notation, a lightweight data exchange format) structure, the judgment result is correct; when the message structure of the log message is correct, the log recording module and the log recording method corresponding to the log message are verified according to the configuration file. If the verification passes, the log is stored in the database.

[0066] like Figure 4 As shown, according to an embodiment of the present invention, a main flow chart of a method for recording application logs applied to any of the above-mentioned application log recording systems is provided, including:

[0067] In the configuration unit, the application configuration information is configured, wherein the configuration information includes one or more of the following: application information of the application, module information of the log recording module in the application, and method information for recording logs. The configuration information can be modified, deleted, marked effective, and marked invalid.

[0068] According to an implementation of an embodiment of the present invention, the application information includes an application code and one or more of the following: a system code to which the application belongs, a system name to which the application belongs, and an application name. The application code is unique and can be modified, deleted, marked as valid, or marked as invalid.

[0069] First, the configuration unit configures the application information of each application. After the application is configured, the application is selected to configure the module information of the log recording module in the application.

[0070] According to an implementation of an embodiment of the present invention, the module information includes the module name and the module class. The module information can be used to determine a unique module entry. In an actual project using the spring framework, the module class corresponds to the full path class name.

[0071] Furthermore, after the module information configuration is completed, the log recording module is selected to configure the log recording method.

[0072] According to an implementation of an embodiment of the present invention, the method information includes: method name, method description and method parameters. Among them, the method name refers to the specific method name of the class of the module, and the method parameter is a JSON (JavaScript Object Notation, a lightweight data exchange format) structure, which defines a parameter object array, for example: [{"name":"userInfo","type":"com.xxx.UserInfo"},{"name":"userTypeList","type":"java.util.List"}], it can be seen that each parameter object has 2 contents, where name is the specific parameter name of the method, and type is the parameter type. The parameter object array composed of the above parameter name and parameter type can determine a unique logging method.

[0073] After the above configuration information is configured, a configuration file for recording application logs is obtained. In a specific implementation, the configuration unit provides a query port, and the application unit can query and obtain the configuration information for recording application logs of the corresponding application by inputting the application code.

[0074] Through the above steps, when the configuration information consisting of one or more of the application information, module information and method information is configured, a configuration file for recording application logs is obtained. At this time, the latest configuration information can be obtained through the above query port, thereby achieving the purpose of managing each application configuration.

[0075] In the application unit, first introduce the SDK for recording application logs, and inherit the abstract class in the SDK by implementing some log interfaces, thereby effectively avoiding duplicate codes for generating application logs.

[0076] Furthermore, when the application is started, the classes in the SDK are loaded to implement the initialization of the classes in the SDK. Through this step, the definition of the classes required for recording application logs in the application is implemented. Specifically, the classes in the SDK that need to be initialized include: a log recording configuration class, which obtains the configuration information of the corresponding application from the configuration center system through the application code; a log aspect class inherits the abstract class in the public class, which is used to implement the method of obtaining the operating user and the method of calling the log reporting class. The log reporting class generates logs by calling the log recording method in the public class and reports the logs to the log recording system; a log AOP (Aspect Oriented Programming) related configuration is used to intercept the aspect instance, call the corresponding aspect embedding expression and the execution method after the aspect is embedded. In a specific embodiment, after the log AOP related configuration is embedded in the aspect, the log recording configuration class obtains the configuration information, and the log aspect class determines whether to record the application log according to the configuration information. If the judgment result is yes, the application log is generated by the log reporting class and the application log is sent to the log generation system.

[0077] Furthermore, the application unit periodically obtains a configuration file for recording application logs from the configuration unit. It should be noted that, for different application scenarios, the application unit can also monitor whether the configuration file is updated, and record the application log according to the updated configuration file, so as to achieve the purpose of changing the configuration in real time.

[0078] Furthermore, the application unit records the application log according to the configuration file after the application is started, and then asynchronously sends the application log to the storage unit via http (HyperText Transfer Protocol).

[0079] In the storage unit, the storage unit receives the application log sent by the application unit and writes the application log asynchronously to the message queue. The asynchronous method ensures that the writing of the current application log is not affected by the message queue, and the message queue can also temporarily store log data, which not only avoids the loss of application logs, but also effectively reduces the peak value caused by the sharp increase of application logs, and improves the writing efficiency of application logs.

[0080] Further, the message is logged from the message queue.

[0081] Furthermore, the log message is parsed, and by parsing the log information, the number of logs can be further screened, the efficiency of log recording is improved, and the storage space of the storage module is increased. At the same time, the message structure of the parsed log information is judged. If the message structure of the log message is a JSON structure, the judgment result is correct and the next step is continued; if the message structure of the log message is a non-JSON structure, the judgment result is wrong and the log message is not stored.

[0082] Furthermore, the storage unit verifies the log recording module and log recording method corresponding to the log message according to the configuration file, and if the verification is passed, the log is stored in the database. The specific operation method of the verification is to check whether the module for recording application logs and the method for recording application logs corresponding to the application log are reflected in the configuration file, and if so, the verification is passed.

[0083] Because a software development kit for recording application logs is introduced, a configuration file for recording application logs is read, and after the application is started, the application log is recorded according to the configuration file, and the application log is sent to the storage unit. Therefore, by introducing a software development kit for recording application logs, duplicate codes for generating application logs are effectively avoided, and the operating efficiency of the application is improved; by reading the configuration file, a unified configuration for recording application logs is provided, and the configuration can be changed in real time; by sending the application log to the storage unit, the adverse effect of recording logs on the performance of the current application is further reduced.

[0084] Figure 5 An exemplary system architecture 500 is shown to which the method for recording application logs or the system for recording application logs according to the embodiments of the present invention can be applied.

[0085] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0086] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0087] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0088] The server 505 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 501, 502, and 503. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information and product information) to the terminal device.

[0089] It should be noted that the method for recording application logs provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the system for recording application logs is generally set in the server 505 .

[0090] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0091] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present invention. Figure 6 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0092] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0093] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.

[0094] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.

[0095] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0096] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0097] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes an application unit, a configuration unit, and a storage unit. The names of these units do not constitute a limitation on the units themselves in some cases, for example, the configuration unit may also be described as a "unit for generating a configuration file".

[0098] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: introducing a software development kit for recording application logs, reading a configuration file for recording application logs, and recording the log of the application according to the configuration file after the application is started, and then sending the application log to a storage unit.

[0099] According to the technical solution of the embodiment of the present invention, a software development kit for recording application logs is introduced, a configuration file for recording application logs is read, and after the application is started, the application log is recorded according to the configuration file, and the application log is sent to the storage unit. Therefore, by introducing a software development kit for recording application logs, duplicate codes for generating application logs are effectively avoided, and the operating efficiency of the application is improved; by reading the configuration file, a unified configuration for recording application logs is provided, and real-time changes to the configuration are supported; by sending the application log to the storage unit, the adverse effects of recording logs on the performance of the current application are further reduced.

[0100] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for recording application logs, characterized in that: include: Introduce a software development kit for recording application logs: extract the relevant classes required for logging into public classes; Implement some log interfaces; specifically include: log section class and log reporting class; the log section class inherits the abstract class in the public class, and is used to implement the method of obtaining the operation user and the method of calling the log reporting class; the log reporting class generates a log by calling the log recording method in the public class, and reports the log; wherein the public class is extracted by the relevant class required for log recording; Reading a configuration file for recording application logs; wherein the configuration file includes: application information, module information and / or method information of the application; According to the configuration file, after the application is started, recording a log of the application; Sending the application log to a storage unit; The method further includes: after the application is started, monitoring whether the configuration file is updated, and recording a log of the application according to the updated configuration file.

2. The method for recording application logs according to claim 1, characterized in that: After the application is started, the configuration file is read periodically.

3. The method for recording application logs according to claim 1 or 2, characterized in that: The log is parsed, and the parsed log information is recorded in a database.

4. The method for recording application logs according to claim 1, characterized in that: The log is sent to a storage unit using a message queue.

5. A system for recording application logs, characterized in that: It includes an application unit, a configuration unit and a storage unit; wherein, The application unit is used to introduce a software development kit for recording application logs: extract relevant classes required for log recording into public classes; implement part of the log interface; specifically include: log aspect class and log reporting class; the log aspect class inherits the abstract class in the public class, and is used to implement the method of obtaining the operating user and the method of calling the log reporting class; the log reporting class generates a log by calling the log recording method in the public class, and reports the log; wherein the public class is extracted by the relevant classes required for log recording; read the configuration file for recording application logs from the configuration unit; record the log of the application according to the configuration file; send the application log to the storage unit; the configuration unit is used to generate the configuration file; wherein the configuration file includes: application information, module information and / or method information of the application; The storage unit is used to receive and store the application log; After the application is started, the application unit is used to monitor whether the configuration file is updated, and record the log of the application according to the updated configuration file.

6. The system for recording application logs according to claim 5, characterized in that: After the application is started, the application unit periodically reads the configuration file.

7. The system for recording application logs according to claim 5 or 6, characterized in that: The storage unit parses the log and records the parsed log information into a database.

8. The system for recording application logs according to claim 5, characterized in that: The application unit sends the log to the storage unit by using a message queue.

9. A server, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Behaviour log data management system and behaviour log data management method

    CN103023693A