Audit Logging

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Audit Logging

Ivan B
Can anyone suggest a way to audit and log operations done through
myBatis. We need this for common criteria and we'd like to stay away
from using aspect, triggers, or spring.

Is there a built in way to do this in myBatis?

Much appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Audit Logging

Guy Rouillier
On 10/12/2010 6:09 PM, Ivan B wrote:
> Can anyone suggest a way to audit and log operations done through
> myBatis. We need this for common criteria and we'd like to stay away
> from using aspect, triggers, or spring.
>
> Is there a built in way to do this in myBatis?

You could enable DEBUG level logging, which prints out all the SQL
statements executed by MyBatis (and other things - parameter
substitutions, results.)  You could then set up a logger to put these
log statements where you want them, e.g., syslog or into a database.

--
Guy Rouillier
Reply | Threaded
Open this post in threaded view
|

Re: Audit Logging

Ivan B
Thank you. That is an interesting idea. The only concern is if setting
DEBUG
level logging will decrease performance significantly.

Never than less very interesting idea.

On Oct 12, 3:15 pm, Guy Rouillier <[hidden email]> wrote:

> On 10/12/2010 6:09 PM, Ivan B wrote:
>
> > Can anyone suggest a way to audit and log operations done through
> > myBatis. We need this for common criteria and we'd like to stay away
> > from using aspect, triggers, or spring.
>
> > Is there a built in way to do this in myBatis?
>
> You could enable DEBUG level logging, which prints out all the SQL
> statements executed by MyBatis (and other things - parameter
> substitutions, results.)  You could then set up a logger to put these
> log statements where you want them, e.g., syslog or into a database.
>
> --
> Guy Rouillier
Reply | Threaded
Open this post in threaded view
|

Re: Audit Logging

Clinton Begin
Administrator
Logging will decrease performance quite a bit I think.... but you could test it to validate that. 



On Tue, Oct 12, 2010 at 4:45 PM, Ivan B <[hidden email]> wrote:
Thank you. That is an interesting idea. The only concern is if setting
DEBUG
level logging will decrease performance significantly.

Never than less very interesting idea.

On Oct 12, 3:15 pm, Guy Rouillier <[hidden email]> wrote:
> On 10/12/2010 6:09 PM, Ivan B wrote:
>
> > Can anyone suggest a way to audit and log operations done through
> > myBatis. We need this for common criteria and we'd like to stay away
> > from using aspect, triggers, or spring.
>
> > Is there a built in way to do this in myBatis?
>
> You could enable DEBUG level logging, which prints out all the SQL
> statements executed by MyBatis (and other things - parameter
> substitutions, results.)  You could then set up a logger to put these
> log statements where you want them, e.g., syslog or into a database.
>
> --
> Guy Rouillier

Reply | Threaded
Open this post in threaded view
|

Re: Audit Logging

François Schiettecatte
In reply to this post by Ivan B
You could always modify iBatis to log what you are looking for. What about at the JDBC driver level? And you did not mention what RDBMS you are using, I know that MySQL allows you to log all statements to a file or to a table.

François

On Oct 12, 2010, at 6:45 PM, Ivan B wrote:

> Thank you. That is an interesting idea. The only concern is if setting
> DEBUG
> level logging will decrease performance significantly.
>
> Never than less very interesting idea.
>
> On Oct 12, 3:15 pm, Guy Rouillier <[hidden email]> wrote:
>> On 10/12/2010 6:09 PM, Ivan B wrote:
>>
>>> Can anyone suggest a way to audit and log operations done through
>>> myBatis. We need this for common criteria and we'd like to stay away
>>> from using aspect, triggers, or spring.
>>
>>> Is there a built in way to do this in myBatis?
>>
>> You could enable DEBUG level logging, which prints out all the SQL
>> statements executed by MyBatis (and other things - parameter
>> substitutions, results.)  You could then set up a logger to put these
>> log statements where you want them, e.g., syslog or into a database.
>>
>> --
>> Guy Rouillier

Reply | Threaded
Open this post in threaded view
|

Re: Audit Logging

Andrius Juozapaitis
In reply to this post by Clinton Begin
why would you want to stay away from using aspects? that's exactly the
type of use case you can realize with almost zero effort using
aspectj.

regards,
Andrius Juozapaitis
ps. I know of a few scenarios where aspects are not desirable - like
remoting objects, but proxying your service layer (or mybatis, for
that matter) is really the most straightforward implementation for
this requirement.

