CN113064874A - Method and device for recording log - Google Patents

Method and device for recording log Download PDF

Info

Publication number
CN113064874A
CN113064874A CN202110479032.4A CN202110479032A CN113064874A CN 113064874 A CN113064874 A CN 113064874A CN 202110479032 A CN202110479032 A CN 202110479032A CN 113064874 A CN113064874 A CN 113064874A
Authority
CN
China
Prior art keywords
information
target
field
statement
meta
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110479032.4A
Other languages
Chinese (zh)
Inventor
黄进兵
吕勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
BEIJING CERTIFICATE AUTHORITY
Original Assignee
BEIJING CERTIFICATE AUTHORITY
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by BEIJING CERTIFICATE AUTHORITY filed Critical BEIJING CERTIFICATE AUTHORITY
Priority to CN202110479032.4A priority Critical patent/CN113064874A/en
Publication of CN113064874A publication Critical patent/CN113064874A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/211Schema design and management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the application provides a method and a device for recording logs, wherein the method comprises the following steps: acquiring service request information through a target interface; according to the target interface, target log statement information corresponding to the target interface is searched, the target log statement information is used for stating that log recording is carried out through a target insertion statement, and the target insertion statement is constructed by at least one field meta-information; and acquiring a target insertion statement according to the target log statement information, and performing log recording on the service request information by using the target insertion statement. According to the method and the device, the insertion statement can be constructed through at least one field meta-information, so that the user does not need to execute the processes of writing codes, testing the codes and online, and the code development efficiency can be improved.

Description

