best way for logging WHO did WHAT in spring web apps?
i am doing a Spring web application and
i have a design/implementation question. i have
not figured out how to do it the best way.
the requriement is to record WHO(which user)
did WHAT (save, delete...) in the application.
i have seen a few Spring web apps)
but they only record WHAT.
this can be accomplished in the service tier
easily. specifically, when an operation is done,
a service method simply writes a log entry.
however, i have two issues with this
approach. first, how can the service tier
get User information (the WHO part)?
i can make each method in a service manager
take a parameter of user information, but
this would service interface ugly. on the
other hand, i think the logging/auditing is
NOT a service manager's job.
the other option for me is to write
log entries (through an audit service manager)
in web controllers. specifically,
writing a log entry after a service method
is called successfully. however, this approach
is not ideal either, since the same method
may be called in many places and i have
to write logging statements the same way
repeatedly. besides, i have to wire
audit service manager with almost each
web controller.
then, the AOP approach? i dont know how
Spring AOP can help me log WHO did WHAT.
i have seen some examples, but they
are really simplistic, most often missing
both the WHO part and detailed information
about WHAT.
other approaches? somehow, i would like
to do the logging in service managers.
but i dont know how to make user information
available to service managers in an
elegant way.
anybody has the same problem as i do?
any advice? any solution?
thanks!
pete