CN111597158A - Log file rolling method and device, storage medium and terminal - Google Patents

Log file rolling method and device, storage medium and terminal Download PDF

Info

Publication number
CN111597158A
CN111597158A CN202010326577.7A CN202010326577A CN111597158A CN 111597158 A CN111597158 A CN 111597158A CN 202010326577 A CN202010326577 A CN 202010326577A CN 111597158 A CN111597158 A CN 111597158A
Authority
CN
China
Prior art keywords
log file
type log
type
period
file
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.)
Granted
Application number
CN202010326577.7A
Other languages
Chinese (zh)
Other versions
CN111597158B (en
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.)
Yuanguang Software Co Ltd
Original Assignee
Yuanguang Software Co Ltd
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 Yuanguang Software Co Ltd filed Critical Yuanguang Software Co Ltd
Priority to CN202010326577.7A priority Critical patent/CN111597158B/en
Publication of CN111597158A publication Critical patent/CN111597158A/en
Application granted granted Critical
Publication of CN111597158B publication Critical patent/CN111597158B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • 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/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/162Delete operations

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)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the application discloses a log file rolling method, a log file rolling device, a log file storage medium and a log file storage terminal, the application limits the size of a log file generated in a period, packs a plurality of log files generated in the period, and then rolls the packed log file according to a storage day threshold value, so that the occupation of a disk space can be effectively reduced compared with a scheme of rolling according to the size, the log file can be conveniently searched according to date and time, an additional backup device is not needed for backing up the log file, and the storage cost of the log file is reduced.

Description

