CN113672564A - Method, system and medium for application program log recording - Google Patents
Method, system and medium for application program log recording Download PDFInfo
- Publication number
- CN113672564A CN113672564A CN202110899771.9A CN202110899771A CN113672564A CN 113672564 A CN113672564 A CN 113672564A CN 202110899771 A CN202110899771 A CN 202110899771A CN 113672564 A CN113672564 A CN 113672564A
- Authority
- CN
- China
- Prior art keywords
- log
- file
- classification
- record
- recording
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 33
- 230000005012 migration Effects 0.000 claims abstract description 55
- 238000013508 migration Methods 0.000 claims abstract description 55
- 230000006835 compression Effects 0.000 claims abstract description 7
- 238000007906 compression Methods 0.000 claims abstract description 7
- 230000001360 synchronised effect Effects 0.000 claims description 6
- 238000010276 construction Methods 0.000 claims description 5
- 238000004590 computer program Methods 0.000 claims description 2
- 230000006870 function Effects 0.000 description 3
- 238000010586 diagram Methods 0.000 description 2
- 241000282414 Homo sapiens Species 0.000 description 1
- 206010063385 Intellectualisation Diseases 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/16—File or folder operations, e.g. details of user interfaces specifically adapted to file systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/11—File system administration, e.g. details of archiving or snapshots
- G06F16/119—Details of migration of file systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/172—Caching, prefetching or hoarding of files
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/1734—Details of monitoring file system events, e.g. by the use of hooks, filter drivers, logs
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/174—Redundancy elimination performed by the file system
- G06F16/1744—Redundancy elimination performed by the file system using compression, e.g. sparse files
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/18—File system types
- G06F16/1805—Append-only file systems, e.g. using logs or journals to store data
- G06F16/1815—Journaling file systems
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a method, a system and a medium for logging application programs, wherein the method comprises the following steps: setting a log classification rule and a log migration reference condition; acquiring a log parameter set, and constructing a log record class according to the log parameter set; acquiring log information of an application program; according to the log record class, executing log record operation on the log information to obtain a plurality of log files; according to the log classification rule, file classification operation is executed to obtain a plurality of classification log files; acquiring first attribute information of the classification log file; performing compression uploading operation on the classification log files according to the first attribute information and the log migration reference condition; by the mode, the invention realizes unified recording of all kinds of logs through log record types, and improves the working efficiency; the recorded log files are classified, so that the problems are conveniently positioned and solved, and the workload is reduced; the log file is saved through the file server, and the file storage safety is improved.
Description
Technical Field
The present invention relates to the field of log recording, and in particular, to a method, system, and medium for application log recording.
Background
With the increasing development of computer technology and the prevalence of electronization and intellectualization, more and more work is replaced by application programs. In order to better serve human beings, the application program is continuously updated, and besides a certain function is required to be added, the iterative updating of the application program is mainly used for solving the problem of the previous version. How to locate the problem requires logging information such as nodes where the problem has occurred with respect to the steps of operating the application.
The existing log record is to uniformly record all logs and store the logs in the local application program, when a problem occurs and a log file needs to be consulted, the problem needs to be looked up from a huge log file, and then the problem is located, which is a large workload, the difficulty in looking up is large, the problem is difficult to locate, and the log is stored in the local area, so that the log file is easily lost, and certain difficulty is brought to the subsequent location problem.
Disclosure of Invention
The invention mainly solves the problems that the application program is easy to lose when being stored locally, the log files are not classified by the existing log recording method, and the work difficulty is high through the log positioning problem.
In order to solve the above problems, the present invention adopts a technical solution that: there is provided a method of application logging, comprising the steps of:
initialization: setting a log classification rule and a log migration reference condition;
constructing a log record class: acquiring a log parameter set, and constructing a log record class according to the log parameter set;
recording a log: acquiring log information of an application program; according to the log record class, executing log record operation on log information to obtain a plurality of log files;
and log file classification: according to the log classification rule, performing file classification operation on the log files to obtain a plurality of classification log files;
uploading a log file: acquiring first attribute information of the classification log file; and performing compression uploading operation on the classified log files according to the first attribute information and the log migration reference condition.
Further, the logging step further comprises:
constructing log contents: acquiring log information of the application program; according to the log information, log record content is constructed;
log caching: according to the log record class, writing the log record content into a log cache queue;
starting a thread: opening a log write-in sub-thread, and adding a synchronous lock to the log cache queue;
log writing: and executing the log recording operation on the log recording content in the log cache queue through the log write-in sub-thread to obtain a plurality of log files.
Further, the log parameter set comprises a number of first log reference parameters; the step of constructing a log record class according to the set of log parameters further comprises:
generating a plurality of log recording strategies according to the first log reference parameters; and constructing the log record class according to a plurality of log record strategies.
Further, the log information includes a first log parameter, a second log parameter, and a third log parameter; the step of log caching further comprises:
calling the corresponding log recording strategy in the log recording class according to the first log parameter; and writing the log record content into a log cache queue through the log record strategy.
Further, the step of performing the logging operation further comprises:
acquiring the corresponding log file according to the first log parameter; writing the log record content into the log file;
if the log file does not exist, executing log file construction operation;
and if the log file exists, recording the log record content to the tail part of the log file.
Further, the step of invoking the log file construction policy further comprises:
calling the logging strategy according to the first logging parameter, and constructing the log file corresponding to the first logging parameter; and recording the log record content to the tail part of the log file.
Further, the step of performing a compressed upload operation on the classified log file according to the first attribute information and the log migration reference condition further includes:
comparing the first attribute information with the log migration reference condition:
if the first attribute information accords with the log migration reference condition, compressing the corresponding classification log file to obtain a compressed classification log file; uploading the compressed classified log file;
and if the first attribute information does not accord with the log migration reference condition, continuously storing the log classified file corresponding to the log in the current position.
A system for application logging, comprising: the system comprises an initialization module, a log record building module, a log record recording module, a log file classification module and a log file uploading module;
the initialization module is used for setting log classification rules and log migration reference conditions;
the log record constructing module is used for acquiring a log parameter set and constructing a log record class according to the log parameter set;
the log recording module is used for acquiring log information of the application program; according to the log record class, executing log record operation on log information to obtain a plurality of log files;
the log file classification module is used for executing file classification operation on the log files according to the log classification rule to obtain a plurality of classification log files;
the log file uploading module is used for acquiring first attribute information of the classified log files; and performing compression uploading operation on the classified log files according to the first attribute information and the log migration reference condition.
Further, the log recording module comprises a log content constructing unit, a log caching unit, a thread opening unit and a log writing unit;
the log content constructing unit is used for acquiring log information of the application program; according to the log information, log record content is constructed;
the log caching unit is used for writing the log record content into a log caching queue according to the log record class;
the thread opening unit is used for opening a log write-in sub-thread and adding a synchronous lock to the log cache queue;
the log writing unit is used for executing the log recording operation on the log recording content in the log cache queue through the log writing sub-thread to obtain a plurality of log files.
The invention also provides a computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method for application logging.
The invention has the beneficial effects that:
1. the method for recording the application program logs can realize that the records of all kinds of logs are matched through the general log record class, the records of the logs are managed uniformly, the records of the logs and the subsequent problems are convenient to locate, and the working efficiency is improved;
2. the system for recording the application program log can classify the recorded log files, is convenient for searching and positioning problems through the log files subsequently, reduces the workload of workers and improves the efficiency of positioning and solving the problems;
3. the application program log recording medium can upload the local log files meeting the conditions to a special file server, prevent the local log files from being lost, improve the safety of file storage and simultaneously provide guarantee for the problem of log positioning in the follow-up process.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a method for logging an application according to embodiment 1 of the present invention;
fig. 2 is a flowchart of a logging step of a method for logging an application according to embodiment 1 of the present invention;
FIG. 3 is a schematic diagram of a system for application logging according to embodiment 2 of the present invention;
fig. 4 is a schematic diagram of a logging module of the system for logging an application according to embodiment 2 of the present invention.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the description of the present invention, it should be noted that, unless explicitly specified or limited otherwise, terms such as "log classification rule", "log migration reference condition", "log parameter set", "log record class", "log information", "log file", "first attribute information", "compressed upload", "log record content", "log cache queue", "synchronization lock", "child thread", "log record policy", "log file construction", "tail", "current location", "transaction log", "flow log", "operation log", "transaction number", "message" and the like should be understood in a broad sense. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
Furthermore, the terms "first", "second", "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first," "second," or "third" may explicitly or implicitly include at least one of the feature.
Example 1
An embodiment of the present invention provides a method for logging an application program, please refer to fig. 1 and fig. 2, including the following steps:
s100, initialization:
setting a log classification rule and a log migration reference condition of a log file, wherein the log classification rule is that log files recorded subsequently are classified according to a certain rule, so that the log can be conveniently checked, problems can be conveniently positioned and the like; the log migration reference condition is that when the local log of the application program is migrated according to the set condition, the local log is migrated to a specific log server for storage, and when the log migration reference condition is satisfied, the migration is initiated, and if the log migration reference condition is not satisfied, the migration is not performed.
The log classification rule and the setting of the log migration reference condition can be set according to actual requirements, and the setting of the log migration reference condition needs to take the storage space of a server or a terminal where the application program is located into consideration.
In order to explain the invention more clearly, the log classification rule is set here as that the logs are classified according to the time integral point, namely, the logs in the same hour are recorded in a log file, the log migration reference condition is set as that the log file is migrated when the creation time of the log file exceeds 30 days, namely, the time of the current day is obtained, 30 days are subtracted from the time of the current day to obtain a date, and the log files created before the date need to be migrated to a log server; it should be noted that the setting is only for explaining the implementation process of the present invention, and the protection scope of the present invention is not limited thereby.
S200, constructing a log record class:
collecting all first log reference parameters, namely log types, according to requirements, acquiring a common recording format according to the log types, and compiling a log recording strategy corresponding to each log type through codes to obtain a plurality of log recording strategies; and planning a plurality of log recording strategies into the same log tool class to obtain a log recording class.
The log types here may be all log types that are disclosed in the prior art, or all log types that need to be used by the application, for example: it should be noted that the examples herein are merely for explaining the present invention, and the protection scope of the present invention is not limited thereby.
The recording format here may be a general logging format, or a personalized logging format may be set according to actual requirements, for example: the transaction log needs to record a transaction number, a transaction uploading message, transaction uploading time, a transaction result, a transaction returning message, and transaction returning time, and it should be noted that the examples herein are merely for explaining the present invention, and the protection scope of the present invention cannot be limited thereby.
The logging policy here may be a method or an ordered combination of codes used to solve a class of problems in computer languages such as functions, and is a functional code module.
A journaling class, as used herein, refers to a class in a computer language, which is a template that describes the behavior and state of a class of objects.
S300, recording a log:
s301, constructing log content:
the method comprises the steps of obtaining log information to be recorded in an application program, wherein the log information comprises a first log parameter, a second log parameter and a third log parameter, the first log parameter is a log type, the second log parameter is a log level, and the third log parameter is log content.
And establishing log record content according to the log information.
In order to explain the invention more clearly, the log type is set as a transaction log, the log level is the highest level, the log content is a transaction error report, and the error reason is that the transaction core server cannot be connected; then, with this log information, log record content needs to be constructed: the transaction log, highest level, transaction error, can not connect with the transaction core server.
It should be noted that the above examples are only for explaining the implementation of the present invention, and do not limit the protection scope of the present invention.
S302, log caching:
and calling a log recording strategy of the corresponding log type in the log recording class according to a first log parameter, namely the log type, in the log information, and writing the log recording content into the log cache queue through the strategy.
S303, starting a thread:
and opening a log write-in sub-thread and adding a synchronization lock to the log cache queue.
When the application program runs in the server or the terminal, the main thread of the server or the terminal is called to run, so that in order to avoid the influence of logging on the running of the application program, a sub-thread written in the log is started to specially process the log.
Because the main thread for running the application program and the sub-thread for writing the log are two independent threads, in order to write the log record content cached in the log cache queue across threads, a synchronization lock needs to be added in the log cache queue.
S304, log writing:
and calling a log write sub-thread, and writing the log record content in the log cache queue added with the synchronous lock into a log file at a specified position, wherein the log record content of different log types can be written into different log files because of different log types, so that a plurality of log record files can be obtained.
In the first writing, the designated location certainly does not have the log file corresponding to the log type, and then a new log file needs to be created through the logging policy corresponding to the log type, and then the logging content is written into the log file.
It should be noted that, when writing the log record content into the log file, new log record content is added after the original content in the log file, that is, new log record content is written at the tail of the log file.
S400, log file classification:
according to the set log classification rule, the log files at the designated positions are classified, and a plurality of classified log files can be obtained.
For a clearer explanation of the present invention, the example of the initialization step continued with S100 here is that the log classification rules are classified according to time integral points, so that for an application, each log category has 24 files in 24 hours a day, and it is assumed that each log category generates a log every hour, and the names of the classified log files include date and integral point information, such as XXX log 2021010123. log; it should be noted that the setting and examples are only for explaining the present invention, and the protection scope of the present invention is not limited thereby.
S500, log file uploading:
acquiring first attribute information of each classified log file, where the first attribute information needs to be set according to log migration reference conditions, for example: if the log migration reference condition is a date type condition, the first attribute information is the creation date of the classified log file; the log migration reference condition is the file size, and the first attribute information is the file size of the classified log file; it should be noted that the examples are only for explaining the present invention and are not to be construed as limiting the scope of the present invention.
Comparing the first attribute information with the log migration reference condition:
if the first attribute information meets the log migration reference condition, compressing the classified log file to obtain a compressed classified log file, uploading the compressed classified log file to a specified log server for storage, and deleting the local corresponding log file;
if the first attribute information does not meet the log migration reference condition, the classified log file needs to be continuously stored in the local where the application program is located until the log migration reference condition is met.
For the purpose of explaining the present invention more clearly, the log migration criterion is set here to be that the log of more than 30 days needs to be migrated, and assuming that the date of the day is 2021 year 3 month 31 day, then the log files created before 2021 year 3 month 1 day and 2021 year 3 month 1 day need to be migrated to the log server, where the date of the day is included when calculating the date; it should be noted that the setting and examples are only for explaining the present invention, and the protection scope of the present invention is not limited thereby.
Example 2
An embodiment of the present invention further provides a system for logging an application program, please refer to fig. 3 to 4, including: the system comprises an initialization module, a log record building module, a log record recording module, a log file classification module and a log file uploading module;
an initialization module:
the initialization module is used for setting log classification rules and log migration reference conditions;
specifically, the initialization module sets a log classification rule and a log migration reference condition of the log file, wherein the log classification rule is that log files recorded subsequently are classified according to a certain rule, so that the log can be conveniently checked, problems can be conveniently positioned and the like; the log migration reference condition is that when the local log of the application program is migrated according to the set condition, the local log is migrated to a specific log server for storage, and when the log migration reference condition is satisfied, the migration is initiated, and if the log migration reference condition is not satisfied, the migration is not performed.
The log classification rule and the setting of the log migration reference condition can be set according to actual requirements, and the setting of the log migration reference condition needs to take the storage space of a server or a terminal where the application program is located into consideration.
In order to explain the invention more clearly, the log classification rule is set here as that the logs are classified according to the time integral point, namely, the logs in the same hour are recorded in a log file, the log migration reference condition is set as that the log file is migrated when the creation time of the log file exceeds 30 days, namely, the time of the current day is obtained, 30 days are subtracted from the time of the current day to obtain a date, and the log files created before the date need to be migrated to a log server; it should be noted that the setting is only for explaining the implementation process of the present invention, and the protection scope of the present invention is not limited thereby.
Constructing a log record module:
the log record constructing module is used for acquiring a log parameter set and constructing a log record class according to the log parameter set;
specifically, a log record class building module collects all first log reference parameters, namely log classes, according to requirements, acquires a common record format according to the log classes, and writes a log record strategy corresponding to each log class through codes to obtain a plurality of log record strategies; and planning a plurality of log recording strategies into the same log tool class to obtain a log recording class.
The log types here may be all log types that are disclosed in the prior art, or all log types that need to be used by the application, for example: it should be noted that the examples herein are merely for explaining the present invention, and the protection scope of the present invention is not limited thereby.
The recording format here may be a general logging format, or a personalized logging format may be set according to actual requirements, for example: the transaction log needs to record a transaction number, a transaction uploading message, transaction uploading time, a transaction result, a transaction returning message, and transaction returning time, and it should be noted that the examples herein are merely for explaining the present invention, and the protection scope of the present invention cannot be limited thereby.
The logging policy here may be a method or an ordered combination of codes used to solve a class of problems in computer languages such as functions, and is a functional code module.
A journaling class, as used herein, refers to a class in a computer language, which is a template that describes the behavior and state of a class of objects.
A log recording module:
the log recording module is used for acquiring log information of the application program; according to the log record class, executing log record operation on the log information to obtain a plurality of log files; the log recording module comprises a log content constructing unit, a log caching unit, a thread opening unit and a log writing unit;
constructing a log content unit:
the log content constructing unit is used for acquiring log information of the application program; according to the log information, constructing log record content;
specifically, the log content constructing unit acquires log information to be recorded in the application program, wherein the log information includes a first log parameter, a second log parameter and a third log parameter, the first log parameter is a log type, the second log parameter is a log level, and the third log parameter is log content.
And establishing log record content according to the log information.
In order to explain the invention more clearly, the log type is set as a transaction log, the log level is the highest level, the log content is a transaction error report, and the error reason is that the transaction core server cannot be connected; then, with this log information, log record content needs to be constructed: the transaction log, highest level, transaction error, can not connect with the transaction core server.
It should be noted that the above examples are only for explaining the implementation of the present invention, and do not limit the protection scope of the present invention.
A log caching unit:
the log cache unit is used for writing the log record content into a log cache queue according to the log record class;
specifically, the log caching unit calls a log recording strategy of a corresponding log type in the log recording types according to a first log parameter, namely the log type, in the log information, and writes the log recording content into the log caching queue through the strategy.
Starting a thread unit:
the thread opening unit is used for opening the log write-in sub-thread and adding a synchronous lock to the log cache queue;
specifically, the thread-opening unit opens the log write sub-thread and adds a synchronization lock to the log cache queue.
When the application program runs in the server or the terminal, the main thread of the server or the terminal is called to run, so that in order to avoid the influence of logging on the running of the application program, a sub-thread written in the log is started to specially process the log.
Because the main thread for running the application program and the sub-thread for writing the log are two independent threads, in order to write the log record content cached in the log cache queue across threads, a synchronization lock needs to be added in the log cache queue.
A log writing unit:
the log writing unit is used for executing log recording operation on log recording contents in the log cache queue through a log writing sub-thread to obtain a plurality of log files;
specifically, the log writing unit calls a log writing sub-thread to write the log record content in the log cache queue added with the synchronization lock into the log file at the designated position, and because the log types are different, the log record content of different log types can be written into different log files, so that a plurality of log record files can be obtained here.
In the first writing, the designated location certainly does not have the log file corresponding to the log type, and then a new log file needs to be created through the logging policy corresponding to the log type, and then the logging content is written into the log file.
It should be noted that, when writing the log record content into the log file, new log record content is added after the original content in the log file, that is, new log record content is written at the tail of the log file.
A log file classification module:
the log file classification module is used for executing file classification operation on the log files according to log classification rules to obtain a plurality of classified log files;
specifically, the log file classification module classifies the log files at the designated positions according to the set log classification rule, so as to obtain a plurality of classified log files.
For a clearer explanation of the present invention, the example of the log classification rule in the continuous initialization module is classified according to the time integral point, so that for an application, each log category has 24 files in 24 hours a day, and it is assumed that each log category generates a log every hour, and the name of the classified log file contains date and integral point information, such as XXX log 2021010123. log; it should be noted that the setting and examples are only for explaining the present invention, and the protection scope of the present invention is not limited thereby.
A log file uploading module:
the log file uploading module is used for acquiring first attribute information of the classified log files; performing compression uploading operation on the classification log files according to the first attribute information and the log migration reference condition;
specifically, the log file uploading module acquires first attribute information of each classified log file, where the first attribute information needs to be set according to log migration reference conditions, for example: if the log migration reference condition is a date type condition, the first attribute information is the creation date of the classified log file; the log migration reference condition is the file size, and the first attribute information is the file size of the classified log file; it should be noted that the examples are only for explaining the present invention and are not to be construed as limiting the scope of the present invention.
Comparing the first attribute information with the log migration reference condition:
if the first attribute information meets the log migration reference condition, compressing the classified log file to obtain a compressed classified log file, uploading the compressed classified log file to a specified log server for storage, and deleting the local corresponding log file;
if the first attribute information does not meet the log migration reference condition, the classified log file needs to be continuously stored in the local where the application program is located until the log migration reference condition is met.
For the purpose of explaining the present invention more clearly, the log migration criterion is set here to be that the log of more than 30 days needs to be migrated, and assuming that the date of the day is 2021 year 3 month 31 day, then the log files created before 2021 year 3 month 1 day and 2021 year 3 month 1 day need to be migrated to the log server, where the date of the day is included when calculating the date; it should be noted that the setting and examples are only for explaining the present invention, and the protection scope of the present invention is not limited thereby.
Example 3
This embodiment 3 has a computer-readable storage medium for storing computer software instructions for implementing the method for application logging described in embodiment 1 above, which contains a program set for the method for application logging; specifically, the executable program may be built in the system for logging an application program described in embodiment 2, so that the system for logging an application program may implement the method for logging an application program described in embodiment 1 by executing the built-in executable program.
The numbers of the embodiments disclosed in the embodiments of the present invention are merely for description, and do not represent the merits of the embodiments.
It will be understood by those skilled in the art that all or part of the steps of implementing the above embodiments may be implemented by hardware, and a program that can be implemented by the hardware and can be instructed by the program to be executed by the relevant hardware may be stored in a computer readable storage medium, where the storage medium may be a read-only memory, a magnetic or optical disk, and the like.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes performed by the present specification and drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.
Claims (10)
1. A method of application logging, comprising the steps of:
initialization: setting a log classification rule and a log migration reference condition;
constructing a log record class: acquiring a log parameter set, and constructing a log record class according to the log parameter set;
recording a log: acquiring log information of an application program; according to the log record class, executing log record operation on log information to obtain a plurality of log files;
and log file classification: according to the log classification rule, performing file classification operation on the log files to obtain a plurality of classification log files;
uploading a log file: acquiring first attribute information of the classification log file; and performing compression uploading operation on the classified log files according to the first attribute information and the log migration reference condition.
2. The method of claim 1, wherein the application logging comprises:
the logging step further comprises:
constructing log contents: acquiring log information of the application program; according to the log information, log record content is constructed;
log caching: according to the log record class, writing the log record content into a log cache queue;
starting a thread: opening a log write-in sub-thread, and adding a synchronous lock to the log cache queue;
log writing: and executing the log recording operation on the log recording content in the log cache queue through the log write-in sub-thread to obtain a plurality of log files.
3. The method of claim 2, wherein the application logging comprises:
the log parameter set comprises a plurality of first log reference parameters; the step of constructing a log record class according to the set of log parameters further comprises:
generating a plurality of log recording strategies according to the first log reference parameters; and constructing the log record class according to a plurality of log record strategies.
4. A method of application logging according to claim 3, wherein:
the log information comprises a first log parameter, a second log parameter and a third log parameter; the step of log caching further comprises:
calling the corresponding log recording strategy in the log recording class according to the first log parameter; and writing the log record content into a log cache queue through the log record strategy.
5. The method of claim 4, wherein the application logging comprises:
the step of performing the logging operation further comprises:
acquiring the corresponding log file according to the first log parameter; writing the log record content into the log file;
if the log file does not exist, executing log file construction operation;
and if the log file exists, recording the log record content to the tail part of the log file.
6. The method of claim 5, wherein the application logging comprises:
the step of invoking the log file construction policy further comprises:
calling the logging strategy according to the first logging parameter, and constructing the log file corresponding to the first logging parameter; and recording the log record content to the tail part of the log file.
7. The method of claim 1, wherein the application logging comprises:
the step of executing a compression uploading operation on the classification log file according to the first attribute information and the log migration reference condition further includes:
comparing the first attribute information with the log migration reference condition:
if the first attribute information accords with the log migration reference condition, compressing the corresponding classification log file to obtain a compressed classification log file; uploading the compressed classified log file;
and if the first attribute information does not accord with the log migration reference condition, continuously storing the log classified file corresponding to the log in the current position.
8. A system for application logging, comprising: the system comprises an initialization module, a log record building module, a log record recording module, a log file classification module and a log file uploading module;
the initialization module is used for setting log classification rules and log migration reference conditions;
the log record constructing module is used for acquiring a log parameter set and constructing a log record class according to the log parameter set;
the log recording module is used for acquiring log information of the application program; according to the log record class, executing log record operation on log information to obtain a plurality of log files;
the log file classification module is used for executing file classification operation on the log files according to the log classification rule to obtain a plurality of classification log files;
the log file uploading module is used for acquiring first attribute information of the classified log files; and performing compression uploading operation on the classified log files according to the first attribute information and the log migration reference condition.
9. The system for application logging according to claim 8, wherein:
the log recording module comprises a log content constructing unit, a log caching unit, a thread opening unit and a log writing unit;
the log content constructing unit is used for acquiring log information of the application program; according to the log information, log record content is constructed;
the log caching unit is used for writing the log record content into a log caching queue according to the log record class;
the thread opening unit is used for opening a log write-in sub-thread and adding a synchronous lock to the log cache queue;
the log writing unit is used for executing the log recording operation on the log recording content in the log cache queue through the log writing sub-thread to obtain a plurality of log files.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out method steps of an application logging method of any one of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110899771.9A CN113672564A (en) | 2021-08-06 | 2021-08-06 | Method, system and medium for application program log recording |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110899771.9A CN113672564A (en) | 2021-08-06 | 2021-08-06 | Method, system and medium for application program log recording |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113672564A true CN113672564A (en) | 2021-11-19 |
Family
ID=78541683
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110899771.9A Pending CN113672564A (en) | 2021-08-06 | 2021-08-06 | Method, system and medium for application program log recording |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113672564A (en) |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1670708A (en) * | 2004-03-17 | 2005-09-21 | 联想(北京)有限公司 | Management method for computer log |
KR20060077984A (en) * | 2004-12-30 | 2006-07-05 | 주식회사 이너버스 | Method of classifying log files, recording media readable by a computer embedded therein, and a log file classification system for performing the same |
CN102637142A (en) * | 2012-04-13 | 2012-08-15 | 浪潮(北京)电子信息产业有限公司 | Computer system and method for realizing log management |
CN102981943A (en) * | 2012-10-29 | 2013-03-20 | 新浪技术(中国)有限公司 | Method and system for monitoring application logs |
CN105204979A (en) * | 2015-07-28 | 2015-12-30 | 维沃移动通信有限公司 | Recording method of Android logs and mobile terminal |
CN108710563A (en) * | 2018-05-16 | 2018-10-26 | 广州市千钧网络科技有限公司 | A kind of Application Logging method and device |
CN108874639A (en) * | 2018-03-27 | 2018-11-23 | 平安科技(深圳)有限公司 | Log archiving method, electronic device and readable storage medium storing program for executing |
CN111611021A (en) * | 2020-04-17 | 2020-09-01 | 深圳市广和通无线股份有限公司 | Log data transmission method and device, computer equipment and storage medium |
-
2021
- 2021-08-06 CN CN202110899771.9A patent/CN113672564A/en active Pending
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1670708A (en) * | 2004-03-17 | 2005-09-21 | 联想(北京)有限公司 | Management method for computer log |
KR20060077984A (en) * | 2004-12-30 | 2006-07-05 | 주식회사 이너버스 | Method of classifying log files, recording media readable by a computer embedded therein, and a log file classification system for performing the same |
CN102637142A (en) * | 2012-04-13 | 2012-08-15 | 浪潮(北京)电子信息产业有限公司 | Computer system and method for realizing log management |
CN102981943A (en) * | 2012-10-29 | 2013-03-20 | 新浪技术(中国)有限公司 | Method and system for monitoring application logs |
CN105204979A (en) * | 2015-07-28 | 2015-12-30 | 维沃移动通信有限公司 | Recording method of Android logs and mobile terminal |
CN108874639A (en) * | 2018-03-27 | 2018-11-23 | 平安科技(深圳)有限公司 | Log archiving method, electronic device and readable storage medium storing program for executing |
CN108710563A (en) * | 2018-05-16 | 2018-10-26 | 广州市千钧网络科技有限公司 | A kind of Application Logging method and device |
CN111611021A (en) * | 2020-04-17 | 2020-09-01 | 深圳市广和通无线股份有限公司 | Log data transmission method and device, computer equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP3270216B2 (en) | File name detection method | |
US6826604B2 (en) | Input/output device information management system for multi-computer system | |
CN111723079A (en) | Data migration method, device, computer equipment and storage medium | |
WO2020134633A1 (en) | Development method and device for application program, and integrated development tool | |
CN110489310B (en) | Method and device for recording user operation, storage medium and computer equipment | |
CN113448938A (en) | Data processing method and device, electronic equipment and storage medium | |
CN111737227A (en) | Data modification method and system | |
CN110647423B (en) | Method, device and readable medium for creating storage volume mirror image based on application | |
CN102073554A (en) | Method and device for recovering files closed abnormally | |
CN112988278B (en) | Meta file modification method and device of resource file, electronic equipment and storage medium | |
CN115705294B (en) | Method, device, electronic equipment and medium for acquiring function call information | |
CN112835638B (en) | Configuration information management method and device based on embedded application program | |
CN111949287A (en) | Software upgrading method and device | |
CN109542860A (en) | Service data management method, terminal device based on HDFS | |
CN113672564A (en) | Method, system and medium for application program log recording | |
US10997057B2 (en) | Debugging asynchronous functions | |
CN117632860A (en) | Method and device for merging small files based on Flink engine and electronic equipment | |
US12072868B1 (en) | Data retention management for partitioned datasets | |
CN111026764B (en) | Data storage method and device, electronic product and storage medium | |
CN115658697A (en) | Index reconstruction method, device, equipment and storage medium | |
CN114169309A (en) | Method and device for modifying behavior data table, computer equipment and storage medium | |
CN114356404A (en) | Interface document generating method, system and computer readable storage medium | |
CN108415814B (en) | Method for automatically recording field change, application server and computer readable storage medium | |
KR102276345B1 (en) | Compression method for behavior event on computer | |
CN115328878B (en) | Log data storage system, method, device and medium |
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 |