Method and device for recording log
Technical Field
The present application relates to the field of computers, and in particular, to a method and an apparatus for logging.
Background
In software development and delivery operation and maintenance, an access detail log of a software system is recorded in a database (for example, a relational database), which is an important component function, and can record the access behavior of the software system, so that the behavior can be analyzed from the log afterwards or the software system has a business requirement for retrieving the log.
However, the conventional method for developing the log has a problem of relatively low development efficiency. For example, in the case of adding a log table, the process of development, test and online is required, which causes a problem of low development efficiency.
Disclosure of Invention
An embodiment of the present application aims to provide a method and an apparatus for recording a log, so as to solve a problem in the prior art that development efficiency is relatively low.
In a first aspect, an embodiment of the present application discloses a method for recording a log, where the method includes: acquiring service request information through a target interface; according to the target interface, target log statement information corresponding to the target interface is searched, the target log statement information is used for stating that log recording is carried out through a target insertion statement, and the target insertion statement is constructed by at least one field meta-information; and acquiring a target insertion statement according to the target log statement information, and performing log recording on the service request information by using the target insertion statement.
Therefore, the insertion statement can be constructed through at least one field meta-information, so that the processes of writing codes, testing codes and online are not required to be executed by a user, and the code development efficiency can be improved.
In one possible embodiment, before obtaining the service request information through the target interface, the method further includes: acquiring a construction request of a target insert statement, wherein the construction request carries first identification information of each field meta-information in at least one field meta-information and second identification information of each closure function in at least one closure function, and each closure function in at least one closure function is used as a value-taking algorithm of a variable field in the target insert statement; searching each field meta-information according to the first identification information of each field meta-information; constructing a target insertion statement according to each field meta-information; and setting a value-taking algorithm of a variable field in the target insertion statement according to the second identification information of each closure function.
Therefore, by means of the technical scheme, the automatic construction of the insertion statement can be achieved, the user does not need to write the insertion statement from the beginning, and therefore the development efficiency can be greatly improved.
In one possible embodiment, the constructing of the target insert statement according to each field meta information includes: searching a target sentence construction template corresponding to the target insertion sentence from a plurality of sentence construction templates; and constructing a template according to each field meta-information and the target sentence, and constructing the target insertion sentence.
In one possible embodiment, the method further comprises: acquiring a modification request of a target insertion statement through a target interface; and modifying the target insert statement according to the modification request.
In one possible embodiment, the at least one field meta-information comprises at least one of the following information: built-in field meta-information, request field meta-information, response field meta-information, context field meta-information, fixed value field meta-information, extension field meta-information, and custom field meta-information.
Therefore, by means of the technical scheme, the embodiment of the application can construct various insert statements, so that various logs can be recorded.
In a second aspect, an embodiment of the present application discloses an apparatus for logging, including: the first acquisition module is used for acquiring the service request information through the target interface; the first searching module is used for searching target log statement information corresponding to a target interface according to the target interface, wherein the target log statement information is used for stating that log recording is carried out through a target insertion statement, and the target insertion statement is constructed by at least one field meta-information; and the recording module is used for acquiring the target insertion statement according to the target log statement information and performing log recording on the service request information by using the target insertion statement.
In one possible embodiment, the apparatus further comprises: a second obtaining module, configured to obtain a construction request of the target insert statement before obtaining service request information through the target interface, where the construction request carries first identification information of each field meta information in the at least one field meta information and second identification information of each closure function in the at least one closure function, and each closure function in the at least one closure function is used as a value-taking algorithm for a variable field in the target insert statement; the second searching module is used for searching each field meta-information according to the first identification information of each field meta-information; the construction module is used for constructing a target insertion statement according to each field meta-information; and the setting module is used for setting a value-taking algorithm of the variable field in the target insertion statement according to the second identification information of each closure function.
In one possible embodiment, the building block is specifically configured to: searching a target sentence construction template corresponding to the target insertion sentence from a plurality of sentence construction templates; and constructing a template according to each field meta-information and the target sentence, and constructing the target insertion sentence.
In one possible embodiment, the apparatus further comprises: the third acquisition module is used for acquiring a modification request of the target insertion statement through the target interface; and the modification module is used for modifying the target insertion statement according to the modification request.
In one possible embodiment, the at least one field meta-information comprises at least one of the following information: built-in field meta-information, request field meta-information, response field meta-information, context field meta-information, fixed value field meta-information, extension field meta-information, and custom field meta-information.
In a third aspect, an embodiment of the present application provides a storage medium, where a computer program is stored on the storage medium, and when the computer program is executed by a processor, the computer program performs the method according to the first aspect or any optional implementation manner of the first aspect.
In a fourth aspect, an embodiment of the present application provides an electronic device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when the electronic device is running, the machine-readable instructions when executed by the processor performing the method of the first aspect or any of the alternative implementations of the first aspect.
In a fifth aspect, the present application provides a computer program product which, when run on a computer, causes the computer to perform the method of the first aspect or any possible implementation manner of the first aspect.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
FIG. 1 illustrates a flow chart of a method for developing a log provided by the prior art;
FIG. 2 is a flow chart illustrating a method for constructing an insert statement according to an embodiment of the present application;
FIG. 3 is a flow chart illustrating a method for logging provided by an embodiment of the present application;
fig. 4 shows a block diagram of a device for logging according to an embodiment of the present application;
fig. 5 shows a block diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
In software development and delivery operation and maintenance, an access detail log of a software system is recorded in a relational database, which is an important component function and can record key access behaviors of the software system, so that the behavior can be analyzed from the log afterwards or the software system has service requirements for retrieving the log.
Referring to fig. 1, fig. 1 is a flowchart illustrating a method for developing a log according to the prior art. The method shown in fig. 1 comprises:
in step S110, a database Data schema Definition Language (DDL) statement of the database table is created or modified. The DDL statement is used for creating a table structure statement or modifying the table structure statement.
It should be understood that the table structure may be created manually or automatically by software at startup.
Step S120, an insertion statement for table row data insertion is created. Wherein the insert statement is used to inform the database to insert a specified value into a specified field of a specified table, and the insert statement may be a Structured Query Language (SQL) statement.
It should be understood that the insertion statement may be written directly by a software developer, or may be generated by an Object Relational Mapping (ORM) tool capable of automatically Mapping a specific structure of speech, etc., as long as it is guaranteed to be submitted to a database server, so that the insertion of the table data can be completed.
It should also be understood that the ORM tool may be an object relational mapping framework Hibernate of open source code, MyBatis, etc.
In order to facilitate understanding of step S120, the following description is made by way of specific examples.
Specifically, because the fields to be recorded are different from place to place, different insert statements need to be created, and the fields to be recorded need to be in one-to-one correspondence with the content of the record.
In addition, when the table structure is changed, the corresponding fields and the bound values need to be adjusted to adapt to the change of the table structure.
Step S130, binding values corresponding to the variables in the insertion statement. The insertion statement includes at least one variable, and each variable in the at least one variable has a corresponding value (for example, when the insertion statement includes a name variable, the obtained name "zhang san" may be bound to the name variable).
Specifically, the value corresponding to each variable in the binding insertion statement also relates to the basic constraints of the database design, such as the type of the value of the variable and the length of the value of the variable.
For example, a field is defined as varcha (10), and the meaning of the field is to limit the maximum length of the character string to 10, which will cause the subsequent step S140 to fail if the bound variable value exceeds the maximum length of the corresponding field of the creation table structure. Moreover, the basic requirement of ordinary logging is that the execution of the service is not affected, the failure of log insertion will cause the interruption of the service execution, and at this time, the code for logging needs to be adjusted so that the maximum length check passes.
In step S140, an insert statement is executed.
Further, in the case where the table structure is changed, steps S110 to S140 may be re-executed.
However, the conventional method for developing the log has at least the following problems:
log data needs to record what information needs to be configured in the code. For example, when writing a log to a log table in a relational database, an insert statement needs to be written in a code, and then different values are obtained according to different fields bound by the insert statement, and then the values are submitted to a database server. However, for different services, different log formats need to be recorded, each log format needs to be supported by a new code, and then a test on-line process is performed, which is relatively inefficient. For the same format, the field information of the record may need to be added or adjusted, and the log writing code still needs to be adjusted;
the access points which need to record the log are realized by directly adding the log record of a specific access point in a specific code corresponding to the corresponding service access point by the service;
in terms of code quality, the codes for recording the logs have a large number of similar codes except for the table names of the recorded logs, different fields of the log records and different value modes of the fields, and thus, the codes are repeated in a large number. Moreover, the contents of the log record also often need to be adjusted, the log table structure also often expands, and the log implementation code also frequently changes.
In other words, the existing method for developing the log has at least the following problems: when a generation mode and a field value taking mode need to be written manually and log writing is executed, the efficiency is low and errors are easy to occur; a specific service log needs to be implemented in each specific service implementation, resulting in a large number of similar codes; when the log structure is upgraded and maintained, the code, the reconstruction generation mode and the field value taking mode need to be changed, so that the workload is increased; log-structured meta-information is hard coded in the code and is not easily shared between different languages of the microservice.
In short, the conventional method for developing the log has the problem of relatively low development efficiency. For example, in the case of adding a log table, the process of development, test and online is required, which causes a problem of low development efficiency. For another example, when an existing log table structure needs to be added or adjusted, a process of development, testing and online is still required.
Based on this, the embodiment of the present application skillfully provides a scheme for logging, in which service request information is obtained through a target interface, target log declaration information corresponding to the target interface is searched according to the target interface, the target log declaration information is used to declare that logging is performed through a target insertion statement, the target insertion statement is constructed by at least one field meta-information, the target insertion statement is obtained according to the target log declaration information, and the service request information is logged by using the target insertion statement.
Therefore, the insertion statement can be constructed through at least one field meta-information, so that the processes of writing codes, testing codes and online are not required to be executed by a user, and the code development efficiency can be improved.
To facilitate understanding of the embodiments of the present application, some terms referred to in the present application are explained below:
"built-in class field meta-information": it is used to indicate the type of supported field meta-information built in. Such as the current time, the address of the current machine, and the current machine name, etc.
"request class field meta-information": it is used to represent the information carried by the access object when it requests access. For example, a request IP address and an IP address of an access object, etc.
"response class field meta information": it may refer to replying to information to access an object after a request is performed. Such as execution time, success of execution results, execution status, etc.
"context field meta information": it is used to indicate specific fields of a particular fetch in the current request body. For example, requesting a username in the content, etc.
"fixed value field meta information": it may refer to a fixed, unchanging value set by the user. For example, a fixed value of "identity verification service" may be set, and each generated log includes this field, whose value is fixed and does not become "identity verification service".
"extended class field meta-information": it requires the user to expand the type of design setting.
"custom field meta-information": it may be a setting value that the user can customize by a code.
"closure function": when the returned value of a function is another function and the returned function calls other variables inside its parent function, a closure is generated if the returned function is executed externally.
Referring to fig. 2, fig. 2 is a flowchart illustrating a method for constructing an insert statement according to an embodiment of the present application. It should be understood that the method shown in fig. 2 may be executed by an apparatus for constructing an insertion sentence, and the apparatus may be various devices capable of executing the method, such as a personal computer or a server (for example, a single server or a server cluster may be used), and the embodiments of the present application are not limited thereto. The method for constructing the insert statement as shown in FIG. 2 comprises the following steps:
step S210, a request for constructing a target insert statement is obtained. The construction request carries first identification information of each field meta-information in at least one field meta-information and second identification information of each closure function in at least one closure function, and each closure function can be used as a value-taking algorithm of a variable field in the target insertion statement.
It should be understood that, specific information corresponding to each field meta information in the at least one field meta information may be set according to actual requirements, and the embodiment of the present application is not limited thereto.
Optionally, the at least one field meta-information comprises at least one of the following information: built-in field meta-information, request field meta-information, response field meta-information, context field meta-information, fixed value field meta-information, extension field meta-information, and custom field meta-information.
It should be understood that the information included in the built-in class field meta-information may be set according to actual requirements, and the embodiment of the present application is not limited thereto.
For example, referring to table 1 below, table 1 shows information contained in the built-in class field meta information.
TABLE 1
Built-in type field meta-information Description of the invention
httplog:“id” Log record identification ID
httplog:“created” Creation time
httplog:“ip” Current machine IP
httplog:“hostname” Current machine name
httplog:“pid” Application Process number PID
httplog:“started” Start time (e.g., yyyy-MM-dd HH: MM: ss. SSS)
httplog:“end” End time (e.g., yyyy-MM-dd HH: MM: ss. SSS)
httplog:“cost” Takes time (e.g., milliseconds)
httplog:“biz” Business name, biz corresponding to httplog annotation
httplog:“exception” Abnormal information
Note that httplog in table 1 indicates HTTP log. Correspondingly, httplog in other tables is similar, and will not be described one by one subsequently.
It should be noted that the time format is shown in parentheses such as "yyyy-MM-dd HH: MM: ss.SSS" and "millisecond" in Table 1.
It should be noted here that the field meta information in table 1 above indicates the form of the code stored in the system. Correspondingly, other tables are similar and will not be described one by one subsequently.
It should also be understood that the information included in the request class field meta-information may be set according to actual requirements, and the embodiment of the present application is not limited thereto.
For example, see table 2 below, where table 2 shows the information contained in the request class field meta information.
TABLE 2
Figure BDA0003047620270000091
Figure BDA0003047620270000101
It should also be understood that the information included in the response class field meta-information may be set according to actual requirements, and the embodiment of the present application is not limited thereto.
It should be noted here that "xxx" in table 2 represents a placeholder, which needs to be replaced with an actual name in actual use. Such as name, age, address, etc.
Correspondingly, "xxx" appearing elsewhere is similar to "xxx" in table 2, and will not be described one by one subsequently, see the above description specifically.
For example, please refer to table 3 below, where table 3 shows the information contained in the response class field meta information.
TABLE 3
Figure BDA0003047620270000102
Figure BDA0003047620270000111
It should also be understood that the information included in the context field meta-information may be set according to actual requirements, and the embodiments of the present application are not limited thereto.
For example, please refer to table 4 below, where table 4 shows the information contained in the context field meta information.
TABLE 4
Context field meta information Description of the invention
httplog:“ctx_xxx” Value of context object xxx
It should also be understood that the information contained in the fixed value field meta information may be set according to actual requirements, and the embodiment of the present application is not limited thereto.
For example, referring to table 5 below, table 5 shows information contained in the fixed value field meta information.
TABLE 5
Fixed value field meta information Description of the invention
httplog:"fix_xxx" Fixed value specified by fix parameter
It should also be understood that the information included in the extension class field meta information may be set according to actual requirements, and the embodiment of the present application is not limited thereto.
For example, referring to table 6 below, table 6 shows the information contained in the extended class field meta information.
TABLE 6
Extended class field meta-information Description of the invention
httplog:“pre_xxx” Attribute values given by custom extender pre
httplog:“post_xxx” Attribute values given by custom extender post
It should also be understood that the information included in the custom field meta information may be set according to actual requirements, and the embodiment of the present application is not limited thereto.
For example, see table 7 below, where table 7 shows the information contained in the custom field meta information.
TABLE 7
Figure BDA0003047620270000121
It should be noted here that the field meta information may be stored in a formatted form in the comment of the field, or may be stored in a configuration system in a configuration manner.
It should also be understood that the specific identification information corresponding to the first identification information may also be set according to actual requirements, and the embodiment of the present application is not limited thereto.
It should also be understood that the specific function corresponding to each closure function in the at least one closure function may also be set according to actual requirements, and the embodiment of the present application is not limited thereto.
It should also be understood that the specific identification information corresponding to the second identification information may also be set according to actual requirements, and the embodiment of the present application is not limited thereto.
It should also be understood that specific field information corresponding to a variable field in a target insertion statement may also be set according to actual requirements, and the embodiment of the present application is not limited thereto.
For example, the variable field in the target insert statement may include the IP of the access object, the access time, etc.
It should also be understood that the specific algorithm corresponding to the value-taking algorithm of the variable field may also be set according to actual requirements, and the embodiment of the present application is not limited thereto.
For example, the value-taking algorithm may be used to convert the collected field information into a specific format corresponding to the variable field (for example, in a case that the time format corresponding to the variable field is millisecond, the obtained time format may be converted into millisecond).
Step S220, searching each field meta-information according to the first identification information of each field meta-information.
Specifically, each field meta-information is correspondingly provided with corresponding first identification information, so that in the process of constructing the target insertion statement, a user can select which field meta-information is utilized to construct the target insertion statement and can set a value-taking algorithm in the target insertion statement. Therefore, the device searches the corresponding field meta-information by using the first identification information of each field meta-information in the at least one field meta-information selected by the user.
Step S230, according to each field meta information, a target insert statement is constructed.
It should be understood that, according to each field meta information, a specific process of constructing the target insertion statement may be set according to actual requirements, and the embodiment of the present application is not limited thereto.
Optionally, since the construction request may carry the third identification information of the target insertion sentence, and a plurality of insertion sentences and sentence construction templates corresponding to each insertion sentence may be preset, the target sentence construction template corresponding to the target insertion sentence may be searched from the plurality of sentence construction templates according to the third identification information of the target insertion sentence carried in the construction request, and then the target insertion sentence may be constructed according to each field meta information and the target sentence construction template.
It should also be understood that, the template is constructed according to each field meta-information and the target statement, and the specific process of constructing the target insertion statement may also be set according to actual requirements, and the embodiment of the present application is not limited thereto.
For example, corresponding field meta-information may be embedded in corresponding locations in the target sentence building template.
Step S240, setting a value-taking algorithm of the variable field in the target insertion statement according to the second identification information of each closure function.
Specifically, although the target insertion sentence has been constructed in step S230, the variable field in the target insertion sentence is not set in value. Therefore, the corresponding variable field in the target insertion statement can be set according to the second identification information of each closure function.
Therefore, by means of the technical scheme, the automatic construction of the insertion statement can be achieved, the user does not need to write the insertion statement from the beginning, and therefore the development efficiency can be greatly improved.
It should be understood that the above method for constructing the insert sentence is only exemplary, and those skilled in the art can make various modifications according to the above method, and the solution after the modification also belongs to the protection scope of the present application.
It should be noted that, on the basis of fig. 2, a person skilled in the art can record a log according to the constructed target insertion statement.
In order to facilitate understanding of the embodiments of the present application, the following description will be given by way of specific examples.
Referring to fig. 3, fig. 3 is a flowchart illustrating a method for logging according to an embodiment of the present application. It should be understood that the method shown in fig. 3 may be executed by a logging apparatus, which may correspond to the logging apparatus shown in fig. 4 below, and the logging apparatus may be various devices capable of executing the method, such as a personal computer or a server (for example, the server may be a single server, or may be a distributed system, etc.), and the embodiments of the present application are not limited thereto. The method of logging as in fig. 3 comprises:
step S310, obtain the service request information through the target interface.
It should be understood that the specific interface corresponding to the target interface may be set according to actual requirements, and the embodiment of the present application is not limited thereto.
It should also be understood that the specific information corresponding to the service request information may also be set according to actual requirements, and the embodiment of the present application is not limited thereto.
For example, the service request information may be payment request information or the like.
Step S320, according to the target interface, finding the target log declaration information corresponding to the target interface. Wherein the target journal declaration information is used to declare that the journal recording is performed by a target insertion statement, which is constructed by at least one field meta information.
Specifically, because each of the plurality of interfaces is correspondingly provided with log declaration information, and each of the log declaration information can declare that data passing through the current interface is recorded by using a corresponding insertion statement (for example, it can be determined from the first log declaration information that data passing through the first interface is recorded by using the first insertion statement, that is, log recording of data of the first interface is realized by using the first insertion statement), the target log declaration information corresponding to the target interface can be searched according to the target interface.
Step S330, according to the target log statement information, obtaining a target insertion statement, and using the target insertion statement to log the service request information.
Specifically, since the target log declaration information is used to declare that the logging is performed by the target insertion statement, the target insertion statement can be acquired according to the target log declaration information. Subsequently, after the target insert statement is obtained, the service request information can be logged by using the insert statement.
In addition, in the case that there is a modification request for the target insertion statement, the modification request for the target insertion statement may be acquired through the target interface, and then the target insertion statement may be modified according to the modification request.
It should be understood that, although the description is given by taking the modification request of the target insertion statement through the target interface as an example, those skilled in the art should understand that it may also obtain the modification request through other interfaces, and the embodiments of the present application are not limited thereto.
It should also be understood that, according to the modification request, the specific process of modifying the target insertion statement may be set according to actual requirements, and the embodiment of the present application is not limited thereto.
Alternatively, in the case of an add/drop to a target insert statement, the target insert statement may be changed only if the log meta information is changed (e.g., a record field is added or subtracted).
For example, when the log meta-information is deleted, the target insert statement may be deleted, indicating that such log is no longer recorded. And under the condition that the record field is not added or deleted, the target insertion statement does not change when the value mode of the record field is changed, but the closure function of the variable field is changed.
Therefore, the insertion statement can be constructed through at least one field meta-information, so that the processes of writing codes, testing codes and online are not required to be executed by a user, and the code development efficiency can be improved.
In addition, the embodiment of the application declares the mode that the corresponding service needs to record the log through the log declaration information, so that the problem caused by a recording writing method of the specific log, which is tedious in manual coding, time-consuming and labor-consuming, is solved.
In addition, according to the embodiment of the application, when the log record needs to be changed (for example, the content of the log record is increased or the content of the log record is adjusted), only the field meta information needs to be adjusted, and codes do not need to be rewritten, retested and redeployed, so that the deployment efficiency is improved.
It should be understood that the above-mentioned method for logging is only exemplary, and those skilled in the art can make various modifications according to the above-mentioned method, and the solution after the modification also falls into the scope of the present application.
Referring to fig. 4, fig. 4 is a block diagram illustrating a structure of an apparatus 400 for logging logs according to an embodiment of the present disclosure. It should be understood that the apparatus 400 is capable of executing the steps of the above-mentioned logging method, and the specific functions of the apparatus 400 can be referred to the above description, and the detailed description is appropriately omitted here to avoid redundancy. The device 400 includes at least one software function module that can be stored in a memory in the form of software or firmware (firmware) or solidified in an Operating System (OS) of the device 400. Specifically, the apparatus 400 includes:
a first obtaining module 410, configured to obtain service request information through a target interface; a first searching module 420, configured to search, according to a target interface, target log declaration information corresponding to the target interface, where the target log declaration information is used to declare that log recording is performed through a target insertion statement, and the target insertion statement is constructed by at least one field meta information; and the recording module 430 is configured to obtain the target insertion statement according to the target log declaration information, and perform log recording on the service request information by using the target insertion statement.
In one possible embodiment, the apparatus 400 further comprises: a second obtaining module (not shown) configured to obtain a construction request of the target insert statement before obtaining service request information through the target interface, where the construction request carries first identification information of each field meta information in the at least one field meta information and second identification information of each closure function in the at least one closure function, and each closure function in the at least one closure function is used as a value-taking algorithm of a variable field in the target insert statement; a second search module (not shown) for searching each field meta-information according to the first identification information of each field meta-information; a construction module (not shown) for constructing a target insertion sentence according to each field meta information; and a setting module (not shown) configured to set a value-taking algorithm of a variable field in the target insertion statement according to the second identification information of each closure function.
In one possible embodiment, the building block is specifically configured to: searching a target sentence construction template corresponding to the target insertion sentence from a plurality of sentence construction templates; and constructing a template according to each field meta-information and the target sentence, and constructing the target insertion sentence.
In one possible embodiment, the apparatus 400 further comprises: a third obtaining module (not shown) for obtaining a modification request of the target insertion statement through the target interface; and a modification module (not shown) for modifying the target insert statement according to the modification request.
In one possible embodiment, the at least one field meta-information comprises at least one of the following information: built-in field meta-information, request field meta-information, response field meta-information, context field meta-information, fixed value field meta-information, extension field meta-information, and custom field meta-information.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working process of the apparatus described above may refer to the corresponding process in the foregoing method, and will not be described in too much detail herein.
Referring to fig. 5, fig. 5 is a block diagram illustrating an electronic device 500 according to an embodiment of the present disclosure. As shown in fig. 5. Electronic device 500 may include a processor 510, a communication interface 520, a memory 530, and at least one communication bus 540. Wherein the communication bus 540 is used for realizing direct connection communication of these components. The communication interface 520 of the device in the embodiment of the present application is used for performing signaling or data communication with other node devices. Processor 510 may be an integrated circuit chip having signal processing capabilities. The Processor 510 may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor 510 may be any conventional processor or the like.
The Memory 530 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like. The memory 530 stores computer readable instructions that, when executed by the processor 510, the electronic device 500 may perform the steps of the above-described method embodiments.
The electronic device 500 may further include a memory controller, an input-output unit, an audio unit, and a display unit.
The memory 530, the memory controller, the processor 510, the peripheral interface, the input/output unit, the audio unit, and the display unit are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these elements may be electrically coupled to each other via one or more communication buses 540. The processor 510 is adapted to execute executable modules stored in the memory 530, such as software functional modules or computer programs comprised by the electronic device 500.
The input and output unit is used for providing input data for a user to realize the interaction of the user and the server (or the local terminal). The input/output unit may be, but is not limited to, a mouse, a keyboard, and the like.
The audio unit provides an audio interface to the user, which may include one or more microphones, one or more speakers, and audio circuitry.
The display unit provides an interactive interface (e.g. a user interface) between the electronic device and a user or for displaying image data to a user reference. In this embodiment, the display unit may be a liquid crystal display or a touch display. In the case of a touch display, the display can be a capacitive touch screen or a resistive touch screen, which supports single-point and multi-point touch operations. The support of single-point and multi-point touch operations means that the touch display can sense touch operations simultaneously generated from one or more positions on the touch display, and the sensed touch operations are sent to the processor for calculation and processing.
The input and output unit is used for providing input data for a user to realize the interaction between the user and the processing terminal. The input/output unit may be, but is not limited to, a mouse, a keyboard, and the like.
It will be appreciated that the configuration shown in FIG. 5 is merely illustrative and that the electronic device 500 may include more or fewer components than shown in FIG. 5 or may have a different configuration than shown in FIG. 5. The components shown in fig. 5 may be implemented in hardware, software, or a combination thereof.
The present application provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the method of any of the alternative implementations.
The present application provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the method of any of the alternative implementations.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process of the system described above may refer to the corresponding process in the foregoing method, and will not be described in too much detail herein.
It should be noted that, in the present specification, the embodiments are all described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. For the device-like embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes. It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method of logging, comprising:
acquiring service request information through a target interface;
according to the target interface, target log statement information corresponding to the target interface is searched, the target log statement information is used for stating that log recording is carried out through a target insertion statement, and the target insertion statement is constructed by at least one field meta-information;
and acquiring the target insertion statement according to the target log statement information, and performing log recording on the service request information by using the target insertion statement.
2. The method of claim 1, wherein before the obtaining service request information via the target interface, the method further comprises:
obtaining a construction request of the target insertion statement, where the construction request carries first identification information of each field meta-information in the at least one field meta-information and second identification information of each closure function in the at least one closure function, and each closure function in the at least one closure function is used as a value-taking algorithm of a variable field in the target insertion statement;
searching each field meta-information according to the first identification information of each field meta-information;
constructing the target insertion statement according to the meta information of each field;
and setting a value-taking algorithm of a variable field in the target insertion statement according to the second identification information of each closure function.
3. The method of claim 2, wherein said constructing the target insert statement according to the per-field meta information comprises:
searching a target sentence construction template corresponding to the target insertion sentence from a plurality of sentence construction templates;
and constructing a template according to the meta information of each field and the target sentence, and constructing the target insertion sentence.
4. The method of claim 1, further comprising:
acquiring a modification request of the target insertion statement through the target interface;
and modifying the target insertion statement according to the modification request.
5. The method of claim 1, wherein the at least one field meta-information comprises at least one of: built-in field meta-information, request field meta-information, response field meta-information, context field meta-information, fixed value field meta-information, extension field meta-information, and custom field meta-information.
6. An apparatus for logging, comprising:
the first acquisition module is used for acquiring the service request information through the target interface;
the first searching module is used for searching target log statement information corresponding to the target interface according to the target interface, wherein the target log statement information is used for stating that log recording is carried out through a target insertion statement, and the target insertion statement is constructed by at least one field meta-information;
and the recording module is used for acquiring the target insertion statement according to the target log statement information and performing log recording on the service request information by using the target insertion statement.
7. The apparatus of claim 6, further comprising:
a second obtaining module, configured to obtain a construction request of the target insertion statement before obtaining service request information through a target interface, where the construction request carries first identification information of each field meta information in the at least one field meta information and second identification information of each closure function in the at least one closure function, and each closure function in the at least one closure function is used as a value-taking algorithm for a variable field in the target insertion statement;
the second searching module is used for searching each field meta-information according to the first identification information of each field meta-information;
the building module is used for building the target insertion statement according to the meta information of each field;
and the setting module is used for setting the value-taking algorithm of the variable field in the target insertion statement according to the second identification information of each closure function.
8. The apparatus according to claim 7, wherein the building block is specifically configured to: searching a target sentence construction template corresponding to the target insertion sentence from a plurality of sentence construction templates; and constructing a template according to the meta information of each field and the target sentence, and constructing the target insertion sentence.
9. The apparatus of claim 6, further comprising:
a third obtaining module, configured to obtain, through the target interface, a modification request of the target insertion statement;
and the modification module is used for modifying the target insertion statement according to the modification request.
10. The apparatus of claim 6, wherein the at least one field meta-information comprises at least one of: built-in field meta-information, request field meta-information, response field meta-information, context field meta-information, fixed value field meta-information, extension field meta-information, and custom field meta-information.
CN202110479032.4A 2021-04-29 2021-04-29 Method and device for recording log Pending CN113064874A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110479032.4A CN113064874A (en) 2021-04-29 2021-04-29 Method and device for recording log

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110479032.4A CN113064874A (en) 2021-04-29 2021-04-29 Method and device for recording log