Log file rolling method and device, storage medium and terminal
Technical Field
The present application relates to the field of computers, and in particular, to a log file rolling method, apparatus, storage medium, and terminal.
Background
The log file is a record file or a file set for recording system operation events, the computer writes the produced log data into the log file, and the log data can be divided into event logs and message logs. The log file has important roles of processing historical data, tracing diagnostic problems, understanding the activities of the system, and the like. As time increases, a computer generates a large amount of log data in the running process, due to the limitation of disk space, some log data need to be released when the free space of the disk is insufficient, so as to store newly produced log data, and the process of uploading the released log data is also called roll-on of log data. The current log file roll-over policy includes: rolling according to the size of the log file and rolling according to the date of the log file; the former roll-off method has problems that: a large amount of disk space is occupied, and log data of specified time is inconvenient to search; the latter method of roll-over has problems: the storage space occupied by a single log file is large, and the storage and the access of the file are inconvenient.
Disclosure of Invention
The embodiment of the application provides a log file rolling method, a log file rolling device, a log file rolling storage medium and a log file rolling storage terminal, and the log file rolling storage is optimized to achieve the effects of easiness in access and easiness in finding. The technical scheme is as follows:
in a first aspect, an embodiment of the present application provides a log file roll-in method, where the method includes:
when an i +1 th period comes, acquiring a first type log file generated in the ith period from a log directory; the first type log file is used for storing log data; i is an integer greater than or equal to 1;
writing the first type log file generated in the ith period into a second type log file corresponding to the i periods;
adding date information to a second type log file corresponding to the ith period;
deleting the first type log file generated in the ith period, and generating a second type log file corresponding to the (i + 1) th period;
and deleting the expired second type log file in the log directory according to a preset storage day threshold.
In one possible design, the generating the first type log file in the ith cycle includes:
generating a jth first type log file, and writing log data into the jth first type log file; adding time information to the jth first type log file when the size of the jth first type log file reaches a file size threshold; generating a j +1 th first type log file; j is an integer greater than or equal to 1.
In one possible design, the adding time information to the jth first type log file includes:
analyzing the file names of the j first type log files;
adding the time information to the filename of the jth first type log file; wherein the time information represents a time at which the jth first type log file was generated.
In one possible design, the writing the first type of log file generated in the ith cycle into the second type of log file corresponding to the i cycles includes:
compressing the first type log file generated in the ith period;
and generating a second type log file corresponding to the ith period according to the compressed first type log file.
In a possible design, the adding date information to the second type log file corresponding to the ith period includes:
analyzing the file name of the second type log file corresponding to the ith period;
adding the date information into the file name of a second type log file corresponding to the ith period; wherein the date information indicates a date corresponding to the ith cycle.
In one possible design, further comprising:
counting the number of the first type log files in the ith period;
and deleting the oldest first type log file in the ith period when the number reaches a log saving number threshold value.
In one possible design, the period is a length of days, and the second type of log file is in a.zip format or a.rar format.
In a possible design, before the obtaining, in the log directory, the first type log file generated in the ith cycle when the (i + 1) th cycle arrives, the method further includes:
setting the file size threshold, the log storage number threshold and the maximum retention days according to a setting instruction of a user
In a second aspect, an embodiment of the present application provides an apparatus for rolling a log file, where the apparatus includes:
the acquisition unit is used for acquiring a first type log file generated in the ith period from a log directory when the (i + 1) th period comes; the first type log file is used for storing log data, and the process of generating the first type log file in each period comprises the following steps: generating a jth first type log file; adding time information to the jth first type log file when the size of the jth first type log file reaches a threshold value; generating a j +1 th first type log file; i and j are integers greater than or equal to 1;
the generating unit is used for writing the first type log file generated in the ith period into a second type log file corresponding to the i periods;
the adding unit is used for adding date information to the second type log file corresponding to the ith period;
the generating unit is further configured to delete the first type log file generated in the ith period in the log directory, and generate a second type log file corresponding to the (i + 1) th period;
and the deleting unit is used for deleting the expired second type log file in the log directory according to a preset storage day threshold.
In a third aspect, embodiments of the present application provide a computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the above-mentioned method steps.
In a fourth aspect, an embodiment of the present application provides a terminal, which may include: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the above-mentioned method steps.
The beneficial effects brought by the technical scheme provided by some embodiments of the application at least comprise:
the process of generating the first type of log file includes: and writing the generated log file into the current first type log file, generating a new first type log file when the size of the current first type log file reaches a preset file size threshold, writing the subsequently generated log data into the new first type log file, and so on. When the current period comes, all the first type log files generated in the previous period are packaged to generate second type log files, then the first type log files generated in the previous period are uploaded to generate new second type log files, the subsequently generated first type log files are written into the new second type log files, and then the expired second type log files in the log catalog are deleted according to a preset storage day threshold value. Compared with the scheme of rolling storage according to the size, the method and the device can effectively reduce the occupation of the disk space, facilitate the searching of the log file according to the date and the time, do not need an additional backup device to backup the log file, and reduce the cost of storing the log file.
Drawings
In order to more clearly illustrate the embodiments of the present application 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, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flowchart of a log file roll-in method according to an embodiment of the present disclosure;
fig. 2 is another schematic flowchart of a log file roll-in method according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a log file rolling device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a terminal according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the application, as detailed in the appended claims.
In the description of the present application, it is to be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. The specific meaning of the above terms in the present application can be understood in a specific case by those of ordinary skill in the art. Further, in the description of the present application, "a plurality" means two or more unless otherwise specified. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
The journal file rolling method provided by the embodiment of the present application will be described in detail below with reference to fig. 1 to 4. The method may be implemented in dependence on a computer program operable on a device for configuring an application program interface based on the von neumann architecture. The computer program may be integrated into the application or may run as a separate tool-like application. The apparatus for configuring the application program interface in the embodiment of the present application may be a terminal, including but not limited to a smartphone, a personal computer, a tablet computer, a handheld device, an in-vehicle device, a wearable device, a computing device, or other processing device connected to a wireless modem.
Fig. 1 is a schematic flow chart of a log file rolling method according to an embodiment of the present disclosure. As shown in fig. 1, the method of the embodiment of the present application may include the steps of:
s101, when the (i + 1) th cycle arrives, a first type log file generated in the ith cycle is acquired in a log directory.
The log data can be generated by an application program, a database or other entities, the type of the log data can be a message log or an event log, the message log records messages generated by the chat application program, and the event log records events generated in the execution process of the application program. The terminal periodically executes the log file rolling process, and the length of the period can be determined according to actual requirements, for example: the length of the period is days, namely the terminal executes the roll-in process of the log file every other day. In each period, the terminal generates one or more first-type log files, log data generated by the application program can be written into the first-type log files, and the size of the first-type log files correspondingly increases with the increase of the log data.
In this embodiment, the method for generating the first type log file in each cycle includes: the method comprises the steps of generating a current first type log file, wherein the current first type log file can be an empty file and does not include any log data, writing the log data generated by an application program into the current first type log file by a terminal, detecting the size of the current first type log file by the terminal, and adding time information to the current first type log file when the size of the current first type log file reaches a preset file size threshold, wherein the time information can be the time for generating the current first type log file or the time for enabling the size of the current first type log file to reach the file size threshold. After the requirement of the file size threshold is met, the terminal generates a new first type log file, the terminal stops writing log data into the current first type log file, subsequently generated log data can be written into the new first type log file, and the like, and the process of generating the first type log file is repeatedly executed in each period.
For example: in each period, the terminal generates a jth first type log file, and the terminal writes log data generated by the application program into the jth first type log file. The terminal detects the size of the jth first type log file at the same time, when the size of the jth first type log file reaches a file size threshold (for example, 10 megabytes), time information is added to the jth first type log file, then the terminal generates a jth +1 first type log file, the terminal stops writing log data into the jth first type log file, and the terminal redirects and writes the log data generated by the application program into the newly generated jth +1 first type log file. It will be readily appreciated that the data for the first type log files generated during each cycle may be one or more, and that after the cycle is complete, the size of each of the first type log files during the cycle may be less than or equal to the file size threshold.
In one possible implementation, adding time information to each first type log file includes:
acquiring the time for generating the first type log file, and applying the generation time condition to the file name of the first type log file, for example: the generation time of the first type log file is 18:52:26, and the generation time is added into the file name of the jth first type log file; or acquiring the time when the size of the first type log file reaches the size threshold, and adding the time into the file name of the first type log file.
When the (i + 1) th cycle comes, for example: the length of each period is day, and when the current time is detected to be 00:00:00, the current end is determined and the next day comes. The terminal is pre-configured with a log directory, and the log directory is used for storing log files. And the terminal acquires all the first type log files generated in the ith period in the log directory.
In a possible implementation manner, the terminal counts the number of the first type log files in the period;
and deleting the oldest first type log file in the period when the number reaches a log saving number threshold value.
The terminal presets the maximum number (log saving number threshold) of the first type log files stored in each period, counts the number of the first type log files in each period, acquires the generation time of each first type log file when the data reaches the log saving number threshold, and deletes the first type log file with the earliest generation time.
S102, writing the first type log file generated in the ith period into a second type log file corresponding to the ith period.
As can be seen from the process of generating the first-type files in S101, the size of each first-type log file generated in the ith period may be smaller than or equal to the file size threshold. And the terminal packs all the first type log files generated in the ith period and then writes the packed first type log files into a second type log file corresponding to the ith period which is generated in advance.
In a possible implementation manner, writing all the first type log files generated in the ith cycle into the second type log file corresponding to the ith cycle includes:
packaging and compressing all the first type log files generated in the ith period to obtain a second type log file in a compressed format, for example: the compression format is.
S103, adding date information to the second type log file corresponding to the ith period.
The date information indicates a date corresponding to the ith cycle, for example: the date information may be represented by XX years X months X days.
In a possible implementation manner, the adding date information to the second type log file corresponding to the ith period includes:
and analyzing the file name of the second type log file corresponding to the ith period, and adding date information which represents the date of the ith period into the file name.
S104, deleting the first type log file generated in the ith period in the log directory, and generating a second type log file corresponding to the (i + 1) th period.
After the terminal completes generation of a second type log file corresponding to the ith period from the first type log file generated in the ith period, the first type log file generated in the ith period is deleted from the log directory so as to reduce occupation of a disk space. Then, the terminal stops writing the first type log file into the second type log file corresponding to the ith period, the terminal generates the second type log file corresponding to the (i + 1) th period, and the terminal writes the subsequently generated first type log file into the newly generated second type log file corresponding to the (i + 1) th period.
And S105, deleting the expired second type log file in the log directory according to a preset storage day threshold.
The terminal acquires the storage date of each second type log file stored in the log directory, calculates the storage days of each second type log file according to the storage date, and then deletes the second type log file with the storage days larger than the storage days threshold value in the log directory so as to reduce the occupation of the disk space.
In a possible implementation, before S101, the method further includes:
and setting the size threshold, the log storage number threshold and the maximum retention days according to a setting instruction of a user.
The size threshold is used for judging whether a new first log file is generated or not, the log storage number threshold is used for judging whether the number of second log files generated in each period is excessive or not, and the maximum reserved days are used for judging whether the storage time of the second type log files in the log directory is expired or not. The size threshold, the log saving number threshold and the maximum retention days can be determined according to actual requirements, for example: the size threshold is 10 megabytes and the log storage number threshold is 1000.
By implementing the embodiment of the application, the process of generating the first type log file comprises the following steps: and writing the generated log file into the current first type log file, generating a new first type log file when the size of the current first type log file reaches a preset file size threshold, writing the subsequently generated log data into the new first type log file, and so on. When the current period comes, all the first type log files generated in the previous period are packaged to generate second type log files, then the first type log files generated in the previous period are uploaded to generate new second type log files, the subsequently generated first type log files are written into the new second type log files, and then the expired second type log files in the log catalog are deleted according to a preset storage day threshold value. Compared with the scheme of rolling storage according to the size, the method and the device can effectively reduce the occupation of the disk space, facilitate the searching of the log file according to the date and the time, do not need an additional backup device to backup the log file, and reduce the cost of storing the log file.
Referring to fig. 2, the log file rolling method of the present application is described below with respect to a specific embodiment:
step 1, setting relevant parameters of a log roll-over strategy:
A. the file size threshold is set to 10 mbytes.
B. The threshold of the number of saved logs is set to be 1000.
C. The storage day threshold was set to 180 days.
The terminal saves the relevant parameters of the log roll-in strategy in a configuration file so as to load and use the configuration file in an application program.
Step 2, rolling the log record according to the size
On the ith day, when the size of the jth first-type log file reaches the file size threshold of 10M bytes set in step 1, the following operations are performed:
A. generating a j +1 th log file of the first type, for example: the file name and suffix format of the generated j +1 th first type log file is expressed as: log file name log "
B. The jth first type log file is renamed to a format of "log file name _ time-minutes-seconds.
C. And writing the log data generated by the application program into a j +1 th newly generated first-type log file.
D. And (3) judging whether the number of the first type log files in the ith day reaches the log storage number threshold set in the step (1), and if so, deleting the first type log file which is stored firstly in the ith day.
And 3, rolling and saving according to daily log records.
When the time reaches 00:00: when 00, the terminal judges that the (i + 1) th day arrives, and triggers a daily log record rolling strategy, wherein the process is as follows:
A. all first type log files within the ith day: the log file name _ time-minute-second log is compressed into the same zip file, the zip file is named as a log file, year, month and day and zip, and the zip file is the second type log file corresponding to the ith day.
B. And deleting all the first type log files generated in the ith filling, and generating a second type log file corresponding to the (i + 1) th day.
C. And writing the subsequently generated first type log file into a second type log file corresponding to the new (i + 1) th day.
D. And deleting the second type log file with expired log file, year, month, day and zip under the log directory of the terminal according to the storage day threshold value set in the step 1 for 180 days.
The following are embodiments of the apparatus of the present application that may be used to perform embodiments of the method of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the embodiments of the method of the present application.
Referring to fig. 3, a schematic structural diagram of a log file rolling device according to an exemplary embodiment of the present application is shown. The means for rolling the log file may be implemented as all or part of the terminal in software, hardware or a combination of both. The apparatus 1 includes an acquisition unit 10, a generation unit 20, an addition unit 30, and a deletion unit 40.
The acquiring unit 10 is configured to acquire a first type log file generated in an ith cycle from a log directory when the (i + 1) th cycle arrives; the first type log file is used for storing log data, and the process of generating the first type log file in each period comprises the following steps: generating a jth first type log file; adding time information to the jth first type log file when the size of the jth first type log file reaches a threshold value; generating a j +1 th first type log file; i and j are integers greater than or equal to 1;
a generating unit 20, configured to write the first type log file generated in the ith cycle into a second type log file corresponding to the i cycles;
an adding unit 30, configured to add date information to the second type log file corresponding to the ith period;
the generating unit 20 is further configured to delete the first type log file generated in the ith period in the log directory, and generate a second type log file corresponding to the (i + 1) th period;
and the deleting unit 40 is configured to delete the expired second type log file in the log directory according to a preset storage day threshold.
In one or more embodiments, the adding time information to the jth first type log file includes:
analyzing the file names of the j first type log files;
adding the time information to the filename of the jth first type log file; wherein the time information represents a time at which the jth first type log file was generated.
In one or more embodiments, the writing the first type log file generated in the ith cycle to the second type log file corresponding to the i cycles includes:
compressing the first type log file generated in the ith period;
and generating a second type log file corresponding to the ith period according to the compressed first type log file.
In one or more embodiments, the adding date information to the second type log file corresponding to the ith period includes:
analyzing the file name of the second type log file corresponding to the ith period;
adding the date information into the file name of a second type log file corresponding to the ith period; wherein the date information indicates a date corresponding to the ith cycle.
In one or more embodiments, the deletion unit 40 is further configured to:
counting the number of the first type log files in the ith period;
and deleting the oldest first type log file in the ith period when the number reaches a log saving number threshold value.
In one or more embodiments, the period is a length of days, and the second type of log file is in a.zip format or a.rar format.
In one or more embodiments, the apparatus 1 further comprises:
and the setting unit is used for setting the file size threshold, the log storage number threshold and the maximum retention days according to a setting instruction of a user.
It should be noted that, when the log file rolling device provided in the foregoing embodiment executes the log file rolling method, only the division of the function modules is described as an example, and in practical applications, the function distribution may be completed by different function modules according to needs, that is, the internal structure of the device is divided into different function modules, so as to complete all or part of the functions described above. In addition, the log file rolling device and the log file rolling method provided by the above embodiments belong to the same concept, and details of implementation processes are shown in the method embodiments and are not described herein.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
In this embodiment, the process of generating the first type log file by the apparatus 1 includes: and writing the generated log file into the current first type log file, generating a new first type log file when the size of the current first type log file reaches a preset file size threshold, writing the subsequently generated log data into the new first type log file, and so on. When the current period comes, all the first type log files generated in the previous period are packaged to generate second type log files, then the first type log files generated in the previous period are uploaded to generate new second type log files, the subsequently generated first type log files are written into the new second type log files, and then the expired second type log files in the log catalog are deleted according to a preset storage day threshold value. Compared with the scheme of rolling storage according to the size, the method and the device can effectively reduce the occupation of the disk space, facilitate the searching of the log file according to the date and the time, do not need an additional backup device to backup the log file, and reduce the cost of storing the log file.
An embodiment of the present application further provides a computer storage medium, where the computer storage medium may store a plurality of instructions, where the instructions are suitable for being loaded by a processor and executing the method steps in the embodiments shown in fig. 1 to fig. 2, and a specific execution process may refer to specific descriptions of the embodiments shown in fig. 1 to fig. 2, which are not described herein again.
Please refer to fig. 4, which provides a schematic structural diagram of a terminal according to an embodiment of the present application. As shown in fig. 4, the terminal 1000 can include: at least one processor 1001, at least one network interface 1004, a user interface 1003, memory 1005, at least one communication bus 1002.
Wherein a communication bus 1002 is used to enable connective communication between these components.
The user interface 1003 may include a Display screen (Display) and a Camera (Camera), and the optional user interface 1003 may also include a standard wired interface and a wireless interface.
The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface), among others.
Processor 1001 may include one or more processing cores, among other things. Processor 1001 interfaces various parts throughout terminal 1000 using various interfaces and lines, and performs various functions of terminal 1000 and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in memory 1005, and calling data stored in memory 1005. Alternatively, the processor 1001 may be implemented in at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 1001 may integrate one or more of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a modem, and the like. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing the content required to be displayed by the display screen; the modem is used to handle wireless communications. It is understood that the modem may not be integrated into the processor 1001, but may be implemented by a single chip.
The Memory 1005 may include a Random Access Memory (RAM) or a Read-Only Memory (Read-Only Memory). Optionally, the memory 1005 includes a non-transitory computer-readable medium. The memory 1005 may be used to store an instruction, a program, code, a set of codes, or a set of instructions. The memory 1005 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described above, and the like; the storage data area may store data and the like referred to in the above respective method embodiments. The memory 1005 may optionally be at least one memory device located remotely from the processor 1001. As shown in fig. 4, a memory 1005, which is one type of computer storage medium, may include an operating system, a network communication module, a user interface module, and a fraud phone identification application.
In the terminal 1000 shown in fig. 4, the user interface 1003 is mainly used as an interface for providing input for a user, and acquiring data input by the user; the processor 1001 may be configured to call an application program stored in the memory 1005 and configured to configure an application program interface, and to specifically execute the method shown in fig. 1, where specific procedures may refer to the method embodiment shown in fig. 1.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a read-only memory or a random access memory.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present application and is not to be construed as limiting the scope of the present application, so that the present application is not limited thereto, and all equivalent variations and modifications can be made to the present application.

