views:

84

answers:

1

I have java webapp (written in spring mvc) and running on tomcat. I want to log user's behavior into a separate log file (separate from what we're logging right now to catalina.out).

We're currently using Apache commons logging to obtain Log instances in our classes:

protected final Log logger = LogFactory.getLog(getClass());

I prefer to keep use LogFactory to access my customized logger (hence not creating a dependency on a specific logging package). Yet, I need to create my own handler (so that I route usage events to a separate file. e.g. usage.out), also need a custom formatter to format the logs. I wonder what is the best way to achieve this? What is the common practice?

A: 

You can use Simple Logging Facade for Java [1] with native implementation - Logback [2]. Then You can store logs in files or/and in database. Logback has also support for Tomcat [3]

Michał Mech
Thanks for the links... I'll start reading the documentations. The thing is that what I am trying to do sounds like a very common task (logging different stuff to different logs files) which I should be able to achieve using a customized logger. So I thought there should be a more native solution, or a common design pattern I can follow...
shane
From one side this is very common task and from the other side this is very simple task. That's why there is no many solutions.SLF4J is facade so You don't have to use specific implementation.One of the most common solution is Log4j with is implementing SLF4J too.
Michał Mech