CN105573900A - System log configuring and recording method - Google Patents

System log configuring and recording method Download PDF

Info

Publication number
CN105573900A
CN105573900A CN201510947609.4A CN201510947609A CN105573900A CN 105573900 A CN105573900 A CN 105573900A CN 201510947609 A CN201510947609 A CN 201510947609A CN 105573900 A CN105573900 A CN 105573900A
Authority
CN
China
Prior art keywords
class
log
file
configuration
network interface
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201510947609.4A
Other languages
Chinese (zh)
Inventor
赵昆
葛文海
芮国强
仇志凌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NANJING APAITEK TECHNOLOGY Co Ltd
Original Assignee
NANJING APAITEK TECHNOLOGY 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 NANJING APAITEK TECHNOLOGY Co Ltd filed Critical NANJING APAITEK TECHNOLOGY Co Ltd
Priority to CN201510947609.4A priority Critical patent/CN105573900A/en
Publication of CN105573900A publication Critical patent/CN105573900A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging

Abstract

The invention provides a system log configuring and recording method. The method comprises the following steps: creating, opening, formatting and outputting of a format macro definition, wherein Configure is to configure an abstract class, and provide interfaces for start and stop as required, output granularity, file size, data setting and system load parameter setting; a derived class comprises four class objects including registry, file, distributive database and network interface, and acts as an actual information configuration manner; a Manager class is a configuration information management computer, and the four configuration classes of the registry, the file, the distributive database and the network interface exist in the management computer in a class aggregation manner and are flexibly selected and used as required; Run Log is a log core mode, is applied to a log system to be configured into operation, and supports a system load optimization algorithm. The method provides functions of formatting contents, outputting original memory block data, and the like.

Description

