The content of the invention
The application provides a kind of daily record Method of printing, to solve the above-mentioned problems in the prior art.
The application provides a kind of daily record printing equipment and system in addition.
The application provides a kind of daily record Method of printing, is applied in operation system, and the operation system includes multiple layers, institute
The method of stating includes:
Receive service request;
According to the service request, corresponding layer and corresponding daily record print components are determined;
By the produced log information in corresponding layer of the service request, using the daily record print components of the determination
In printing to journal file.
Optionally, the log information that the service request is produced in corresponding layer, using the determination
Daily record print components are printed in journal file, including:By the produced log information in corresponding layer of the service request,
In same journal file being printed to using identical daily record print components.
Optionally, described according to the service request, after determining corresponding layer and corresponding daily record print components,
Perform following operation:
Store the corresponding relation between the daily record print components and the daily record print components and corresponding service request;
The log information that the service request is produced in corresponding layer, is printed using the daily record of the determination
Component is printed in journal file, including:
In the different layers of operation system, the type according to the service request determines the daily record corresponding to the service request
Print components;
The log information recorded the need for obtaining produced by the service request in different layers;
The log information of different layers is printed into the corresponding daily record of the service request using the daily record print components for determining
In file.
Optionally, multiple layers of the operation system include request entry level and several called layers;
The request entry level is the initial layers of the entrance operation system of the service request, and can call described called
Layer;Described several called layers at least partly between layers have call order, according to call order successively by last layer
Called;
It is described that corresponding layer and corresponding daily record print components are determined according to the service request, it is in the request
What entry level was carried out.
Optionally, described in the different layers of operation system, the type according to the service request determines the service request
Corresponding daily record print components include:
Using the required parameter of service request as interface parameters, according to the business for calling order to call different layers successively
Layer in system;
Different layers type respectively according to the service request determines and the daily record print components corresponding to the service request.
Optionally, the log information of different layers is printed into the business in the daily record print components using determination please
After asking in corresponding journal file, following operation is performed:
Reverse-order according to order is called returns to the result of service request successively;
Be back to the result of service request after request entry level by the called layer that requested entry level is called, described to ask
Ask entry level that the result of service request is returned into requesting party.
Optionally, it is described that the log information of different layers is printed into the service request using the daily record print components for determining
In corresponding journal file, including:Order is called according to described, it is determined that the order of the log information in printing to journal file.
Optionally, the log information in the produced log information in the corresponding layer of the service request is used with lower section
Formula is obtained:
Different layers are adjusted according to the business that the required parameter of the service request for receiving carries out equivalent layer in the operation system
With every layer can obtain returning result corresponding with required parameter;
Using the required parameter and returning result as the log information.
Optionally, the log information in the produced log information in the corresponding layer of the service request also includes extra
Service requesting information, the extra traffic solicited message refers to the institute for specifying corresponding to the extra traffic request that requesting party sends
Need the information of printing;
The log information that the service request is produced in corresponding layer, is printed using the daily record of the determination
Component prints to journal file to be included:
Including the layer of the extra traffic request, determining that the extra traffic asks corresponding daily record print components;
Obtain the specify information of the required printing of the corresponding additional request parameter of the additional request business and return;
The specify information of the additional request parameter of acquisition and return is printed to using the daily record print components for determining
In the journal file corresponding with extra traffic request.
Optionally, it is described according to the service request, determine that corresponding layer and corresponding daily record print components include:
Obtain the type corresponding to service request;
Based on the type corresponding to the service request, using predetermined manner set the service request interface method so that
Obtaining has corresponding relation between service request and corresponding daily record print components.
Optionally, the predetermined manner includes:By the way of explaining;Or, using xml configuration modes.
Optionally, it is described by the way of explaining, it is to increase corresponding daily record printing on the interface method of service request
The note of component, so as to have corresponding relation between service request and corresponding daily record print components.
Optionally, the layering interception mode for pre-setting is used for different layers set daily record interception mode;
After the reception service request, following operation is performed:
Different layers intercept the service request of equivalent layer respectively using the daily record interception mode, please to perform corresponding service
The daily record print out task asked.
The application also provides a kind of daily record printing equipment, and the device includes:
Service request receiving unit, for receiving service request;
Daily record print components determining unit, for according to the service request, determining corresponding layer and corresponding daily record
Print components;
Log information print unit, for by the produced log information in corresponding layer of the service request, using
The daily record print components of the determination are printed in journal file.
Optionally, the device also includes:
Memory cell, for, according to the service request, determining corresponding layer and corresponding daily record printing group described
After part, the daily record print components and the corresponding relation between the daily record print components and corresponding service request are stored;
The log information print unit includes:
Daily record print components obtain subelement, in the different layers of operation system, according to the class of the service request
Type determines the daily record print components corresponding to the service request;
Log information obtain subelement, for obtaining produced by the service request in different layers the need for record daily record letter
Breath;
Printing subelement, for the log information of different layers to be printed into the business using the daily record print components for determining
In asking corresponding journal file.
Optionally, multiple layers of the operation system include request entry level and several called layers;
The request entry level is the initial layers of the entrance operation system of the service request, and can call described called
Layer;Described several called layers at least partly between layers have call order, according to call order successively by last layer
Called;
The daily record print components determining unit is carried out in the request entry level.
Optionally, the daily record print components obtain subelement and include:
Subelement is called, for using the required parameter of service request as interface parameters, order being called successively according to described
Call the layer in the operation system of different layers;
Subelement is obtained, corresponding to the type determination and the service request for different layers respectively according to the service request
Daily record print components.
Optionally, the device also includes:
Service request result returning unit, for being believed the daily record of different layers using the daily record print components for determining described
After breath is printed in the corresponding journal file of the service request, service request is returned successively according to the reverse-order of order is called
Result;
Result returns to requesting party's unit, returns to the result of service request for being requested the called layer that entry level is called
To request entry level, the result of service request is returned to requesting party by the request entry level.
Optionally, the log information in the produced log information in the corresponding layer of the service request also includes extra
Service requesting information, the extra traffic solicited message refers to the institute for specifying corresponding to the extra traffic request that requesting party sends
Need the information of printing;
The log information print unit includes:
Additional request obtains subelement, for including the layer of the extra traffic request, determines that the extra traffic please
Seek corresponding daily record print components;
Specify information obtains subelement, for obtaining the corresponding additional request parameter of the additional request business and return
The specify information of required printing;
Specify information prints subelement, for the additional request parameter that will be obtained using the daily record print components for determining
And during the specify information for returning prints to the journal file corresponding with extra traffic request.
Optionally, the daily record print components determining unit includes:
Type obtains subelement, for obtaining the type corresponding to service request;
Printing subelement, for based on the type corresponding to the service request, setting the business using predetermined manner please
The interface method asked is with so that have corresponding relation between service request and corresponding daily record print components.
Optionally, the device also includes:
Daily record interception mode setting unit, for using the layering interception mode for pre-setting to set daily record interception for every layer
Mode;
Daily record print out task execution unit, for after the reception service request, different layers to use the daily record
Interception mode intercepts the service request of equivalent layer respectively, to perform the daily record print out task of corresponding service request.
The application also provides a kind of daily record print system in addition, and the system includes:
Automatic blocker module, for interception service request, and is configured to business using predetermined manner by daily record blocker
On the interface of each layer of system;
Business information configuration module, the service request for receiving automatic blocker block intercepts, and based on service request,
Configure to determine and the daily record print components corresponding to the service request for service request;
Daily record printing tools module, for after automatic blocker block intercepts to service request, using business information
The daily record print components of configuration module configuration print log in operation system.
Optionally, the business information configuration module will have been configured daily record print components and the corresponding relation of service request
Storage is in the thread for safeguarding the corresponding relation;
Accordingly, that daily record print components are obtained from the thread is right with service request for the daily record printing tools module
Should be related to, and be printed to the log information produced by the operation of corresponding service request accordingly using the daily record print components
In journal file.
Compared with prior art, the application has advantages below:
The application provides a kind of daily record Method of printing, is applied in operation system, and the operation system includes multiple layers, should
Method includes:Receive service request;According to the service request, corresponding layer and corresponding daily record print components are determined;Will
The produced log information in corresponding layer of the service request, daily record is printed to using the daily record print components of the determination
In file.
The method is to set up a method simple, flexible, to daily record framework of the service code without intrusion, without business system
System increases code, when different business it is requested come, the daily record framework that the method is set up can be automatic by each layer of processing method
Parameter and return value are printed upon in the corresponding journal file of different business, while the daily record printing in service code can also be direct
In printing to the corresponding journal file of the business, it is ensured that all daily records on a service request link can be printed to
In one file.
Specific embodiment
The application first embodiment provides a kind of daily record Method of printing, and the method is applied in operation system, the business
System includes multiple layers, specifically, the daily record framework for print log can be built in operation system by the method, should
Daily record framework can be in advance the service request corresponding daily record printing tools of configuration, so that the operation system of multi-tier structure
The log information of each layer can be printed in a journal file, accordingly, for a service request, the service request chain
The daily record on road writes on string in one journal file, therefore, it can carrying out investigation problem by journal file or carrying out business
Saved during monitoring and expend time and efforts.On the other hand, printed to one in the daily record for ensureing said one service request link
While file, the method need not increase code in operation system, to facilitate application developer to be absorbed in service code
Exploitation, without considering various problems related to daily record in addition.
The method is illustrated and introduced below by way of specific embodiment.Fig. 1 is that the application first embodiment is provided
Daily record Method of printing flow chart.Fig. 1 is refer to, the method comprises the following steps S101- steps S103.
Step S101, receives service request.
In the operation system of service end, can typically mark off different levels to enter the isolation of line code and abstract, because
This, simple backend services system can be made up of in the multiple layerings with layering structure multiple, for example, the layering can be with
Including request entry level and several called layers, the request entry level is the entrance operation system of the service request
The superiors, it is also the starting for entering the operation system that the superiors can directly receive the service request request entry level
Layer, and the called layer can be called;Described several called layers at least partly between layers have call order, according to
Order is called, can be called by last layer successively.
The conventional layering structure can including service layer, field layer and data Layer etc., or expression layer, operation layer,
Data Layer etc., it is also possible to including Communication Layer, logical layer, data Layer etc..In a word, operation system can be by the side comprising multilayer
Formula realizes the complete execution of business, being performed required for performing this layer respectively in each layer of operation system for task.Wherein, often
Operation system can include service layer, field layer and data Layer, and different service requests are can perform by three layers.Institute
State service layer to can be set as asking entry level, for directly receiving external business request, in addition, use calling between layers
Mode connect, then accordingly, service layer can call field layer, and field layer can call data Layer.Above-mentioned call relation
As in the operation system order is called between each layer.
Because service layer, field layer and data Layer are the conventional layered modes of operation system, the present embodiment will be with the layering
Illustrated as a example by mode.Service request side sends service request signal by front end system, accordingly, the service requesting information
Need to be processed by the above three layer of backend services system, and for a service request, the service request is every
Can be printed upon the log information required for the service request in corresponding journal file by individual layer.
By above-mentioned introduction, illustrate in the operation system of service end, each layer may all receive service request, and according to
Calling sequentially between layers, can know, the service layer can receive service request, it is possible to the service request
Required parameter continues to call the field layer as Transfer Parameters, likewise, field layer can also be adjusted according to Transfer Parameters
Use the data Layer.
A service request is often performed, has corresponding operation in execution in corresponding service layer, field layer and data Layer,
Information produced by the operation is the follow-up log information for needing and printing.
The service request can be the process logged on log-in interface that requesting party initiates, or in register interface
Process registered etc., or the process paid the bill on payment interface etc., the particular type of the service request can have
It is various, as long as the request that requesting party initiates, can be divided into different classes by the request.
In addition, in order to ensure the daily record printing task be performed, it is necessary to set open the daily record print out task mode,
Only perform after unlatching operation, just the service request of reception can be carried out daily record printing, and unlatching operation can pass through
Various ways are realized, it is preferred that above-mentioned unlatching operation is realized by the way of the request of daily record blocker interception service.
Specifically, needing to use predetermined manner to set daily record interception mode for different layers in advance.
Due to the operation performed by the specific service request for performing in every layer be it is different, accordingly, every layer of behaviour of execution
Log information produced by making is also what is differed, accordingly, it would be desirable on the basis of layer, the daily record letter of different every layers be obtained respectively
Breath, so then every layer be required to perform for service request daily record print out task, therefore, every layer of entry position, be both needed to
Corresponding daily record blocker is set, the service request of the equivalent layer is called to intercept.
It is described it is advance use predetermined manner for every layer set daily record interception mode the step of in the predetermined manner include:
Can should be AOP (Aspect Oriented Programming) towards tangent plane mode towards tangent plane mode, below can be by
AOP substitutes noun as towards tangent plane mode.Specifically, the AOP is by precompile mode and runtime dynamic proxy reality
A kind of unified technology safeguarded of existing program function.AOP is the continuity of OOP, is a focus in software development, is also
An important content in Spring frameworks, is a kind of derivative pattern of functional expression programming.Can be to service logic using AOP
Various pieces isolated so that between service logic each several part the degree of coupling reduction, improve program reusability,
The efficiency of exploitation is improve simultaneously.
Herein, each layer in operation system can be isolated using AOP modes, daily record blocker is set and arrives each
On the interface method of the entry position of level.
Accordingly, daily record blocker is provided with every layer of interface method, and after the reception service request,
Following operation can be performed:
The service request is intercepted using the daily record interception mode, the daily record print out task of corresponding service request is performed.
The step is that every layer of service request is intercepted by daily record interception mode, and corresponding service can be performed after interception please
How the daily record print out task asked, specific daily record print out task performs, and can be introduced and be illustrated by subsequent step.
Fig. 1, step S102 are continued referring to, according to the service request, determines that corresponding layer and corresponding daily record are beaten
Print component.
Wherein, the daily record print components be used for by log information be printed upon to should daily record print components journal file
In.
The step is the species or type specifically according to service request, is that different types of service request configuration is different
The process of daily record print components, simply simple illustration and introduction have been carried out in above-mentioned steps to the service request.
For example, logging in this request for user, user can be logged in this process an as class, and be such
Service request determine corresponding daily record print components, and daily record print components are an instruments of print log, by daily record
Print components can will need printing log information print into corresponding journal file, therefore, daily record print components be with
Journal file is corresponding.
Accordingly, according to the type of service request, the log information produced by the service request of same type can be beaten
Can being printed with execution journal in print to identical journal file, also, in every layer for task, and can will log in this in every layer
The log information that the involved operation of one request is produced is printed into same journal file, and each layer of log information can be used
The mode that string is write is printed upon in same journal file.
Specifically, the type based on the service request, is that the service request determines corresponding daily record printing group
Part step includes by the way of:Obtain the type of service request.
The type of service request is obtained first, is determined corresponding daily record to allow to the type according to service request and is beaten
Print component.
Based on the type corresponding to the service request, using predetermined manner set the service request interface method so that
Obtain service request corresponding with corresponding daily record print components.
The predetermined manner includes:By the way of explaining;Or, using xml configuration modes.The side using note
Formula, is the note for increasing corresponding daily record print components on the interface method of service request, so that the interface side of service request
There is corresponding relation between method and corresponding daily record print components.
Above-mentioned predetermined manner is simultaneously constrained to above two mode, and other can enter interface method with daily record print components
The corresponding mode of row belongs to the scope of the application protection.
It is usually please according to the service request, the step for determine corresponding layer and corresponding daily record print components
Ask what entry level was completed, only after the request entry level of the superiors has configured corresponding daily record print components, be only possible to
The print out task of daily record is carried out in subsequent step using the daily record print components for configuring.
It is that the service request determines corresponding daily record print components step in addition, the type of the service request should be based on
Suddenly can be completed in the business information configuration module of encapsulation, the effect of the business information configuration module is using default side
Formula will ask the business interface method of entrance and the journal file of reality to be mapped.
Specifically, described according to the service request, after determining respective layer and corresponding daily record print components, can be with
Perform following operation:
Store the corresponding relation between the daily record print components and the daily record print components and corresponding service request.
The step is to store daily record print components with the corresponding relation of corresponding service request with daily record print components
The process come, due to can also be applied to the daily record print components in subsequent step, and also relates to daily record print components and phase
Corresponding relation between the service request answered, it is therefore desirable to herein stored above- mentioned information, so that subsequent step is carried out
State the acquisition of information.
In the application first embodiment, the daily record print components and the daily record print components are stored for by described
In the corresponding relation storage between corresponding service request, wherein storage mode can be including various, wherein preferred storage
Mode includes in the following manner:
The daily record print components and the daily record print components are deposited with the corresponding relation between corresponding service request
Storage is in thread local variable.
The thread local variable can be described as ThreadLocal, above-mentioned daily record can be stored in the ThreadLocal and is beaten
Print component and the corresponding relation between daily record print components and the service request of respective type.Storage is described
After in ThreadLocal, in each level of operation system, can be from the ThreadLocal in corresponding level
The middle corresponding daily record print components of acquisition, therefore, for identical service request, can be from the ThreadLocal in every layer
It is middle to read the daily record print components corresponding with the service request, and the daily record print components are used by the log information in every layer
Can print into identical journal file.
Accordingly, in all layers of the operation system in layering structure, the need for produced by the service request
The log information of record, is walked using being printed in corresponding journal file with the daily record print components that the service request is corresponding
Suddenly, Fig. 2 is the flow chart of the daily record print components print log process that the application first embodiment is provided, and refer to Fig. 2, the mistake
Journey comprises the following steps S102-1 to step S102-3:
Step S102-1, in each layer of the operation system of layering structure, the type according to the service request is obtained
Daily record print components corresponding with the service request.
It is accordingly, described due to storing in the thread local variable daily record print components in above-mentioned steps
In each layer of the operation system of layering structure, the type according to the service request obtains day corresponding with the service request
Will print components, are that each layer obtains daily record printing group corresponding to the service request from the thread local variable
Part.
In addition, being directed to identical service request, can read from the thread local variable (ThreadLocal) in every layer
The daily record print components corresponding with the service request are taken, and is printed the log information in every layer using the daily record print components
Into identical journal file.
Specifically, in each layer of the operation system in layering structure, the type according to the service request is obtained
Daily record print components step corresponding with the service request includes:
It is that the request entry level and several called layers set and call order.
The request entry level can call the first called layer, first called layer second can be called to be adjusted
With layer, the like, to set and calling order between request entry level and several called layers.Wherein, the request entrance
What layer was directly received is calling for outside requesting party.
Specifically, multiple layers of the operation system include request entry level and several called layers;The request
Entry level is the initial layers of the entrance operation system of the service request, and can call the called layer;Described several quilts
Calling layer at least partly has between layers calls order, is called by last layer successively according to order is called.
Secondly, it is that the request entry level and several called layers are set after calling sequentially, by asking for service request
Parameter is sought as interface parameters, according to the layer called in the operation system for sequentially calling different layers successively.
Entry position in each level is provided with interface method, using required parameter as interface parameters, by each layer
The interface method of entry position enters the transmission of line parameter and calls, to connect all layers.
Different layers type respectively according to the service request is obtained and the daily record print components corresponding to the service request.
After this step, following operation is performed:
Reverse-order according to order is called returns to the result of service request successively.The called layer that requested entry level is called
The result of service request is back to after request entry level, the result of service request is returned to request by the request entry level
Side.
Fig. 2, step S102-2 are continued referring to, the daily record recorded the need for obtaining produced by the service request in different layers
Information.
The step is the process for obtaining log information in every layer, and for each service request, the service request is in business
The operation of each layer of execution in system is different, and accordingly, the information produced by operation performed in every layer is referred to as daily record
Information, therefore, according to each layer of different operating, it will form different log informations.
Specifically, for example, log in this request, different according to every layer of effect, then the operation performed by every layer is also different,
For example, for service layer, field layer and data Layer, what may be performed in service layer is the user name that logs in user as request
Parameter, whether with the presence of the user name in decision-making system.And in field layer, may perform is by the corresponding request of required parameter
Object is changed into the internal object in system, and it no longer shows user name, but request is joined by the internal object being transformed into
Number is judged.What may be performed in data Layer is deterministic process to user cipher, and its operation for performing is exactly sentencing for password
It is disconnected.So, for a log on request, the operation performed by service layer, field layer and data Layer is different, accordingly, is held
Log information produced by row operation is also different, but all layers of log information is related to log in this request.
Above-mentioned two step has obtained corresponding daily record print components and every layer of daily record related to service request
Information, even if following step carries out the process of daily record printing by daily record print components.
Fig. 2, step S102-3 are continued referring to, the log information of different layers is printed using the daily record print components for determining
To in the corresponding journal file of the service request.
The step is completed on the basis of above-mentioned two step, and the daily record print components are the classes with service request
Type is corresponding, and the service request of same type will correspond to a daily record print components, then the daily record print components will be obtained in every layer
Log information produced by the service request of the type for taking is printed in same journal file.
Because the operation system of the layering structure includes request entry level and several called layers;The request entrance
Layer is the superiors of the entrance operation system of the service request;Described several called layers are used for suitable according to calling
Sequence, is called by last layer successively.
Accordingly, the type based on the service request, is that the service request determines corresponding daily record printing group
Part step, it, in the request entry level, is that the service request determines corresponding daily record based on the type of the service request to be
Print components.
It should be noted that the log information in the log information step recorded the need for produced by the service request is adopted
Obtain with the following methods:
The required parameter of the service request that each layer of basis is received is carried out accordingly in the operation system of the layering structure
The calling service of layer, every layer can obtain returning result corresponding with required parameter;Using the required parameter and returning result as
The log information.
It is, include required parameter and returning result for the log information involved by normal calling service, and
Most the required parameter and returning result are printed into corresponding journal file at last.
In addition, except above-mentioned normal calling service, extra calling service is further related to, therefore, the service request institute
Log information in the log information step recorded the need for generation also includes extra traffic solicited message, and the extra traffic please
Seek the information that information refers to the required printing specified corresponding to the extra traffic request that requesting party sends.
Accordingly, it is being related to the equivalent layer of the extra traffic request, is obtaining extra traffic and ask corresponding daily record printing
Component;Obtain the specify information of the required printing of the corresponding additional request parameter of the additional request business and return;Using
The daily record print components print to the specify information of the additional request parameter of acquisition and return in corresponding journal file.
Daily record print components have been obtained in above-mentioned steps, and the daily record print components are with the type of service request
It is mutually corresponding, therefore, subsequent step is the process printed to the log information for obtaining by the daily record print components.
Fig. 1, step S103 are continued referring to, the produced log information in corresponding layer of the service request is adopted
In journal file being printed to the daily record print components of the determination.
By the agency of mistake, can be based on the type of the service request in step s 102, be that the service request determines
After corresponding daily record print components, in thread local variable by above-mentioned daily record print components and the daily record print components with
Corresponding relation between corresponding service request is stored, and phase can be obtained from the thread local variable in subsequent step
The daily record print components answered.
Specifically, the step is realized using following steps:
In the different layers of the operation system of layering structure, the type according to the service request determines and the service request
Corresponding daily record print components.
Because the operation system of the layering structure includes request entry level and several called layers.The request entrance
Layer is the superiors of the entrance operation system of the service request;Described several called layers are used for suitable according to calling
Sequence, is called by last layer successively.Can be called corresponding to acquisition and service request in making every layer so as to foundation calls order
Daily record print components.
And then, the log information recorded the need for obtaining produced by the service request in different layers.
It should be noted that the log information in the log information step recorded the need for produced by the service request is adopted
Obtain with the following methods:
The required parameter of the service request that each layer of basis is received is carried out accordingly in the operation system of the layering structure
The calling service of layer, every layer can obtain returning result corresponding with required parameter;Using the required parameter and returning result as
The log information.
In addition, it is necessary to explanation, due to being related to call order between each layer in the multilayer that includes in operation system, because
This, it is described that the log information of different layers is printed into the corresponding daily record text of the service request using the daily record print components for determining
When in part, the arrangement of the log information in the journal file can also have order, specifically, it can be basis that this puts in order
Call what order was arranged between multilayer in operation system, accordingly, order can be called according to described, it is determined that printing to
The order of the log information in journal file.
It is, include required parameter and returning result for the log information involved by normal calling service, and
Most the required parameter and returning result are printed into corresponding journal file at last.
In addition, except above-mentioned normal calling service, extra calling service is further related to, therefore, the service request institute
Log information in the log information step recorded the need for generation also includes extra traffic solicited message, and the extra traffic please
Seek the information that information refers to the required printing specified corresponding to the extra traffic request that requesting party sends.
Accordingly, the log information that will be recorded the need for produced by the service request, using with the service request
Step includes during corresponding daily record print components print to corresponding journal file:
It is being related to the equivalent layer of the extra traffic request, is obtaining extra traffic and ask corresponding daily record print components;Obtain
Take the specify information of the required printing of the corresponding additional request parameter of the additional request business and return;Using the daily record
Print components print to the specify information of the additional request parameter of acquisition and return in corresponding journal file.
For each service request, the operation of each layer in operation system execution of the service request be it is different,
Accordingly, the information produced by operation for performing in every layer is referred to as log information, therefore, according to each layer of different operating, will
Different log informations can be formed.
Specifically, for example, log in this request, different according to every layer of effect, then the operation performed by every layer is also different,
For example, for service layer, field layer and data Layer, what may be performed in service layer is the user name that logs in user as request
Parameter, whether with the presence of the user name in decision-making system.And in field layer, may perform is by the corresponding request of required parameter
Object is changed into the internal object in system, and it no longer shows user name, but request is joined by the internal object being transformed into
Number is judged.What may be performed in data Layer is deterministic process to user cipher, and its operation for performing is exactly sentencing for password
It is disconnected.So, for a log on request, the operation performed by service layer, field layer and data Layer is different, accordingly, is held
Log information produced by row operation is also different, but all layers of log information is related to log in this request.
Afterwards, using the daily record print components for determining, that the log information of different layers is printed into the service request is corresponding
In journal file.
If type of service is identical, the daily record print components obtained in different layers are identicals, accordingly, using this
The journal file that log information in every layer is printed to is also identical by identical daily record print components.
Additionally, it is necessary to the result of this service request is returned into requesting party after daily record print out task has been performed, should
Specific echo plex mode is as follows:
The step in using the daily record print components for obtaining that every layer of log information is printed into identical journal file
Afterwards, following operation is performed:
Reverse-order according to order is called returns to the result of service request successively.
Be back to the result of service request after request entry level by the called layer that requested entry level is called, described to ask
Ask entry level that the result of service request is returned into requesting party.
Understand for convenience, the application first embodiment is illustrated by specific example to the above method, Fig. 3 is this
Application first embodiment provide service layer accept business request when sequential state diagram.Fig. 4 is the application first embodiment
The field layer of offer receives the state diagram of the sequential of service layer's calling service.Fig. 5 is the use that the application first embodiment is provided
The state diagram of the sequential of daily record print components print log.
Fig. 3 is directed to service layer and accepts business the sequential of request, refer to Fig. 3, and the service layer is the outside of operation system
The request entry level for calling, in the service layer, the daily record blocker interception service for being set by service layer entry position first
Request, after intercepting the service request, it will perform task of daily record printing is carried out for this service request.The specific daily record
Print out task is to determine the corresponding daily record print components of the service request by the setting of the interface method to service layer first
(logger) daily record blocker, and by the logger for determining is back to, meanwhile, the logger for getting is placed into line
In journey local variable (ThreadLocal), and return.Regular traffic can be sent to the service code position of service layer afterwards
Request, and the result of regular traffic is returned, print parameter and the return of this service request using logger again afterwards
Result, the result of this service request is finally returned to requesting party.
Fig. 4 is directed to the sequential that field layer receives service layer's calling service, refer to Fig. 4, and the data Layer receives service layer
Call after, the daily record blocker of field layer first will intercept the request, and current business is obtained from ThreadLocal please
Corresponding logger is sought, and is returned, send calling for regular traffic to field layer service code again afterwards, return to the regular traffic
The result called, the request that field layer is then printed using the logger for obtaining enters ginseng and result, and most backward service layer returns
The result of this business.
And data Layer receive sequential that field layer service calls and field layer receive service layer calling service when
What sequence was similar to, here is omitted.
Fig. 5 is directed to the process called and print of regular traffic, refer to Fig. 5, first to daily record printing tools module
Print log call parameters are initiated, the information to be printed is transmitted, current service request correspondence is obtained from ThreadLocal afterwards
Logger, and return, then print incoming log information, the result of final this time printing using the logger for obtaining.
In a word, when daily record blocker is after request entrance intercepts service request, obtained employment according to the interface method for calling
Business information collocation module gets the corresponding daily record print components of the service request, is then placed into the daily record print components
In ThreadLocal.Follow-up level blocker all gets current business after intercepting and calling from ThreadLocal
Logger, then carries out daily record printing using the logger that this gets.
Therefore, the method can investigate problem and prison by a daily record printing for service request in one file on line
Control only needs to pay close attention to a journal file for a business, interference is reduced, while enhancing the performance of monitoring system.Separately
Outward, this method can also print the required parameter and returning result of each level by predetermined manner, be transmitted without display
Logger, therefore, to service code without invasive, configuration can make developer be absorbed in service code using simple, without
The printing of additional relationships daily record.
The application second embodiment provides a kind of daily record printing equipment, and Fig. 6 is the daily record that the application second embodiment is provided
The structural representation of printing equipment, refer to Fig. 6, and the device includes:
Service request receiving unit 601, for receiving service request;
Daily record print components determining unit 602, for according to the service request, determining corresponding layer and corresponding day
Will print components;
Log information print unit 603, for by the produced log information in corresponding layer of the service request, adopting
In journal file being printed to the daily record print components of the determination.
Optionally, the device also includes:
Memory cell, for, according to the service request, determining respective layer and corresponding daily record print components described
Afterwards, the daily record print components and the corresponding relation between the daily record print components and corresponding service request are stored;
The log information print unit includes:
Daily record print components obtain subelement, in the different layers of operation system, according to the class of the service request
Type determines the daily record print components corresponding to the service request;
Log information obtain subelement, for obtaining produced by the service request in different layers the need for record daily record letter
Breath;
Printing subelement, for the log information of different layers to be printed into the business using the daily record print components for determining
In asking corresponding journal file.
Optionally, multiple layers of the operation system include request entry level and several called layers;
The request entry level is the initial layers of the entrance operation system of the service request, and can call described called
Layer;Described several called layers at least partly between layers have call order, according to call order successively by last layer
Called;
The daily record print components determining unit is carried out in the request entry level.
Optionally, the daily record print components obtain subelement and include:
Subelement is called, for using the required parameter of service request as interface parameters, order being called successively according to described
Call the layer of the operation system of different layers;
Subelement is obtained, corresponding to the type determination and the service request for different layers respectively according to the service request
Daily record print components.
Optionally, the device also includes:
Service request result returning unit, for being believed the daily record of different layers using the daily record print components for determining described
During breath prints to the corresponding journal file of the service request, the knot of service request is returned successively according to the reverse-order for calling order
Really;
Result returns to requesting party's unit, returns to the result of service request for being requested the called layer that entry level is called
To request entry level, the result of service request is returned to requesting party by the request entry level.
Optionally, the log information in the produced log information in the corresponding layer of the service request also includes extra
Service requesting information, the extra traffic solicited message refers to the institute for specifying corresponding to the extra traffic request that requesting party sends
Need the information of printing;
The log information print unit includes:
Additional request obtains subelement, for including the layer of the extra traffic request, determines that extra traffic is asked
Corresponding daily record print components;
Specify information obtains subelement, for obtaining the corresponding additional request parameter of the additional request business and return
The specify information of required printing;
Specify information prints subelement, for the additional request parameter that will be obtained using the daily record print components for determining
And during the specify information for returning prints to the journal file corresponding with extra traffic request.
Optionally, the daily record print components determining unit includes:
Type obtains subelement, the corresponding type for obtaining service request;
Printing subelement, for the corresponding type based on the service request, setting the business using predetermined manner please
The interface method asked is with so that have corresponding relation between service request and corresponding daily record print components.
Optionally, also include:
Daily record interception mode setting unit, is every layer of setting daily record interception mode for using predetermined manner in advance;
Daily record print out task execution unit, for after the reception service request, different layers to use the daily record
Interception mode intercepts the service request of equivalent layer respectively, to perform the daily record print out task of corresponding service request.
The application 3rd embodiment also provides a kind of daily record print system, and Fig. 7 is the day that the application 3rd embodiment is provided
The structural representation of will print system, refer to Fig. 7, and the system includes:
Automatic blocker module 701, for interception service request, and is configured to industry using predetermined manner by daily record blocker
On the interface of each layer of business system;
Business information configuration module 702, the service request for receiving automatic blocker block intercepts, and please based on business
Ask, be that service request is configured to determine and the daily record print components corresponding to the service request;
Daily record printing tools module 703, for after automatic blocker block intercepts to service request, being believed using business
The daily record print components of breath configuration module configuration print log in operation system.
Optionally, the automatic blocker module is each that the operation system is arranged at by way of towards tangent plane
On the interface of layer.
Optionally, the business information configuration module will have been configured daily record print components and the corresponding relation of service request
Storage is in the thread for safeguarding the corresponding relation;
Accordingly, that daily record print components are obtained from the thread is right with service request for the daily record printing tools module
Should be related to, and be printed to the log information produced by the operation of corresponding service request accordingly using the daily record print components
In journal file.
Specifically, the business information configuration module is arranged in request entry level, the business information configuration module is supported
Using note and xml configuration modes, the interface method and journal file of business are mapped.Preferably, it is possible to use explain
Mode, the note mode only need to be on business interface method plus the note of journal file.
After the request entrance of the blocker operation system intercepts request, according to the interface method for calling from business information
Configuration module gets the corresponding daily record logger of business, and then logger is placed into threadlocal.Follow-up level is blocked
Cut device intercept call after the logger of current business is all got from threadlocal, then use this logger
Print log.
The daily record printing tools module, can be from when print log without explicitly transmitting logger
The logger of current business is got in threadlocal, this logger print log is then used.Also, when business system
When system has extra business printing demand, it is also possible to usage log printing tools module print log in operation system.
The application fourth embodiment provides a kind of electronic equipment, and Fig. 8 is the electronic equipment that the application fourth embodiment is provided
Structural representation, refer to Fig. 8, the electronic equipment includes:
Display 801;
Processor 802;
Memory 803;For store daily record printing program, the equipment be powered and run the daily record printing program after,
Perform following step:Receive service request;According to the service request, respective layer and corresponding daily record print components are determined;
By the produced log information in respective layer of the service request, day is printed to using the daily record print components of the determination
In will file, wherein, the method is applied in operation system, and the operation system includes multiple layers.
Although the application is disclosed as above with preferred embodiment, it is not for limiting the application, any this area skill
Art personnel can make possible variation and modification not departing from spirit and scope, thus the application guarantor
The scope that shield scope should be defined by the application claim is defined.
In a typical configuration, computing device includes one or more processors (CPU), input/output interface, net
Network interface and internal memory.Internal memory potentially includes the volatile memory in computer-readable medium, random access memory (RAM)
And/or the form, such as read-only storage (ROM) or flash memory (flash RAM) such as Nonvolatile memory.Internal memory is that computer-readable is situated between
The example of matter.
Computer-readable medium includes that permanent and non-permanent, removable and non-removable media can be by any method
Or technology realizes information Store.Information can be computer-readable instruction, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase transition internal memory (PRAM), static RAM (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only storage (ROM), electric erasable
Programmable read only memory (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read-only storage (CD-ROM),
Digital versatile disc (DVD) or other optical storages, magnetic cassette tape, the storage of tape magnetic rigid disk or other magnetic storage apparatus
Or any other non-transmission medium, can be used to store the information that can be accessed by a computing device.Defined according to herein, calculated
Machine computer-readable recording medium does not include non-temporary computer readable media (transitory media), such as data-signal and carrier wave of modulation.
It will be understood by those skilled in the art that embodiments herein can be provided as method, system or computer program product.
Therefore, the application can be using the embodiment in terms of complete hardware embodiment, complete software embodiment or combination software and hardware
Form.And, the application can be used to be can use in one or more computers for wherein including computer usable program code and deposited
The shape of the computer program product implemented on storage media (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.)
Formula.