Claims (11)

1. A log file rolling method, the method comprising:
when an i +1 th period comes, acquiring a first type log file generated in the ith period from a log directory; the first type log file is used for storing log data; i is an integer greater than or equal to 1;
writing the first type log file generated in the ith period into a second type log file corresponding to the i periods;
adding date information to a second type log file corresponding to the ith period;
deleting the first type log file generated in the ith period, and generating a second type log file corresponding to the (i + 1) th period;
and deleting the expired second type log file in the log directory according to a preset storage day threshold.
2. The method of claim 1, wherein the generating the first type log file in the ith cycle comprises: generating a jth first type log file, and writing log data into the jth first type log file; adding time information to the jth first type log file when the size of the jth first type log file reaches a file size threshold; generating a j +1 th first type log file; j is an integer greater than or equal to 1.
3. The method according to claim 2, wherein adding time information to the jth first type log file comprises:
analyzing the file names of the j first type log files;
adding the time information to the filename of the jth first type log file; wherein the time information represents a time at which the jth first type log file was generated.
4. The method according to claim 1, wherein the writing the first type log file generated in the i-th cycle to the second type log file corresponding to the i-th cycle comprises:
compressing the first type log file generated in the ith period;
and generating a second type log file corresponding to the ith period according to the compressed first type log file.
5. The method according to claim 1, wherein adding date information to the second type log file corresponding to the ith period comprises:
analyzing the file name of the second type log file corresponding to the ith period;
adding the date information into the file name of a second type log file corresponding to the ith period; wherein the date information indicates a date corresponding to the ith cycle.
6. The method of claim 1, further comprising:
counting the number of the first type log files in the ith period;
and deleting the oldest first type log file in the ith period when the number reaches a log saving number threshold value.
7. The method of claim 1, wherein the period is days in length, and wherein the second type of log file is in a.zip format or a.rar format.
8. The method according to claim 1, wherein before the obtaining the first type log file generated in the ith cycle in the log directory when the (i + 1) th cycle arrives, the method further comprises:
and setting the file size threshold, the log storage number threshold and the maximum retention days according to a setting instruction of a user.
9. An apparatus for rolling a log file, the apparatus comprising:
the acquisition unit is used for acquiring a first type log file generated in the ith period from a log directory when the (i + 1) th period comes; the first type log file is used for storing log data, and the process of generating the first type log file in each period comprises the following steps: generating a jth first type log file; adding time information to the jth first type log file when the size of the jth first type log file reaches a threshold value; generating a j +1 th first type log file; i and j are integers greater than or equal to 1;
the generating unit is used for writing the first type log file generated in the ith period into a second type log file corresponding to the i periods;
the adding unit is used for adding date information to the second type log file corresponding to the ith period;
the generating unit is further configured to delete the first type log file generated in the ith period in the log directory, and generate a second type log file corresponding to the (i + 1) th period;
and the deleting unit is used for deleting the expired second type log file in the log directory according to a preset storage day threshold.
10. A computer storage medium, characterized in that it stores a plurality of instructions adapted to be loaded by a processor and to carry out the method steps according to any one of claims 1 to 8.
11. A terminal, comprising: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the method steps of any of claims 1 to 8.
CN202010326577.7A 2020-04-23 2020-04-23 Rolling method and device for log files, storage medium and terminal Active CN111597158B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010326577.7A CN111597158B (en) 2020-04-23 2020-04-23 Rolling method and device for log files, storage medium and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010326577.7A CN111597158B (en) 2020-04-23 2020-04-23 Rolling method and device for log files, storage medium and terminal

Publications (2)

Publication Number Publication Date
CN111597158A true CN111597158A (en) 2020-08-28
CN111597158B CN111597158B (en) 2024-01-19

Family

ID=72190340

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010326577.7A Active CN111597158B (en) 2020-04-23 2020-04-23 Rolling method and device for log files, storage medium and terminal

Country Status (1)

Country Link
CN (1) CN111597158B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112527746A (en) * 2020-12-18 2021-03-19 平安科技(深圳)有限公司 Log storage method, device, equipment and storage medium
CN112732642A (en) * 2021-01-13 2021-04-30 福建天泉教育科技有限公司 Management method and terminal for storage space occupied by chat software
CN113485965A (en) * 2021-06-22 2021-10-08 西安震有信通科技有限公司 Method, device and server for dynamically cleaning log files based on file sizes
CN115269511A (en) * 2022-07-25 2022-11-01 北京航星永志科技有限公司 Generic electronic file packaging method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102970158A (en) * 2012-11-05 2013-03-13 广东睿江科技有限公司 Log storage and processing method and log server
CN109840188A (en) * 2017-11-24 2019-06-04 深圳市优必选科技有限公司 A kind of acquisition methods and its terminal of log
CN111026728A (en) * 2019-11-19 2020-04-17 山东中创软件商用中间件股份有限公司 Log data processing method and related device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102970158A (en) * 2012-11-05 2013-03-13 广东睿江科技有限公司 Log storage and processing method and log server
CN109840188A (en) * 2017-11-24 2019-06-04 深圳市优必选科技有限公司 A kind of acquisition methods and its terminal of log
CN111026728A (en) * 2019-11-19 2020-04-17 山东中创软件商用中间件股份有限公司 Log data processing method and related device

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112527746A (en) * 2020-12-18 2021-03-19 平安科技(深圳)有限公司 Log storage method, device, equipment and storage medium
CN112732642A (en) * 2021-01-13 2021-04-30 福建天泉教育科技有限公司 Management method and terminal for storage space occupied by chat software
CN112732642B (en) * 2021-01-13 2023-05-23 福建天泉教育科技有限公司 Chat software occupied storage space management method and terminal
CN113485965A (en) * 2021-06-22 2021-10-08 西安震有信通科技有限公司 Method, device and server for dynamically cleaning log files based on file sizes
CN115269511A (en) * 2022-07-25 2022-11-01 北京航星永志科技有限公司 Generic electronic file packaging method and device

Also Published As

Publication number Publication date
CN111597158B (en) 2024-01-19

Similar Documents

Publication Publication Date Title
CN111597158A (en) Log file rolling method and device, storage medium and terminal
CN108063818B (en) Data downloading method, device, terminal and computer readable storage medium
CN107341033A (en) A kind of data statistical approach, device, electronic equipment and storage medium
CN111597257A (en) Database synchronization method and device, storage medium and terminal
CN109359091B (en) File management method, device, terminal and computer readable storage medium
CN103218224A (en) Method and terminal for improving utilization ratio of memory space
CN103902589B (en) Management method and device for downloaded files
CN112486913B (en) Log asynchronous storage method and device based on cluster environment
CN113239004B (en) Method and device for synchronizing notes
CN113886193A (en) Log data processing method and device, electronic equipment and storage medium
CN111061752A (en) Data processing method and device and electronic equipment
CN111104178A (en) Dynamic library loading method, terminal device and storage medium
CN112729868A (en) Vehicle diagnosis method, device, equipment and medium
CN109213745B (en) Distributed file storage method, device, processor and storage medium
CN109325015B (en) Method and device for extracting characteristic field of domain model
CN108205559B (en) Data management method and equipment thereof
CN115398406A (en) Data compression method and device, electronic equipment and storage medium
CN111813435A (en) Page content configuration method and device and electronic equipment
CN116071123A (en) Commodity data processing method, commodity data processing system, electronic equipment and storage medium
CN114328007A (en) Container backup and restoration method, device and medium thereof
CN114328280A (en) Log access method and device based on Flash, storage medium and terminal
CN113051105A (en) Data processing method, device, equipment and storage medium
CN113849195A (en) Application program loading method and device, storage medium and terminal
CN111090633A (en) Small file aggregation method, device and equipment of distributed file system
CN112732568B (en) System log acquisition method and device, storage medium and terminal

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
GR01 Patent grant
GR01 Patent grant