On Wed, Oct 13, 2010 at 1:49 AM, Clinton Begin <[hidden email]> wrote:

> Logging will decrease performance quite a bit I think.... but you could test
> it to validate that.
>
>
> On Tue, Oct 12, 2010 at 4:45 PM, Ivan B <[hidden email]> wrote:
>>
>> Thank you. That is an interesting idea. The only concern is if setting
>> DEBUG
>> level logging will decrease performance significantly.
>>
>> Never than less very interesting idea.
>>
>> On Oct 12, 3:15 pm, Guy Rouillier <[hidden email]> wrote:
>> > On 10/12/2010 6:09 PM, Ivan B wrote:
>> >
>> > > Can anyone suggest a way to audit and log operations done through
>> > > myBatis. We need this for common criteria and we'd like to stay away
>> > > from using aspect, triggers, or spring.
>> >
>> > > Is there a built in way to do this in myBatis?
>> >
>> > You could enable DEBUG level logging, which prints out all the SQL
>> > statements executed by MyBatis (and other things - parameter
>> > substitutions, results.)  You could then set up a logger to put these
>> > log statements where you want them, e.g., syslog or into a database.
>> >
>> > --
>> > Guy Rouillier
>
Reply | Threaded
Open this post in threaded view
|

Re: Audit Logging

Larry Meadors
Heh, I was wondering the same thing - the textbook case for AOP is
transparent logging...

On Tue, Oct 12, 2010 at 4:53 PM, Andrius Juozapaitis <[hidden email]> wrote:

> why would you want to stay away from using aspects? that's exactly the
> type of use case you can realize with almost zero effort using
> aspectj.
>
> regards,
> Andrius Juozapaitis
> ps. I know of a few scenarios where aspects are not desirable - like
> remoting objects, but proxying your service layer (or mybatis, for
> that matter) is really the most straightforward implementation for
> this requirement.
>
> On Wed, Oct 13, 2010 at 1:49 AM, Clinton Begin <[hidden email]> wrote:
>> Logging will decrease performance quite a bit I think.... but you could test
>> it to validate that.
>>
>>
>> On Tue, Oct 12, 2010 at 4:45 PM, Ivan B <[hidden email]> wrote:
>>>
>>> Thank you. That is an interesting idea. The only concern is if setting
>>> DEBUG
>>> level logging will decrease performance significantly.
>>>
>>> Never than less very interesting idea.
>>>
>>> On Oct 12, 3:15 pm, Guy Rouillier <[hidden email]> wrote:
>>> > On 10/12/2010 6:09 PM, Ivan B wrote:
>>> >
>>> > > Can anyone suggest a way to audit and log operations done through
>>> > > myBatis. We need this for common criteria and we'd like to stay away
>>> > > from using aspect, triggers, or spring.
>>> >
>>> > > Is there a built in way to do this in myBatis?
>>> >
>>> > You could enable DEBUG level logging, which prints out all the SQL
>>> > statements executed by MyBatis (and other things - parameter
>>> > substitutions, results.)  You could then set up a logger to put these
>>> > log statements where you want them, e.g., syslog or into a database.
>>> >
>>> > --
>>> > Guy Rouillier
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Audit Logging

Ivan B
In reply to this post by Andrius Juozapaitis
One word (or two): "time to market"

In any other case I would say Aspect is the way to do it.

Thank you for the input.

On Oct 12, 3:53 pm, Andrius Juozapaitis <[hidden email]> wrote:

> why would you want to stay away from using aspects? that's exactly the
> type of use case you can realize with almost zero effort using
> aspectj.
>
> regards,
> Andrius Juozapaitis
> ps. I know of a few scenarios where aspects are not desirable - like
> remoting objects, but proxying your service layer (or mybatis, for
> that matter) is really the most straightforward implementation for
> this requirement.
>
>
>
> On Wed, Oct 13, 2010 at 1:49 AM, Clinton Begin <[hidden email]> wrote:
> > Logging will decrease performance quite a bit I think.... but you could test
> > it to validate that.
>
> > On Tue, Oct 12, 2010 at 4:45 PM, Ivan B <[hidden email]> wrote:
>
> >> Thank you. That is an interesting idea. The only concern is if setting
> >> DEBUG
> >> level logging will decrease performance significantly.
>
> >> Never than less very interesting idea.
>
> >> On Oct 12, 3:15 pm, Guy Rouillier <[hidden email]> wrote:
> >> > On 10/12/2010 6:09 PM, Ivan B wrote:
>
> >> > > Can anyone suggest a way to audit and log operations done through
> >> > > myBatis. We need this for common criteria and we'd like to stay away
> >> > > from using aspect, triggers, or spring.
>
> >> > > Is there a built in way to do this in myBatis?
>
> >> > You could enable DEBUG level logging, which prints out all the SQL
> >> > statements executed by MyBatis (and other things - parameter
> >> > substitutions, results.)  You could then set up a logger to put these
> >> > log statements where you want them, e.g., syslog or into a database.
>
> >> > --
> >> > Guy Rouillier
Reply | Threaded
Open this post in threaded view
|

Re: Audit Logging

Andrius Juozapaitis
You just spent more time writing the post than it would have taken to
actually code it. Seriously, take a look at the tutorials, there are
things like profiling aspects in there - with just minor changes, they
would do exactly what you need. Laziness is not an excuse to avoid to
make things easier :)

regards,
Andrius

On Wed, Oct 13, 2010 at 2:30 AM, Ivan B <[hidden email]> wrote:

> One word (or two): "time to market"
>
> In any other case I would say Aspect is the way to do it.
>
> Thank you for the input.
>
> On Oct 12, 3:53 pm, Andrius Juozapaitis <[hidden email]> wrote:
>> why would you want to stay away from using aspects? that's exactly the
>> type of use case you can realize with almost zero effort using
>> aspectj.
>>
>> regards,
>> Andrius Juozapaitis
>> ps. I know of a few scenarios where aspects are not desirable - like
>> remoting objects, but proxying your service layer (or mybatis, for
>> that matter) is really the most straightforward implementation for
>> this requirement.
>>
>>
>>
>> On Wed, Oct 13, 2010 at 1:49 AM, Clinton Begin <[hidden email]> wrote:
>> > Logging will decrease performance quite a bit I think.... but you could test
>> > it to validate that.
>>
>> > On Tue, Oct 12, 2010 at 4:45 PM, Ivan B <[hidden email]> wrote:
>>
>> >> Thank you. That is an interesting idea. The only concern is if setting
>> >> DEBUG
>> >> level logging will decrease performance significantly.
>>
>> >> Never than less very interesting idea.
>>
>> >> On Oct 12, 3:15 pm, Guy Rouillier <[hidden email]> wrote:
>> >> > On 10/12/2010 6:09 PM, Ivan B wrote:
>>
>> >> > > Can anyone suggest a way to audit and log operations done through
>> >> > > myBatis. We need this for common criteria and we'd like to stay away
>> >> > > from using aspect, triggers, or spring.
>>
>> >> > > Is there a built in way to do this in myBatis?
>>
>> >> > You could enable DEBUG level logging, which prints out all the SQL
>> >> > statements executed by MyBatis (and other things - parameter
>> >> > substitutions, results.)  You could then set up a logger to put these
>> >> > log statements where you want them, e.g., syslog or into a database.
>>
>> >> > --
>> >> > Guy Rouillier
Reply | Threaded
Open this post in threaded view
|

Re: Audit Logging

Larry Meadors
Probably don't even have to write it - I bet p6spy would do what you need.

Free and open source - apache style license.

Larry


On Tue, Oct 12, 2010 at 5:35 PM, Andrius Juozapaitis <[hidden email]> wrote:

> You just spent more time writing the post than it would have taken to
> actually code it. Seriously, take a look at the tutorials, there are
> things like profiling aspects in there - with just minor changes, they
> would do exactly what you need. Laziness is not an excuse to avoid to
> make things easier :)
>
> regards,
> Andrius
>
> On Wed, Oct 13, 2010 at 2:30 AM, Ivan B <[hidden email]> wrote:
>> One word (or two): "time to market"
>>
>> In any other case I would say Aspect is the way to do it.
>>
>> Thank you for the input.
>>
>> On Oct 12, 3:53 pm, Andrius Juozapaitis <[hidden email]> wrote:
>>> why would you want to stay away from using aspects? that's exactly the
>>> type of use case you can realize with almost zero effort using
>>> aspectj.
>>>
>>> regards,
>>> Andrius Juozapaitis
>>> ps. I know of a few scenarios where aspects are not desirable - like
>>> remoting objects, but proxying your service layer (or mybatis, for
>>> that matter) is really the most straightforward implementation for
>>> this requirement.
>>>
>>>
>>>
>>> On Wed, Oct 13, 2010 at 1:49 AM, Clinton Begin <[hidden email]> wrote:
>>> > Logging will decrease performance quite a bit I think.... but you could test
>>> > it to validate that.
>>>
>>> > On Tue, Oct 12, 2010 at 4:45 PM, Ivan B <[hidden email]> wrote:
>>>
>>> >> Thank you. That is an interesting idea. The only concern is if setting
>>> >> DEBUG
>>> >> level logging will decrease performance significantly.
>>>
>>> >> Never than less very interesting idea.
>>>
>>> >> On Oct 12, 3:15 pm, Guy Rouillier <[hidden email]> wrote:
>>> >> > On 10/12/2010 6:09 PM, Ivan B wrote:
>>>
>>> >> > > Can anyone suggest a way to audit and log operations done through
>>> >> > > myBatis. We need this for common criteria and we'd like to stay away
>>> >> > > from using aspect, triggers, or spring.
>>>
>>> >> > > Is there a built in way to do this in myBatis?
>>>
>>> >> > You could enable DEBUG level logging, which prints out all the SQL
>>> >> > statements executed by MyBatis (and other things - parameter
>>> >> > substitutions, results.)  You could then set up a logger to put these
>>> >> > log statements where you want them, e.g., syslog or into a database.
>>>
>>> >> > --
>>> >> > Guy Rouillier
>
Reply | Threaded
Open this post in threaded view
|

Re: Audit Logging

Hunter
What about using MyBatis' built in Interceptors (see the plugins
section in the User Guide). I can't speak to performance, but it would
keep you from having to use another library / configuration.

Do you need to log MyBatis itself or just the underlying DB? If just
the DB, maybe the standard audit tables / triggers approach would be
another way to go.

On Oct 13, 12:15 pm, Larry Meadors <[hidden email]> wrote:

> Probably don't even have to write it - I bet p6spy would do what you need.
>
> Free and open source - apache style license.
>
> Larry
>
>
>
> On Tue, Oct 12, 2010 at 5:35 PM, Andrius Juozapaitis <[hidden email]> wrote:
> > You just spent more time writing the post than it would have taken to
> > actually code it. Seriously, take a look at the tutorials, there are
> > things like profiling aspects in there - with just minor changes, they
> > would do exactly what you need. Laziness is not an excuse to avoid to
> > make things easier :)
>
> > regards,
> > Andrius
>
> > On Wed, Oct 13, 2010 at 2:30 AM, Ivan B <[hidden email]> wrote:
> >> One word (or two): "time to market"
>
> >> In any other case I would say Aspect is the way to do it.
>
> >> Thank you for the input.
>
> >> On Oct 12, 3:53 pm, Andrius Juozapaitis <[hidden email]> wrote:
> >>> why would you want to stay away from using aspects? that's exactly the
> >>> type of use case you can realize with almost zero effort using
> >>> aspectj.
>
> >>> regards,
> >>> Andrius Juozapaitis
> >>> ps. I know of a few scenarios where aspects are not desirable - like
> >>> remoting objects, but proxying your service layer (or mybatis, for
> >>> that matter) is really the most straightforward implementation for
> >>> this requirement.
>
> >>> On Wed, Oct 13, 2010 at 1:49 AM, Clinton Begin <[hidden email]> wrote:
> >>> > Logging will decrease performance quite a bit I think.... but you could test
> >>> > it to validate that.
>
> >>> > On Tue, Oct 12, 2010 at 4:45 PM, Ivan B <[hidden email]> wrote:
>
> >>> >> Thank you. That is an interesting idea. The only concern is if setting
> >>> >> DEBUG
> >>> >> level logging will decrease performance significantly.
>
> >>> >> Never than less very interesting idea.
>
> >>> >> On Oct 12, 3:15 pm, Guy Rouillier <[hidden email]> wrote:
> >>> >> > On 10/12/2010 6:09 PM, Ivan B wrote:
>
> >>> >> > > Can anyone suggest a way to audit and log operations done through
> >>> >> > > myBatis. We need this for common criteria and we'd like to stay away
> >>> >> > > from using aspect, triggers, or spring.
>
> >>> >> > > Is there a built in way to do this in myBatis?
>
> >>> >> > You could enable DEBUG level logging, which prints out all the SQL
> >>> >> > statements executed by MyBatis (and other things - parameter
> >>> >> > substitutions, results.)  You could then set up a logger to put these
> >>> >> > log statements where you want them, e.g., syslog or into a database.
>
> >>> >> > --
> >>> >> > Guy Rouillier