CN107766202A - Daily record write-in method, apparatus and computer-readable recording medium based on Log4j - Google Patents
Daily record write-in method, apparatus and computer-readable recording medium based on Log4j Download PDFInfo
- Publication number
- CN107766202A CN107766202A CN201710919664.1A CN201710919664A CN107766202A CN 107766202 A CN107766202 A CN 107766202A CN 201710919664 A CN201710919664 A CN 201710919664A CN 107766202 A CN107766202 A CN 107766202A
- Authority
- CN
- China
- Prior art keywords
- daily record
- written
- log4j
- storage position
- target storage
- 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
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3003—Monitoring arrangements specially adapted to the computing system or computing system component being monitored
- G06F11/302—Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3051—Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computing Systems (AREA)
- Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
The invention discloses a kind of daily record write-in method, apparatus and computer-readable recording medium based on Log4j, need to be written to the daily record to be written of target storage position by obtaining from Log4j buffer area, when preset time period reaches, the daily record to be written currently got is written to target storage position;As long as namely when reaching the default time cycle, you can the daily record to be written for being currently needed for being written to target storage position is write;The invention also discloses a kind of device and computer-readable recording medium based on Log4j, to implement such scheme, solve in existing daily record write-in policy, when the daily record data amount for being currently needed for write-in is smaller, specified file can not be written in time, the problem of causing user can not get the daily record in time, while will not occur often to receive a daily record outgoing event and just export this high concurrent situation of a log content, therefore also reduce the high performance requirements to terminal data write-in.
Description
Technical field
The present invention relates to field of computer technology, more specifically to a kind of daily record wiring method based on Log4j,
Device and computer-readable recording medium.
Background technology
Safeguarded for the ease of exploitation and test processes, usual related large scale system or application all have log recording work(
Can, recorded with the behavior to related application.And in the application based on Java language exploitation, a kind of popular daily record note
Record framework Log4j (Log for Java) turns into a part essential in large-scale application, and Log4j can be helped very easily
Help us to export the information to be printed in any position of program, be easy to us to system in debugging stage and commencement of commercial operation rank
Analysis and positioning of the section to problem.
At present, Log4j can realize that daily record writes by opening Log4j buffering area strategies, by setting corresponding buffering
Area's threshold value, it is disposable when detecting that daily record data amount to be written reaches buffer threshold, then by these daily records to be written
It is written in specified file, but in actual use, there will be following problem, and considerable influence is brought to use:
Log4j buffering areas strategy is opened to carry out output write-in to corresponding daily record, in actual use, if only
The write-in of daily record is controlled by the buffer threshold of setting, it is more likely that exist because user requires the number of the daily record of write-in
The buffer threshold is not reaching to according to amount, the problem of daily record can not be written efficiently into specified file all the time, or need user
The time of wait is longer, the problem of so as to cause operational data temporary loss, causes user can not get this in time
Daily record, influence user experience.
The content of the invention
The technical problem to be solved in the present invention is:Existing daily record write-in policy there may be to terminal capabilities requirement compared with
Height, or the temporary loss of daily record data is there may be, user can not be got corresponding daily record in time, make so as to influence user
The problem of with experience.For the technical problem, the present invention provides a kind of daily record write-in method, apparatus based on Log4j and calculating
Machine readable storage medium storing program for executing.
In order to solve the above technical problems, the present invention provides a kind of daily record wiring method based on Log4j, it is described to be based on
Log4j daily record wiring method includes:
Being obtained from the buffer area of the Log4j needs to be written to the daily record to be written of target storage position;
When preset time period reaches, the daily record to be written currently got is written to the target and stores position
Put.
Optionally, in the described the step of daily record to be written currently got is written into the target storage position
Before, in addition to:
The data volume for the daily record to be written for judging to get is more than 0.
Optionally, before the preset time period reaches, in addition to:
Whether the data volume for the daily record to be written for judging currently to get reaches preset data amount thresholding, in this way, directly
Connect and the daily record to be written is written to the target storage position.
Optionally, before the preset time period reaches, in addition to:
Judge whether to receive daily record output order, in this way, be directly written to the daily record to be written currently obtained
The target storage position.
Optionally, the preset data amount thresholding be according in the preset time period from the buffer area of the Log4j
In the average amount of daily record to be written that gets be configured.
Optionally, the preset time period is the business allowed according to the related service using the daily record to be written
What data delay was configured.
Optionally, the described the step of daily record to be written currently obtained is written to the target storage position it
Afterwards, in addition to:
The present timing time is reset, to restart timing.
Optionally, the target storage position includes at least one of local disk, database, server.
Further, present invention also offers a kind of device based on Log4j, described device to include processor, memory
And communication bus;
The communication bus is used to realize the connection communication between processor and memory;
The processor is used to perform one or more program stored in memory, with the base described in any of the above-described
In the Log4j daily record wiring method the step of.
Further, present invention also offers a kind of computer-readable recording medium, the computer-readable recording medium
It is stored with one or more program, one or more of programs can be by one or more computing device, to realize
The step of daily record wiring method based on Log4j described in any of the above-described.
Beneficial effect
The present invention provides a kind of daily record wiring method, terminal and computer-readable recording medium based on Log4j, for existing
Some daily record write-in policies there may be higher to terminal capabilities requirement, or there may be the temporary loss of daily record data, makes
User can not get corresponding daily record in time, the problem of so as to influence user experience;By being obtained from Log4j buffer area
Taking needs the daily record to be written for being written to target storage position, to be written by what is currently got when preset time period reaches
Daily record is written to target storage position;As long as namely when reaching the default time cycle, you can will be currently needed for being written to mesh
The daily record to be written of mark storage location is write, and the problem of long-time can not be written to target storage position is not present, solution
Determine in existing daily record write-in policy, when the daily record data amount for being currently needed for write-in is smaller, it is impossible to be written in time specified
File, cause user can not base stage the problem of getting the daily record, realize the timely write-in to related daily record to be written, simultaneously
It will not occur often to receive a daily record outgoing event and just export this high concurrent situation of a log content, therefore also reduce
To the high performance requirements of terminal data write-in.
Brief description of the drawings
Below in conjunction with drawings and Examples, the invention will be further described, in accompanying drawing:
Fig. 1 is the hardware architecture diagram for realizing each optional mobile terminal of embodiment one of the present invention;
Fig. 2 is the wireless communication system schematic diagram of mobile terminal as shown in Figure 1;
Fig. 3 is that a kind of daily record based on Log4j that first embodiment of the invention provides writes method flow schematic diagram;
Fig. 4 is that the timing that first embodiment of the invention provides monitors schematic diagram;
Fig. 5 is that a kind of daily record based on Log4j that second embodiment of the invention provides writes method flow schematic diagram;
Fig. 6 is the apparatus structure schematic diagram based on Log4j that third embodiment of the invention provides.
Embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
In follow-up description, the suffix using such as " module ", " part " or " unit " for representing element is only
Be advantageous to the explanation of the present invention, itself there is no a specific meaning.Therefore, " module ", " part " or " unit " can mix
Ground uses.
Terminal can be implemented in a variety of manners.For example, the terminal described in the present invention can include such as mobile phone, flat board
Computer, notebook computer, palm PC, personal digital assistant (Personal Digital Assistant, PDA), portable
Media player (Portable Media Player, PMP), guider, wearable device, Intelligent bracelet, pedometer etc. move
Dynamic terminal, and the fixed terminal such as digital TV, desktop computer.
It will be illustrated in subsequent descriptions by taking mobile terminal as an example, it will be appreciated by those skilled in the art that except special
Outside element for moving purpose, construction according to the embodiment of the present invention can also apply to the terminal of fixed type.
Referring to Fig. 1, its hardware architecture diagram for a kind of mobile terminal of each embodiment of the realization present invention, the shifting
Dynamic terminal 100 can include:RF (Radio Frequency, radio frequency) unit 101, WiFi module 102, audio output unit
103rd, A/V (audio/video) input block 104, sensor 105, display unit 106, user input unit 107, interface unit
108th, the part such as memory 109, processor 110 and power supply 111.It will be understood by those skilled in the art that shown in Fig. 1
Mobile terminal structure does not form the restriction to mobile terminal, and mobile terminal can be included than illustrating more or less parts,
Either combine some parts or different parts arrangement.
The all parts of mobile terminal are specifically introduced with reference to Fig. 1:
Radio frequency unit 101 can be used for receiving and sending messages or communication process in, the reception and transmission of signal, specifically, by base station
Downlink information receive after, handled to processor 110;In addition, up data are sent to base station.Generally, radio frequency unit 101
Including but not limited to antenna, at least one amplifier, transceiver, coupler, low-noise amplifier, duplexer etc..In addition, penetrate
Frequency unit 101 can also be communicated by radio communication with network and other equipment.Above-mentioned radio communication can use any communication
Standard or agreement, including but not limited to GSM (Global System of Mobile communication, global system for mobile telecommunications
System), GPRS (General Packet Radio Service, general packet radio service), CDMA2000 (Code
Division Multiple Access 2000, CDMA 2000), WCDMA (Wideband Code Division
Multiple Access, WCDMA), TD-SCDMA (Time Division-Synchronous Code
Division Multiple Access, TD SDMA), FDD-LTE (Frequency Division
Duplexing-Long Term Evolution, FDD Long Term Evolution) and TDD-LTE (Time Division
Duplexing-Long Term Evolution, time division duplex Long Term Evolution) etc..
WiFi belongs to short range wireless transmission technology, and mobile terminal can help user to receive and dispatch electricity by WiFi module 102
Sub- mail, browse webpage and access streaming video etc., it has provided the user wireless broadband internet and accessed.Although Fig. 1 shows
Go out WiFi module 102, but it is understood that, it is simultaneously not belonging to must be configured into for mobile terminal, completely can be according to need
To be omitted in the essential scope for do not change invention.
Audio output unit 103 can be in call signal reception pattern, call mode, record mould in mobile terminal 100
When under the isotypes such as formula, speech recognition mode, broadcast reception mode, by radio frequency unit 101 or WiFi module 102 it is receiving or
It is sound that the voice data stored in memory 109, which is converted into audio signal and exported,.Moreover, audio output unit 103
The audio output related to the specific function that mobile terminal 100 performs can also be provided (for example, call signal receives sound, disappeared
Breath receives sound etc.).Audio output unit 103 can include loudspeaker, buzzer etc..
A/V input blocks 104 are used to receive audio or video signal.A/V input blocks 104 can include graphics processor
(Graphics Processing Unit, GPU) 1041 and microphone 1042, graphics processor 1041 is in video acquisition mode
Or the static images or the view data of video obtained in image capture mode by image capture apparatus (such as camera) are carried out
Reason.Picture frame after processing may be displayed on display unit 106.Picture frame after the processing of graphics processor 1041 can be deposited
Storage is transmitted in memory 109 (or other storage mediums) or via radio frequency unit 101 or WiFi module 102.Mike
Wind 1042 can connect in telephone calling model, logging mode, speech recognition mode etc. operational mode via microphone 1042
Quiet down sound (voice data), and can be voice data by such acoustic processing.Audio (voice) data after processing can
To be converted to the form output that mobile communication base station can be sent to via radio frequency unit 101 in the case of telephone calling model.
Microphone 1042 can implement various types of noises and eliminate (or suppression) algorithm to eliminate (or suppression) in reception and send sound
Caused noise or interference during frequency signal.
Mobile terminal 100 also includes at least one sensor 105, such as optical sensor, motion sensor and other biographies
Sensor.Specifically, optical sensor includes ambient light sensor and proximity transducer, wherein, ambient light sensor can be according to environment
The light and shade of light adjusts the brightness of display panel 1061, and proximity transducer can close when mobile terminal 100 is moved in one's ear
Display panel 1061 and/or backlight.As one kind of motion sensor, accelerometer sensor can detect in all directions (general
For three axles) size of acceleration, size and the direction of gravity are can detect that when static, the application available for identification mobile phone posture
(such as horizontal/vertical screen switching, dependent game, magnetometer pose calibrating), Vibration identification correlation function (such as pedometer, percussion) etc.;
The fingerprint sensor that can also configure as mobile phone, pressure sensor, iris sensor, molecule sensor, gyroscope, barometer,
The other sensors such as hygrometer, thermometer, infrared ray sensor, will not be repeated here.
Display unit 106 is used for the information for showing the information inputted by user or being supplied to user.Display unit 106 can wrap
Display panel 1061 is included, liquid crystal display (Liquid Crystal Display, LCD), Organic Light Emitting Diode can be used
Forms such as (Organic Light-Emitting Diode, OLED) configures display panel 1061.
User input unit 107 can be used for the numeral or character information for receiving input, and produce the use with mobile terminal
The key signals input that family is set and function control is relevant.Specifically, user input unit 107 may include contact panel 1071 with
And other input equipments 1072.Contact panel 1071, also referred to as touch-screen, collect touch operation of the user on or near it
(for example user uses any suitable objects or annex such as finger, stylus on contact panel 1071 or in contact panel 1071
Neighbouring operation), and corresponding attachment means are driven according to formula set in advance.Contact panel 1071 may include touch detection
Two parts of device and touch controller.Wherein, the touch orientation of touch detecting apparatus detection user, and detect touch operation band
The signal come, transmits a signal to touch controller;Touch controller receives touch information from touch detecting apparatus, and by it
Contact coordinate is converted into, then gives processor 110, and the order sent of reception processing device 110 and can be performed.In addition, can
To realize contact panel 1071 using polytypes such as resistance-type, condenser type, infrared ray and surface acoustic waves.Except contact panel
1071, user input unit 107 can also include other input equipments 1072.Specifically, other input equipments 1072 can wrap
Include but be not limited to physical keyboard, in function key (such as volume control button, switch key etc.), trace ball, mouse, action bars etc.
One or more, do not limit herein specifically.
Further, contact panel 1071 can cover display panel 1061, detect thereon when contact panel 1071 or
After neighbouring touch operation, processor 110 is sent to determine the type of touch event, is followed by subsequent processing device 110 according to touch thing
The type of part provides corresponding visual output on display panel 1061.Although in Fig. 1, contact panel 1071 and display panel
1061 be the part independent as two to realize the input of mobile terminal and output function, but in certain embodiments, can
Input and the output function of mobile terminal are realized so that contact panel 1071 and display panel 1061 is integrated, is not done herein specifically
Limit.
Interface unit 108 is connected the interface that can pass through as at least one external device (ED) with mobile terminal 100.For example,
External device (ED) can include wired or wireless head-band earphone port, external power source (or battery charger) port, wired or nothing
Line FPDP, memory card port, the port for connecting the device with identification module, audio input/output (I/O) end
Mouth, video i/o port, ear port etc..Interface unit 108 can be used for receiving the input from external device (ED) (for example, number
It is believed that breath, electric power etc.) and the input received is transferred to one or more elements in mobile terminal 100 or can be with
For transmitting data between mobile terminal 100 and external device (ED).
Memory 109 can be used for storage software program and various data.Memory 109 can mainly include storing program area
And storage data field, wherein, storing program area can storage program area, application program (such as the sound needed at least one function
Sound playing function, image player function etc.) etc.;Storage data field can store according to mobile phone use created data (such as
Voice data, phone directory etc.) etc..In addition, memory 109 can include high-speed random access memory, can also include non-easy
The property lost memory, a for example, at least disk memory, flush memory device or other volatile solid-state parts.
Processor 110 is the control centre of mobile terminal, utilizes each of various interfaces and the whole mobile terminal of connection
Individual part, by running or performing the software program and/or module that are stored in memory 109, and call and be stored in storage
Data in device 109, the various functions and processing data of mobile terminal are performed, so as to carry out integral monitoring to mobile terminal.Place
Reason device 110 may include one or more processing units;Preferably, processor 110 can integrate application processor and modulatedemodulate is mediated
Device is managed, wherein, application processor mainly handles operating system, user interface and application program etc., and modem processor is main
Handle radio communication.It is understood that above-mentioned modem processor can not also be integrated into processor 110.
Mobile terminal 100 can also include the power supply 111 (such as battery) to all parts power supply, it is preferred that power supply 111
Can be logically contiguous by power-supply management system and processor 110, so as to realize management charging by power-supply management system, put
The function such as electricity and power managed.
Although Fig. 1 is not shown, mobile terminal 100 can also will not be repeated here including bluetooth module etc..
For the ease of understanding the embodiment of the present invention, the communications network system being based on below to the mobile terminal of the present invention enters
Row description.
Referring to Fig. 2, Fig. 2 is a kind of communications network system Organization Chart provided in an embodiment of the present invention, the communication network system
Unite as the LTE system of universal mobile communications technology, the UE that the LTE system includes communicating connection successively (User Equipment, is used
Family equipment) 201, E-UTRAN (Evolved UMTS Terrestrial Radio Access Network, evolved UMTS lands
Ground wireless access network) 202, EPC (Evolved Packet Core, evolved packet-based core networks) 203 and operator IP operation
204。
Specifically, UE201 can be above-mentioned terminal 100, and here is omitted.
E-UTRAN202 includes eNodeB2021 and other eNodeB2022 etc..Wherein, eNodeB2021 can be by returning
Journey (backhaul) (such as X2 interface) is connected with other eNodeB2022, and eNodeB2021 is connected to EPC203,
ENodeB2021 can provide UE201 to EPC203 access.
EPC203 can include MME (Mobility Management Entity, mobility management entity) 2031, HSS
(Home Subscriber Server, home subscriber server) 2032, other MME2033, SGW (Serving Gate Way,
Gateway) 2034, PGW (PDN Gate Way, grouped data network gateway) 2035 and PCRF (Policy and
Charging Rules Function, policy and rate functional entity) 2036 etc..Wherein, MME2031 be processing UE201 and
The control node of signaling between EPC203, there is provided carrying and connection management.HSS2032 is all to manage for providing some registers
Such as the function of attaching position register (not shown) etc, and preserve some and used about service features, data rate etc.
The special information in family.All customer data can be transmitted by SGW2034, and PGW2035 can provide UE 201 IP
Address is distributed and other functions, and PCRF2036 is strategy and the charging control strategic decision-making of business data flow and IP bearing resources
Point, it selects and provided available strategy and charging control decision-making with charge execution function unit (not shown) for strategy.
IP operation 204 can include internet, Intranet, IMS (IP Multimedia Subsystem, IP multimedia
System) or other IP operations etc..
Although above-mentioned be described by taking LTE system as an example, those skilled in the art it is to be understood that the present invention not only
Suitable for LTE system, be readily applicable to other wireless communication systems, such as GSM, CDMA2000, WCDMA, TD-SCDMA with
And following new network system etc., do not limit herein.
Based on above-mentioned mobile terminal hardware configuration and communications network system, each embodiment of the inventive method is proposed.
First embodiment
It is higher to terminal capabilities requirement existing for existing daily record write-in policy in order to solve, or it is likely to occur daily record number
According to temporary loss, user can not be got corresponding daily record in time, the problem of so as to influence user experience.It is of the invention real
Apply example and a kind of daily record wiring method based on Log4j is provided, refer to Fig. 3, Fig. 3 is the present embodiment offer based on Log4j's
Daily record writes method flow schematic diagram, and this method comprises the following steps:
S301, acquisition needs to be written to the daily record to be written of target storage position from corresponding Log4j buffer area.
It should be appreciated that for related large scale system or large-scale application in the process of running, in caused daily record
Hold, generally firstly the need of being cached in terminal in corresponding buffer area, such as in the internal memory of terminal.This programme is directly from corresponding
Buffer area obtains these daily records to be written for needing to be written to target storage position, to be written into corresponding target storage position
Put.
S302, when preset time period reaches, by the daily record to be written currently got be written to target storage
Position.
Judge whether the current preset time cycle reaches, and when the preset time period reaches, by what is currently got
Daily record one-time write to be written is into target storage position.Avoid daily record of the existing daily record write-in policy needs in write-in
When data volume reaches predetermined threshold value, corresponding daily record therein could be written to specified location, exist be currently needed for writing unavoidably
When the daily record data amount entered is smaller, the problem of can not writing in time, now, user just can not find this in specified file
, there is the problem of loss of data in a little log contents.For time limit less demanding situation, user may will not be caused too
It is big to influence, checking the time for user is simply extended, but when user is badly in need of, namely can not using the related service of the daily record
It is delayed when bearing higher, this undoubtedly will can cause incalculable damage to user.And this programme, by week default time
Phase carries out timing monitoring, as long as when preset time period reaches, just carries out write operation to correlation therein daily record to be written,
So as to effectively prevent this problem.
In the present embodiment, business number that preset time period is allowed according to the related service using the daily record to be written
It is configured according to time delay.To ensure in the time delay range allowed in business, automatically corresponding daily record to be written is written to
Target storage position is stored, on the one hand for user, can effectively avoid the threshold value thresholding based on setting buffers come
The problem of can not being written to target storage position for a long time caused by the corresponding daily record to be written of write-in is possible, while also solve
User, which wishes to be written into daily record in time, to be written to target storage position and then needs user is hand-operated forced to write with a brush dipped in Chinese ink, it has not been convenient to which user makes
With the problem of, therefore be advantageous to lifted Consumer's Experience;On the other hand, to performing the associated terminal and server of the write operation
For, because for the daily record to be written got in preset time period, it needs to call a RPC (Remote
Procedure Call Protocol, remote procedure call protocol) operation can be written into target storage position, without
Must be that a RPC operation is called in each daily record to be written respectively, it is not necessary to repeatedly call.Therefore advantageously reduce associated terminal with
And the processing load of server, the requirement to terminal readwrite performance is reduced, improves the write efficiency of log content.
For example, the business datum time delay that business corresponding to daily record to be written is allowed is 10 seconds, now, preset time period
It could be arranged to 10 seconds, that is to say and mesh just was write with a brush dipped in Chinese ink into daily record to be written currently stored in Log4j buffers at interval of 10 seconds
Mark storage location.By continuously carrying out timing monitoring, arrived if monitoring that daily record A to be written stores when timing was by 5 seconds
In the buffer area;Daily record B to be written is stored into the buffer area when timing was by 8 seconds;When timing reaches 10 seconds, that is to say pre-
If the time cycle reaches, by by calling a RPC operation to be written to the daily record A and B to be written in the buffer area together
In target storage position.Avoid terminal from needing at 5 seconds, a RPC operation is called by log content A for daily record A to be written
Target storage position is written to, again at 8 seconds, calls a RPC operation to write log content B for daily record B to be written again
Enter to target storage position.
The scheme provided by the present embodiment, can be at 10 seconds of preset time period, directly by calling a RPC
Daily record A and B to be written in the buffer area is written in target storage position by operation together, and the processing for reducing corresponding terminal is born
Lotus, improve treatment effeciency.Needed especially for the situation of continuously high concurrent data write-in, such as in preset time period
Business datum to be written to be processed is 100,200, and when even more more, the scheme provided by the present embodiment even more can
The processing load of terminal is reduced to a great extent.
Certainly, this programme is before being written into daily record and being written to corresponding target storage position, namely is performing write-in
Before operation, in order to avoid unnecessary write operation, the data volume of the data to be written currently got can also be entered
Row detection, judges whether its data volume is 0, if not being 0, then the daily record to be written is performed into write operation.It that is to say and sentence
It is disconnected to whether there is daily record to be written, when in the absence of corresponding daily record to be written, certainly also just without performing write operation again.
The present embodiment also provides a kind of specific timing monitoring mode, refers to Fig. 4, it is assumed here that preset time period is
5 seconds, timing course was not constant progress timing, but starts timing until business datum to be written be present, and
After preset time period reaches, stop timing, start again into timing when obtaining new business datum to be written again.Specifically
, when get need to be written to the daily record C to be written in target storage position when, proceed by timing, it is assumed that in timing
Between be 2.5 seconds when, get daily record D to be written again, finally when timing time reaches 5 seconds, be written into daily record C and D together
It is written in target storage position, now, terminal stops timing, and is getting daily record E to be written again, now opens again again
Beginning timing.This timing mode is that triggering timing monitors when daily record to be written be present, avoids that day to be written is not present for a long time
Will, terminal are also required to perform the process of timing monitoring, cause unnecessary resource occupation.
, can be to be written by what is currently got from buffer area when judging that preset time period reaches in the present embodiment
Daily record is written to target storage position, specifically, the corresponding function, such as flush functions write with a brush dipped in Chinese ink can be called with by accordingly
Daily record to be written is written in target storage position.If it should be noted that there is currently no daily record to be written, need not perform
Write operation.
It should be noted that target storage position is specifically included in local disk, database, server in the present embodiment
At least one, other storage locations are can also be certainly, it should be appreciated that specific target storage position is generally referred to as spy
Some fixed file etc., will not be repeated here.
The embodiment of the present invention provides a kind of daily record wiring method based on Log4j, by being obtained from Log4j buffer area
Need to be written to the daily record to be written of target storage position, when preset time period reaches, the day to be written that will currently get
Will is written to target storage position;As long as namely when reaching the default time cycle, you can will be currently needed for being written to target
The daily record to be written of storage location is write, and avoids the problem of long-time can not be written to target storage position, solves
In existing daily record write-in policy, when the daily record data amount for being currently needed for write-in is smaller, it is impossible to specified file is written in time,
The problem of causing user can not get the daily record in time, the timely write-in to related daily record to be written is realized, while will not
Generation often receives a daily record outgoing event and just exports this high concurrent situation of a log content, therefore also reduces to end
The high performance requirements of end data write-in.
Second embodiment
On the basis of the present embodiment first embodiment, there is provided a kind of daily record wiring method based on Log4j, refer to figure
5, Fig. 5 be the daily record wiring method refined flow chart based on Log4j that second embodiment of the invention provides, and this method includes:
S501, the buffer area to Log4j are monitored.
By being monitored to Log4j buffer area, to determine whether there is corresponding daily record to be written.
S502, monitor from Log4j buffer area to need the daily record to be written for being written to target storage position.
This step S502 is identical with the step S201 in above-mentioned first embodiment, specifically refers in above-mentioned first embodiment
To the explanation that it is carried out, will not be repeated here.
S503, proceed by timing.
In the present embodiment, timing monitoring is when getting in the presence of needing to be written to the daily record to be written of target storage position
Start, when there is currently no corresponding daily record to be written, then terminal need not carry out timing monitoring, be accounted for reducing terminal resource
With.It should be appreciated that before currently detected daily record to be written is written into target storage position, if get again
Other new daily records to be written, will not also restart timing, only there is currently no in the buffer area of the Log4j to be written
Daily record, and detect again timing can be just proceeded by during new daily record to be written.
S504, judge whether the data volume of the daily record to be written reaches preset data amount thresholding, in this way, go to step
S507;It is such as no, go to step S506.
In the present embodiment, preset data amount thresholding is to be got according in preset time period from the buffer area of the Log4j
The average amount of daily record to be written be configured, such as the average amount of the daily record to be written got is 1KB/
Second, preset time period is 20 seconds, then preset data amount thresholding then could be arranged to 20KB, or close therewith, such as
15KB, 22KB etc..When the data volume of the daily record to be written got reaches this preset data amount thresholding, can not have to waiting
The time of preset time period, directly corresponding daily record to be written is directly write in corresponding target storage position, improved
The efficiency of daily record write-in, and be not in the problem of frequently writing into, user can also get accordingly much sooner
Log content.
In some instances, preset data amount thresholding can flexibly be set according to practical situations, will not be repeated here.
S505, judge whether to receive daily record output order, in this way, go to step S507;It is such as no, go to step S506.
It should be noted that daily record output order refers to that user wishes directly to play corresponding daily record output to be written
During print, a kind of hand-operated forced writing mode for writing the write-in daily record.This programme is before preset time period arrival, with reference to this
The explicit writing mode of kind, for some specific daily records to be written, user may need to manually perform output, make so as to extend
With scene, while guaranteeing to export corresponding log content in time, give user more selection modes.
When S506, preset time period reach, the daily record to be written currently got is written to target storage position.
Before preset time period arrival, if the data volume of the daily record to be written currently got is not up to preset data
, then, ought when preset time period reaches when measuring thresholding, or also not receiving the daily record output order of user's pressure write-in
The write-in daily record of preceding acquisition is written in corresponding target storage position.Solve
S507, the daily record to be written currently got is directly written to target storage position.
Before preset time period reaches, if the data volume of the daily record to be written currently got reaches preset data amount
During thresholding, or when receiving user and forcing the daily record output order of write-in, directly the daily record to be written will be write immediately
Into corresponding target storage position.Because now need to be written to the data volume of the daily record to be written of target storage position
Through very high, it is not necessary to wait reaching for preset time period again, or now user needs to force write-in, the reality based on user
Demand, then also without the arrival for waiting preset time period again, corresponding daily record to be written directly can be written to target
In storage location.
Daily record wiring method provided in an embodiment of the present invention based on Log4j, on the basis of first embodiment, in addition to,
Before preset time period reaches, whether the data volume size for the daily record to be written for judging currently to get reaches preset data
Thresholding is measured, if having reached preset data amount thresholding, the daily record to be written is directly written to corresponding target storage position;
Or judge whether to receive the daily record output order for being used to force to export the daily record to be written of outside input, if received
Arrive, then the daily record to be written is directly written to corresponding target storage position;In this way, with it is as more efficient as possible,
Time shorterly is write corresponding log content, namely improves daily record write efficiency, reduces high concurrent processing to end
Hold the high request of readwrite performance.
3rd embodiment
The present embodiment provides a kind of device based on Log4j, to realize above-mentioned first embodiment and/or second embodiment
Each step of described daily record wiring method, shown in Figure 6, it is total that the device includes processor 61, memory 62 and communication
Line 63, wherein:
Communication bus 63 is used to realize the connection communication between processor 61 and memory 62;
Processor 61 is used to perform one or more program stored in memory 62, to realize following steps:
Being obtained from corresponding Log4j buffer area needs to be written to the daily record to be written of target storage position;
When preset time period reaches, the daily record to be written currently got is written to target storage position.
In the present embodiment, perform the daily record to be written that will currently get in processor 61 and be written to the target and deposit
Before the step of storage space is put, one or more programs for storing are additionally operable to perform in memory 62 to perform following steps:
The data volume for the daily record to be written for judging to get is more than 0.
In the present embodiment, it is additionally operable in processor 61 before preset time period reaches, performs what is stored in memory 62
One or more programs are to perform following steps:
Whether the data volume for the daily record to be written for judging currently to get reaches preset data amount thresholding, in this way, directly
Connect and the daily record to be written is written to the target storage position.
Or judge whether to receive daily record output order, in this way, the log write to be written that directly will currently obtain
Enter to the target storage position.
It should be noted that in the present embodiment preset data amount thresholding be according in the preset time period from described
What the average amount of the daily record to be written got in Log4j buffer area was configured.Such as the day to be written got
The average amount of will is the 1KB/ seconds, and preset time period is 20 seconds, then preset data amount thresholding then could be arranged to 20KB,
Or close therewith, such as 15KB, 22KB etc..When the data volume of the daily record to be written got reaches this preset data amount door
In limited time, can not have to waiting the time of preset time period, processor 61 directly directly writes to corresponding daily record to be written
In corresponding target storage position, the efficiency of daily record write-in is improved, and be not in that user also may be used the problem of frequently writing into
To get corresponding log content much sooner.
In the present embodiment, the step that the daily record to be written that will currently obtain is written to target storage position is performed in processor 61
After rapid, it is additionally operable to perform one or more programs for being stored in memory 62 to perform following steps:
The present timing time is reset, to restart timing.
Specifically, timing course is not constant progress timing, but opened until business datum to be written be present
Beginning timing, and after preset time period arrival, stop timing, start again when obtaining new business datum to be written again
Enter timing.This timing mode is that triggering timing monitors when daily record to be written be present, avoids that day to be written is not present for a long time
Will, terminal are also required to perform the process of timing monitoring, cause unnecessary resource occupation.
In the present embodiment, processor 61 will can currently be got when judging that preset time period reaches from buffer area
Daily record to be written be written to target storage position, specifically, can call it is corresponding write with a brush dipped in Chinese ink function, such as flush functions with
Corresponding daily record to be written is written in target storage position.If it should be noted that there is currently no daily record to be written, locate
Reason device 61 need not then perform write operation.
In the present embodiment, target storage position includes at least one of local disk, database, server.Certainly also
It can be other storage locations, it should be appreciated that some generally referred to as specific file of specific target storage position
Deng will not be repeated here.
The embodiment of the present invention also provides a kind of computer-readable recording medium, and the computer-readable recording medium storage has
One or more program, one or more of programs can be by one or more computing devices, to realize above-mentioned
Each step of the daily record wiring method based on Log4j in one embodiment and/or second embodiment.It will not be repeated here.
It should be noted that herein, term " comprising ", "comprising" or its any other variant are intended to non-row
His property includes, so that process, method, article or device including a series of elements not only include those key elements, and
And also include the other element being not expressly set out, or also include for this process, method, article or device institute inherently
Key element.In the absence of more restrictions, the key element limited by sentence "including a ...", it is not excluded that including this
Other identical element also be present in the process of key element, method, article or device.
The embodiments of the present invention are for illustration only, do not represent the quality of embodiment.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side
Method can add the mode of required general hardware platform to realize by software, naturally it is also possible to by hardware, but in many cases
The former is more preferably embodiment.Based on such understanding, technical scheme is substantially done to prior art in other words
Going out the part of contribution can be embodied in the form of software product, and the computer software product is stored in a storage medium
In (such as ROM/RAM, magnetic disc, CD), including some instructions to cause a station terminal (can be mobile phone, computer, service
Device, air conditioner, or network equipment etc.) perform method described in each embodiment of the present invention.
Embodiments of the invention are described above in conjunction with accompanying drawing, but the invention is not limited in above-mentioned specific
Embodiment, above-mentioned embodiment is only schematical, rather than restricted, one of ordinary skill in the art
Under the enlightenment of the present invention, in the case of present inventive concept and scope of the claimed protection is not departed from, it can also make a lot
Form, these are belonged within the protection of the present invention.
Claims (10)
1. a kind of daily record wiring method based on Log4j, it is characterised in that the daily record wiring method based on Log4j includes:
Being obtained from the buffer area of the Log4j needs to be written to the daily record to be written of target storage position;
When preset time period reaches, the daily record to be written currently got is written to the target storage position.
2. the daily record wiring method based on Log4j as claimed in claim 1, it is characterised in that will currently be got described
The daily record to be written the step of being written to the target storage position before, in addition to:
The data volume for the daily record to be written for judging to get is more than 0.
3. the daily record wiring method based on Log4j as claimed in claim 2, it is characterised in that in the preset time period
Before reaching, in addition to:
Whether the data volume for the daily record to be written for judging currently to get reaches preset data amount thresholding, in this way, directly will
The daily record to be written is written to the target storage position.
4. the daily record wiring method based on Log4j as claimed in claim 2, it is characterised in that in the preset time period
Before reaching, in addition to:
Judge whether to receive daily record output order, in this way, be directly written to the daily record to be written currently obtained described
Target storage position.
5. the daily record wiring method based on Log4j as claimed in claim 3, it is characterised in that the preset data amount thresholding
It is to be entered according to the average amount of the daily record to be written got in the preset time period from the buffer area of the Log4j
What row was set.
6. the daily record wiring method based on Log4j as described in claim any one of 1-5, it is characterised in that when described default
Between the cycle be that the business datum time delay allowed according to the related service using the daily record to be written is configured.
7. the daily record wiring method based on Log4j as described in claim any one of 1-5, it is characterised in that it is described ought
After the step of daily record to be written of preceding acquisition is written to the target storage position, in addition to:
The present timing time is reset, to restart timing.
8. the daily record wiring method based on Log4j as described in claim any one of 1-5, it is characterised in that the target is deposited
Storage space is put including at least one of local disk, database, server.
9. a kind of device based on Log4j, it is characterised in that described device includes processor, memory and communication bus;
The communication bus is used to realize the connection communication between processor and memory;
The processor is used to perform one or more program stored in memory, to realize as appointed in claim 1 to 8
The step of daily record wiring method based on Log4j described in one.
A kind of 10. computer-readable recording medium, it is characterised in that the computer-readable recording medium storage have one or
Multiple programs, one or more of programs can be by one or more computing devices, to realize such as claim 1 to 8
Any one of the daily record wiring method based on Log4j the step of.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710919664.1A CN107766202A (en) | 2017-09-30 | 2017-09-30 | Daily record write-in method, apparatus and computer-readable recording medium based on Log4j |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710919664.1A CN107766202A (en) | 2017-09-30 | 2017-09-30 | Daily record write-in method, apparatus and computer-readable recording medium based on Log4j |
Publications (1)
Publication Number | Publication Date |
---|---|
CN107766202A true CN107766202A (en) | 2018-03-06 |
Family
ID=61267483
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710919664.1A Pending CN107766202A (en) | 2017-09-30 | 2017-09-30 | Daily record write-in method, apparatus and computer-readable recording medium based on Log4j |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107766202A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110442310A (en) * | 2019-08-06 | 2019-11-12 | 惠州Tcl移动通信有限公司 | Application data processing method, device, storage medium and terminal device |
CN110716695A (en) * | 2019-09-12 | 2020-01-21 | 北京浪潮数据技术有限公司 | Node log storage method and system, electronic device and storage medium |
CN111414343A (en) * | 2020-02-24 | 2020-07-14 | 北京云途腾科技有限责任公司 | Log writing method and device, electronic equipment and medium |
CN113037813A (en) * | 2021-02-25 | 2021-06-25 | 平安壹钱包电子商务有限公司 | Method and device for uploading files, computer equipment and storage medium |
CN113051121A (en) * | 2019-12-26 | 2021-06-29 | 百度在线网络技术(北京)有限公司 | Log information retrieval method and device, electronic equipment and medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102799514A (en) * | 2011-05-24 | 2012-11-28 | 中兴通讯股份有限公司 | Method and system for managing log records |
CN105677258A (en) * | 2016-02-23 | 2016-06-15 | 浪潮(北京)电子信息产业有限公司 | Method and system for managing log data |
CN106649735A (en) * | 2016-12-23 | 2017-05-10 | 腾讯科技(深圳)有限公司 | Log data recording method and apparatus |
-
2017
- 2017-09-30 CN CN201710919664.1A patent/CN107766202A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102799514A (en) * | 2011-05-24 | 2012-11-28 | 中兴通讯股份有限公司 | Method and system for managing log records |
CN105677258A (en) * | 2016-02-23 | 2016-06-15 | 浪潮(北京)电子信息产业有限公司 | Method and system for managing log data |
CN106649735A (en) * | 2016-12-23 | 2017-05-10 | 腾讯科技(深圳)有限公司 | Log data recording method and apparatus |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110442310A (en) * | 2019-08-06 | 2019-11-12 | 惠州Tcl移动通信有限公司 | Application data processing method, device, storage medium and terminal device |
CN110716695A (en) * | 2019-09-12 | 2020-01-21 | 北京浪潮数据技术有限公司 | Node log storage method and system, electronic device and storage medium |
CN113051121A (en) * | 2019-12-26 | 2021-06-29 | 百度在线网络技术(北京)有限公司 | Log information retrieval method and device, electronic equipment and medium |
CN111414343A (en) * | 2020-02-24 | 2020-07-14 | 北京云途腾科技有限责任公司 | Log writing method and device, electronic equipment and medium |
CN111414343B (en) * | 2020-02-24 | 2023-08-04 | 北京百度云途腾科技有限责任公司 | Log writing method, device, electronic equipment and medium |
CN113037813A (en) * | 2021-02-25 | 2021-06-25 | 平安壹钱包电子商务有限公司 | Method and device for uploading files, computer equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107688607A (en) | The method and mobile terminal of a kind of database access, computer-readable recording medium | |
CN108536481A (en) | A kind of application program launching method, mobile terminal and computer storage media | |
CN107229402A (en) | Dynamic screenshotss method, device and the readable storage medium storing program for executing of terminal | |
CN107766202A (en) | Daily record write-in method, apparatus and computer-readable recording medium based on Log4j | |
CN107566635A (en) | Screen intensity method to set up, mobile terminal and computer-readable recording medium | |
CN107181700A (en) | Control method, mobile terminal and the storage medium of application program for mobile terminal | |
CN107132974A (en) | Terminal freezes screen processing method, terminal and computer-readable recording medium | |
CN107807767A (en) | A kind of processing method of communication traffic, terminal and computer-readable recording medium | |
CN110180181A (en) | Screenshot method, device and the computer readable storage medium of Wonderful time video | |
CN107390856A (en) | A kind of method, mobile terminal and storage medium for reducing mobile terminal power consumption | |
CN107679176A (en) | It is a kind of to improve using the method for opening speed, terminal, server, computer-readable recording medium | |
CN107678698A (en) | Data cached method for cleaning, server, terminal and computer-readable recording medium | |
CN107124428A (en) | A kind of method, equipment and the storage medium of raising VoLTE call successful rates | |
CN107124466A (en) | One kind prevents caching penetrating method and device, computer-readable recording medium | |
CN109151216A (en) | Using starting method, mobile terminal, server and computer readable storage medium | |
CN110290269A (en) | Display control method, mobile terminal and computer readable storage medium | |
CN109445945A (en) | Memory allocation method, mobile terminal, server and the storage medium of application program | |
CN107809527A (en) | A kind of method and apparatus that prompt operation is presented | |
CN107566295A (en) | A kind of data traffic reminding method, browser and computer-readable recording medium | |
CN107360211A (en) | A kind of inserting method, relevant device and the computer-readable storage medium of information flow information | |
CN107679080A (en) | A kind of multimedia data recording method, terminal and computer-readable recording medium | |
CN107133108A (en) | Implementation method, terminal, server and the computer-readable recording medium of distributed complex lock | |
CN109947519A (en) | Hardware-accelerated control method, terminal and computer readable storage medium | |
CN108879117A (en) | Mobile terminal and its antenna structure | |
CN107797825A (en) | A kind of data transmission method for uplink, terminal and computer-readable recording 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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20180306 |