A kind of system journal configuration and recording method
Technical field
The present invention relates to a kind of system journal configuration and recording method, be specifically related to a kind of system journal configuration and recording method.
Background technology
The system application run under industrial environment, needs to feed back to user or some information of developer usually, as state value change, parameter change, and the information such as fault cues.Partial feedback information participating user is mutual, such as when user correctly can not be identified by system by input through keyboard one section of invalid data, need also to point out to user feedback in time to re-enter, screen can be adopted to export the mode of (exporting prompting text in current interface).In addition, the feedback informations such as debugging, fault are generally transparent for user, and now for not affect Consumer's Experience, the form usually adopting daily record to export replaces screen and exports, object is that system failure dump file is also the one of daily record in addition in order to locate and investigation problem.
By describing above, the appearance form of information is broadly divided into user awareness and user can not perception two kinds, and the scene such as system application of user awareness possesses a daily record output window.The non scene of user then shows as the various ways such as default hidden window, document form, database, OPC data, distributed data collection.
One, for the original log information of Process Character not face object, output can adopt following form:
1, the system run under order line terminal can use printf function by various information Formatting Output on screen
The call format of printf () function is: printf (" < format string > ", < parameter table >)
2, can use under VirtualC++Debug pattern TRACE grand come output information to Debug window
This is grand only occurs in the DEBUG version of program, and when RELEASE time, this grandly just disappears completely, thus helps you to debug also to reduce size of code when RELEASE.
Use very simple, form is as follows: TRACE (" DDDDDDDDDDD "); TRACE (" wewe%d ", 333); Equally also there is TRACE0, TRACE1, TRACE2.。。Correspondence 0,1,2 respectively.。Individual parameter TRACE information outputs to the output window (this window is that you compile that window of project bomp) of VCIDE environment, but is only limitted to the program that you run your DEBUG version in VC.
TRACE information can also use DEBUGVIEW to capture.In this case, you can not run your program in the IDE environment of VC, and by the program isolated operation of DEBUG version good for BUILD, this time can see outputing of DEBUGVIEw form at the window of DEBUGVIEW.
In VC, the usage of TRACE has following four kinds:
1:TRACE is exactly be not with dynamic parameter output string, the printf (" output string ") of similar C;
Character string in 2:TRACE can be with a parameter to export, the printf (" of similar C ... %d ", variable);
3:TRACE can be with two parameters to export, the printf (" of similar C ... %d...%f ", variable 1, variable 2);
4:TRACE can be with three parameters to export, the printf (" of similar C ... %d, %d, %d ", variable 1, variable 2, variable 3);
Win32API supports to use OutputDebugString to output information to all kinds of debugger
VOIDOutputDebugString(LPCTSTRlpOutputString);
Parameters
lpOutputString
[in]Pointertothenull-terminatedstringtobedisplayed.
ReturnValues
Thisfunctiondoesnotreturnavalue.
4, also can realize data by the mode of adding a record to database is in addition recorded in database, and can use stsndard SQL statement insertinto, concrete syntax can with reference to the relevant documentation of ANSI and ISO.
Two, OO log information, is applicable to the management of batch daily record, is below two kinds of common storehouses of increasing income:
1, log4cpp is the open source projects based on LGPL, transplants the log processing track project log4j from Java, and it is consistent to maintain on API.Its similar Support Library also comprises Java (log4j), C (log4c), python (log4p) etc., and its interface character string parameter type uses std::string, supports ANSI character set.Main support function:
Provide extendible multiple log recording mode;
Provide NDC (Nested Diagnostic Context), can be used for the trace debug of multithreading, many scenes;
Provide complete daily record dynamic priority to control, the daily record priority needing record can be adjusted at any time;
All configurations are completed and dynamic load by configuration file;
Excellent performance, EMS memory occupation is little, and the log4cpp.dll size after compiling only has 160kb;
The platform-neutral of code level, Log4cpp source code, after compiling, is applicable to operating system and the developing instrument of most of main flow;
Clear concept, study and easy to use, skilled programmer can be applied log4cpp well within one day and develop.
2, it is all simpler than the storehouse of log4 series for glog, but it does not support to control daily record behavior with configuration file.Googleglog is a c++ storehouse based on program level log information, and the stream class of operation of programming use-pattern and c++ is seemingly, routine:
LOG(INFO)<<"Found"<<num_cookies<<"cookies";
" LOG " is grand is daily record output key word, and " INFO " is seriousness degree.
Main support function:
Optimum configurations, arranges flags parameters to control log recording behavior in the mode of command line parameter;
Severity rankings, according to daily record severity rankings log;
Can log information conditionally;
Condition stops program.Abundant condition criterion is grand, predeterminable program determination condition;
Abnormal signal process.Program exception situation, can customize exception handling procedure;
Support debug function.Can only for debug pattern;
Self-defined log information;
Thread-safe log recording mode;
System-level log recording;
Googleperror style log information;
Simplify daily record character string information.
Above method determines the content of daily record in the development phase, be formatted into what etc., actual to use, daily record can be triggered by all kinds of condition and whether be recorded.
But in industrial environment, consider the restriction of system resource, memory device, excessively use and will cause unpredictable consequence, be therefore necessary whether use start and stop technology as required to decide current log goes on record.Based on same reason, log system also needs to consider to export Task-size Controlling, log file size, controllable quantity.Relatively weak for processing power some system, now should fully take into account the impact that log system runs whole system, possess load balancing techniques in systems in which.
Summary of the invention
The object of this invention is to provide a kind of system journal configuration and recording method, the function such as formatting component and the output of original memory block data is provided, add the needs to industry spot start and stop as required in addition, simultaneously to the output granularity of daily record, file size, data can control, and inside realizes system load balance by series of algorithms optimization.
The invention provides following technical scheme:
A kind of system journal configuration and recording method, comprising: create, open, format, output format macro definition; Configure is configuration abstract class, provides start and stop as required, exports granularity, file size, data are arranged, and system load parameters arranges interface, the mode that derived class comprises registration table, file, distributed data base, network interface four class objects play actual disposition information; Manager class is configuration information management machine, and registration table, file, distributed data base, network interface four configuration class is present in supervisor in the mode of Type of Collective, as required flexible choice for use; RunLog is daily record core schema, for operating log system should be configured to, and the load optimized algorithm of back-up system simultaneously.
The invention has the beneficial effects as follows: the present invention adopts Target-oriented thought, journal function is encapsulated, relatively and Log4XX, glog open source system, except providing the function such as formatting component and the output of original memory block data, adds the needs to industry spot start and stop as required in addition, simultaneously to the output granularity of daily record, file size, data can control, and inside realizes system load balance by series of algorithms optimization.UNICODE version can be compiled as further in addition, adapt to international demand.
Accompanying drawing explanation
Accompanying drawing is used to provide a further understanding of the present invention, and forms a part for instructions, together with embodiments of the present invention for explaining the present invention, is not construed as limiting the invention.In the accompanying drawings:
Fig. 1 is the class figure structure schematic representation of log system of the present invention;
Fig. 2 is a preferred embodiment shortcut schematic diagram;
Fig. 3-12 is configuration, the recording process figure of a preferred embodiment.
Embodiment
As shown in figs. 1-12, be the class graph structure of this log system shown in Fig. 1, wherein Log class realizes basic log recording function, comprises establishment, opens, format, the functions such as output format macro definition.Configure is configuration abstract class, provide start and stop as required, export granularity, file size, data are arranged, system load parameters such as to arrange at the interface, derived class comprises Register(registration table), File(file), DB(distributed data base), Remote(network interface), above four class objects play the mode of actual disposition information.Manager class is configuration information management machine, and above four configuration classes are present in supervisor in the mode of Type of Collective, can flexible choice for use as required.RunLog is daily record core schema, for operating log system should be configured to, and the load optimized algorithm of back-up system simultaneously.
This log system supports virtualc++2008 and above version, can use by the engineering under these environment.For virtualc++2010, double-click " MicrosoftVisualStudio2010 " icon in desktop and enter, as Fig. 2.Click File--New--Project as shown in Figure 3 successively.As Fig. 4 inputs " EMonitor " in new window Name input frame, then click " OK " button.Occur Fig. 5 dialog box, the same Fig. 6 of option--Fig. 9, presses the newly-built engineering of next and Finish button.
As shown in Figure 10, in " solutionexplorer ", right button is clicked, " Add " by engineering name EMonitor place--and " ExistingItem... ", choose " Log.cpp, Log.h, LogManager.cpp; LogManager.h " four files, then click " Add " button.
Need in program to add following code:
In EMonitor.cpp file
#include"LogManager.h"
CLogManagerlogmanager;
BOOLCEMonitorDlg::OnInitDialog()
{
WRITEDEBUG("HelloWorld!");
}
Then perform Build--RebuildSolution, the StartDebugging then clicked in toolbar is to appear after dialog box, can c: generate journal file under catalogue, content is as follows:
2015-06-2917:55:46,329[2704][DEBUG]-e:\git_repository\fireehost\emonitor\emonitor\logmanager.cppline74:HelloWorld!
It is more than basic journal function, can by registration table key-value pair, it controls at any time, click and start--run, input " Regedit ", open REGEDIT, navigate to HKEY_CURRENT_USER EMonitor node, this is the node at journal file controlling functions place, as Figure 12, key assignments and the implication of right side appearance are as follows:
EnableLog(is start and stop as required) 1 permission log recording, 0 stops current log record
MaxLogFileCount(journal file transformation) give tacit consent to 10
The mono-log file size upper limit of MaxLogFileSize(, unit: bytes) give tacit consent to 10485760
GrainSize(daily record granularity) control under final entry herein log category, acquiescence 4, exports any daily record.Granularity has 4 classes, and 4 is most classification, and can use WRITEDEBUG1 in program, WRITEDEBUG2, WRITEDEBUG3, WRITEDEBUG4/WRITEDEBUG specifies the log content of these granularities respectively.
Three key assignments groups provide system load optimizational function entirely below:
CPULoadL(system load Lower percentages value) give tacit consent to 10
CPULoadH(system load number percent higher limit) give tacit consent to 80
OverLoadTime(overload allows duration higher limit, unit: ms) give tacit consent to 1000
LoadCheckInterval(load detecting interval, unit: ms) give tacit consent to 500
Above optimizational function exist in systems in which multiple take cpu resource process and thread automatically enable when working simultaneously, invalid in time only having log system work, in the case normal call log system is exported, does not consider load optimized.After there is load too high (>=CPULoadH), daily record is delayed to export, when load drops to CPULoadL and be following, judge that record total amount determines batch or at the uniform velocity writes, with anti-secondary pollution system resource.
The foregoing is only the preferred embodiments of the present invention, be not limited to the present invention, although with reference to previous embodiment to invention has been detailed description, for a person skilled in the art, it still can be modified to the technical scheme described in foregoing embodiments, or carries out equivalent replacement to wherein portion of techniques feature.Within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (1)

1. system journal configuration and a recording method, is characterized in that, comprising: create, open, format, output format macro definition; Configure is configuration abstract class, provides start and stop as required, exports granularity, file size, data are arranged, and system load parameters arranges interface, the mode that derived class comprises registration table, file, distributed data base, network interface four class objects play actual disposition information; Manager class is configuration information management machine, and registration table, file, distributed data base, network interface four configuration class is present in supervisor in the mode of Type of Collective, as required flexible choice for use; RunLog is daily record core schema, for operating log system should be configured to, and the load optimized algorithm of back-up system simultaneously.
CN201510947609.4A 2015-12-17 2015-12-17 System log configuring and recording method Pending CN105573900A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510947609.4A CN105573900A (en) 2015-12-17 2015-12-17 System log configuring and recording method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510947609.4A CN105573900A (en) 2015-12-17 2015-12-17 System log configuring and recording method

Publications (1)

Publication Number Publication Date
CN105573900A true CN105573900A (en) 2016-05-11

Family

ID=55884066

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510947609.4A Pending CN105573900A (en) 2015-12-17 2015-12-17 System log configuring and recording method

Country Status (1)

Country Link
CN (1) CN105573900A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106776231A (en) * 2017-01-09 2017-05-31 武汉斗鱼网络科技有限公司 Android crash logs optimization method and system based on Git
CN109286608A (en) * 2018-08-20 2019-01-29 中国平安人寿保险股份有限公司 Call chain processing method, device and storage equipment, computer equipment
CN109471773A (en) * 2018-10-31 2019-03-15 武汉斗鱼网络科技有限公司 A kind of method, apparatus, server and the storage medium of the output of front end log multichannel
CN113127103A (en) * 2019-12-30 2021-07-16 武汉斗鱼网络科技有限公司 Signaling system and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101320348A (en) * 2008-06-25 2008-12-10 中兴通讯股份有限公司 Log function implementing method of embedded system
CN101887393A (en) * 2010-07-01 2010-11-17 中兴通讯股份有限公司 Equipment fault reproduction method and system based on para-virtualization technique
CN102467392A (en) * 2010-11-12 2012-05-23 鸿富锦精密工业(深圳)有限公司 Preinstallation environment for operating system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101320348A (en) * 2008-06-25 2008-12-10 中兴通讯股份有限公司 Log function implementing method of embedded system
CN101887393A (en) * 2010-07-01 2010-11-17 中兴通讯股份有限公司 Equipment fault reproduction method and system based on para-virtualization technique
CN102467392A (en) * 2010-11-12 2012-05-23 鸿富锦精密工业(深圳)有限公司 Preinstallation environment for operating system

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106776231A (en) * 2017-01-09 2017-05-31 武汉斗鱼网络科技有限公司 Android crash logs optimization method and system based on Git
CN106776231B (en) * 2017-01-09 2019-11-15 武汉斗鱼网络科技有限公司 Android crash log optimization method and system based on Git
CN109286608A (en) * 2018-08-20 2019-01-29 中国平安人寿保险股份有限公司 Call chain processing method, device and storage equipment, computer equipment
CN109286608B (en) * 2018-08-20 2022-08-12 中国平安人寿保险股份有限公司 Call chain processing method and device, storage device and computer device
CN109471773A (en) * 2018-10-31 2019-03-15 武汉斗鱼网络科技有限公司 A kind of method, apparatus, server and the storage medium of the output of front end log multichannel
CN109471773B (en) * 2018-10-31 2022-04-12 武汉斗鱼网络科技有限公司 Method, device, server and storage medium for multi-channel output of front-end log
CN113127103A (en) * 2019-12-30 2021-07-16 武汉斗鱼网络科技有限公司 Signaling system and electronic equipment

Similar Documents

Publication Publication Date Title
CN108021363B (en) Visual game logic editing method and system
JP2749528B2 (en) Tracer system for error analysis
US9639332B2 (en) Applying coding standards in graphical programming environments
US8869100B1 (en) Data objects for model-based design
US6704743B1 (en) Selective inheritance of object parameters in object-oriented computer environment
US20190332519A1 (en) Selectively tracing portions of computer process execution
US5805796A (en) System architecture for implementing modular diagnostics
US7900198B2 (en) Method and system for parameter profile compiling
CN105573900A (en) System log configuring and recording method
US20030135533A1 (en) Method, apparatus, and program for a state machine framework
US9904524B2 (en) Method and device for visually implementing software code
CN1828597B (en) Simple style
US8832504B2 (en) On demand tracing of application code execution
CN104991763A (en) Universal game interface behavior control system
CN104778124A (en) Automatic testing method for software application
WO2017074609A1 (en) Graphical representation of data in a program code editor
CN102662651A (en) Generation method and generation modules for visual component
US9117020B2 (en) Determining control flow divergence due to variable value difference
CN106325860B (en) A kind of automated maintenance method of space flight embedded software interface data
CN105278945A (en) Program visualization device, program visualization method, and program visualization program
Hopsu et al. On portability of IEC 61499 compliant structures and systems
US11042421B1 (en) Modifying system-defined user interface control functionality on a computing device
CN109542444A (en) Monitoring method, device, server and the storage medium of JAVA application
US10185647B2 (en) Debugging remote vertex code on test machine
US20190324782A1 (en) Class splitting in object-oriented environments

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20160511

WD01 Invention patent application deemed withdrawn after publication