Background technology
General enterprise management system required by all having to the integrality of data, such as requires system to be unable to physics and deletes
Except record, it is desirable that will there is system to record or update certain data when adding each data and be required for tracing into variation
Content or while deleting data, which need whom is recorded, to be deleted, and when is deleted, so as to can by system or manually after delete by mistake
Some functions recover the data deleted by mistake.Realize that this function is referred to as operation log.
The main purpose for doing operation log is the operation behavior that trace into each user in system, for example, to data into
The behaviors such as row is inquired about, is newly-increased, editing or deletion even logs in.Further, it is possible to understand that be that system feelings are used to user
The tracking of condition is recorded, foundation when preventing data from surprisingly deleting, changing the tracking of data, to be gone back to data
Original can protect the integrality of data from certain program.
In specific enterprise's application scenarios, generally require (such as shown below to a certain existing table
Employee tables) it is operated, such as:It is added or the operation of fresh information, the operation for being inquired about or being deleted information.It is existing
It is needing to do a system log to the behavioural information for operating the table, current operation way is:One is established with existing table more
The same table, increases the additional information of operation behavior, for example, establish one it is corresponding with Employee table handling behaviors
EmployeeLog tables, wherein having added some as LogCreated (date is added in daily record) and OperationType (is inquired about, new
Increase, delete, update) attached information.
This way is possible for single operation log recording, but if being recorded to multiple operations
Words, such as to make EmployeeIncome (the income situation of employee) to Employee tables table does daily record, and needs to table
FixedAsset (fixed assets) carries out log recording, if establishing a corresponding operation day using for each operation
If will table, doubling for table quantity can not only be caused by so doing, and greatly add workload and development time, to data
Storehouse table not manageability situations such as.
Therefore, it is necessary to provide a kind of new blog management method, with more than solution.
The content of the invention
It is an object of the invention to provide a kind of method of operation log management, can solve to be involved in Java Web should
With the different operation notes under middle different business state in database, facilitate monitoring system use state and analysis mistake letter
While breath, it is not necessary to increase relevant operation data record sheet, reduce workload and development time, convenient for managing database table.
For solution more than technical problem, the present invention provides a kind of method of operation log management, including:
The daily record for setting up to store business information is set;
Set up to store the log setting detail for the details that the business information needs of configuration log setting record;
Set up to record the operation log of the concrete operations of business information during User operation log is set.
Further, the business information that the daily record is set includes at least business table name, Business Name, major key.
Further, the log setting detail is corresponding with the business information that the daily record is set, and stores the business
The details that information needs record.
Further, the user's operation includes at least one of following operation:Inquiry, newly-increased, deletion, update.
Further, in the method, according to the business information that configuration log is set, global daily record controller
LogManagerment is cut into the expression formula of the class that can be matched and method by AOP services, and used method is performed
Before methods can be called before, are obtained log information, and are written into database or journal file.
Compared with prior art, the present invention provides a kind of method of operation log management, by simply configuring and writing
It can realize the log management of sophisticated functions, realization is involved in different under different business state in Java Web applications
Operation note facilitates monitoring system use state and analysis error message in database;It need not when being carried out at the same time log recording
Increase relevant operation data record sheet, greatly reduce workload and development time, convenient for managing database table.
Specific embodiment
In order to make technical problems, technical solutions and advantages to be solved clearer, clear, tie below
Drawings and examples are closed, the present invention will be described in further detail.It should be appreciated that specific embodiment described herein is only used
To explain the present invention, it is not intended to limit the present invention.
As shown in Figure 1, the present invention provides a kind of method of operation log management, including:
It sets up daily record and (LogSetting) is set, include the business such as business table name, Business Name, major key letter for storing
Breath.
Log setting detail (LogsettingDetail) is set up, corresponds to the business information during daily record is set, is used for
The details of record required for storing the business information during configuration log is set.For example, it is necessary to record word in Employee tables
The information such as section Name, Gender.
Operation log (LogOperation) is set up, for recording the tool of various businesses information during User operation log is set
Body operational circumstances.Such as:Carry out query, add, delete, update and other operations.
Fig. 2 is the function parsing that the technique according to the invention provides a kind of specific implementation of the method for operation log management
Figure.
As shown in Fig. 2, daily record sets the business information of configuration storage daily record, including:TableName (business table name),
BusinessName (Business Name), PrimaryKey (major key), URLTemplate (URL template), CreateUser (are created
Person), CreateTime (creation time), DeleteScriptTemplate, UpdateScriptTemplate.These business are believed
It ceases and provides service basic for user's operation.
Log setting detail corresponds to the business information during daily record is set, and the business information during storage configuration log is set needs
The detailed content to be recorded, including:LogID, ColumnName (field name), ColumnText (the field meaning),
ColumnDataType (data type), CreateUser (founder), CreateTime (creation time).
The concrete condition of various businesses information during operation log recording User operation log is set, including:LogID、
OperationType (action type), PrimaryKeyValue (Major key), Content (content), URL, CreateUser
(founder), CreateTime (creation time).
In order to make technical scheme clearer, clear, below in conjunction with specific implementation the technology of the present invention side
The embodiment of case, the present invention will be described in further detail.
Present embodiment is realized using Spring AOP and reflection.
The configuration of Spring in the project:
<!-- configuration log management -->
<Bean id=" LogManagerment " class=" com.log.LogManagerment "></bean>
<aop:config>
<!-- calling daily record class -->
<aop:Aspectid=" b " ref=" LogManagerment ">
<!-- the add methods of all classes under com*.dao bags are configured, can be all intercepted before calling -->
<aop:Pointcutid=" logScope " expression=" execution (* com.dao.*.add*
(..))"/>
<!-- the add methods of all classes can be called before performing in LogManagerment under com*.dao bags
Before methods -->
<aop:Beforepointcut-ref=" logScope " method=" before "/>
</aop:aspect>
</aop:config>
According to the business information that configuration log is set, global daily record controller LogManagerment is serviced by AOP
The expression formula expression of the class that can be matched and method is cut into, these methods are performed before calling before methods,
And log information (including Business Name, field name and type etc.) is got in method, and it is written to database or daily record
In file.
Daily record has system log, business operation log, work log etc..
System log:Inquire about operation note to system in specified time section for user, it is unrelated with specific business, it is necessary to
When configure.
Business operation log:It is related with the specific business of system, it is the set of a series of operation log.
Work log:Be the progress for tracking business, manager facilitated preferably to hold job progress, so as to and
When be controlled by, effectively allocate resource.In modern target, manager can check a department or project team member in batches
Daily record, track critical event, in time instruct;In addition, work log also has the effect that achievement proves, workload, the work of employee
Make effect to be embodied herein, it is helpful to managing.
A preferred embodiment of the present invention has shown and described in above description, but as previously described, it should be understood that the present invention
Be not limited to form disclosed herein, be not to be taken as the exclusion to other embodiment, and available for various other combinations,
Modification and environment, and above-mentioned introduction or the technology or knowledge of association area can be passed through in the scope of the invention is set forth herein
It is modified.And changes and modifications made by those skilled in the art do not depart from the spirit and scope of the present invention, then it all should be in this hair
In the protection domain of bright appended claims.