Publications (1)

Publication Number Publication Date
CN113064874A true CN113064874A (en) 2021-07-02

Family

ID=76567964

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110479032.4A Pending CN113064874A (en) 2021-04-29 2021-04-29 Method and device for recording log

Country Status (1)

Country Link
CN (1) CN113064874A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113535529A (en) * 2021-07-22 2021-10-22 中国银联股份有限公司 Service log analysis method and device and computer readable storage medium
CN114721916A (en) * 2022-03-08 2022-07-08 北京健康之家科技有限公司 Log generation method and device, terminal equipment and medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113535529A (en) * 2021-07-22 2021-10-22 中国银联股份有限公司 Service log analysis method and device and computer readable storage medium
CN113535529B (en) * 2021-07-22 2024-05-17 中国银联股份有限公司 Service log analysis method, device and computer readable storage medium
CN114721916A (en) * 2022-03-08 2022-07-08 北京健康之家科技有限公司 Log generation method and device, terminal equipment and medium

Similar Documents

Publication Publication Date Title
CN111767057B (en) Data processing method and device
CA2684822C (en) Data transformation based on a technical design document
CN107368593B (en) Data import method and device and server
CN108762743B (en) Data table operation code generation method and device
CN113064874A (en) Method and device for recording log
US7720814B2 (en) Repopulating a database with document content
JP2013077246A (en) Method, apparatus, and program for supporting creation and management of metadata for correcting problem in dynamic web application
US11244025B2 (en) Systems and methods for updating data pipelines
CN113076104A (en) Page generation method, device, equipment and storage medium
CN111552690A (en) Data generation method, device, terminal and storage medium
CN111159045A (en) Compatibility problem detection method, device and storage medium
CN114201615B (en) Scientific research data change review method and server based on data snapshot
US10678864B2 (en) Analysis model preparing system, programming apparatus, and analysis model preparing method
US20180314683A1 (en) Method and device for processing natural language
US9104573B1 (en) Providing relevant diagnostic information using ontology rules
US20230289331A1 (en) Model generation service for data retrieval
WO2017049715A1 (en) Page construction method, apparatus and device, and nonvolatile computer storage medium
CN110705715A (en) Hyper-parameter management method and device and electronic equipment
CN109726376B (en) Standard template generation method and device and electronic equipment
US11327994B2 (en) Arranging converted operation history information
CN113485689A (en) Buried point processing method and device
JP6870454B2 (en) Analytical equipment, analytical programs and analytical methods
CN112732681B (en) Data platform migration method and system
CN110908725A (en) Application program starting method and device, electronic equipment and readable medium
CN116661758B (en) Method, device, electronic equipment and medium for optimizing log framework configuration

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination