Skip to main content

Posts

Showing posts with the label Attribute

Using Spring AOP to create a quick/simple auditing mechanism

These days I have been working in .NET. The project I am on uses Spring.NET and NHibernate for data access. One of the requirements of the project was to capture user activity and log them. There are certainly many different approaches to achieve this goal. There are solutions that you could deploy to your database (triggers etc.) or create application level services that would capture and log user activity. Since the project was already utilizing Spring, I wanted to utilize Spring's AOP features. The first thing I did was to create two database tables that would hold audit data. The first table I called history_log and the second table I called history_log_param . The history_log table has the following columns. CREATE TABLE [dbo].[history_log]( [id] [int] IDENTITY(1,1) NOT NULL, [table_name] [varchar](50) NOT NULL, [method_name] [varchar](50) NOT NULL, [argument_count] [int] NOT NULL, [message] [varchar](500) NOT NULL, [user_name] [varchar](50) NOT NULL, [date] [datetime...