logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jorge Medina" <jmed...@e-dialog.com>
Subject RE: Orthogonal logging configuration
Date Tue, 20 Jan 2009 23:15:34 GMT
For Option (2) I just realized I would have override LogManager, since
all calls to get a Logger from the Logger class calls methods on

Any other ideas are welcome. Thank you.


-----Original Message-----
From: Jorge Medina [mailto:jmedina@e-dialog.com] 
Sent: Tuesday, January 20, 2009 6:07 PM
To: log4j-user@logging.apache.org
Subject: Orthogonal logging configuration

   I have a web services application that can be used by a few clients
(each client may have several users, but this is not relevant. By client
I mean a customer organization, not a client of a client-server system)
a)   I would like to have separate log files, one per each client.  Of
course, there may be sections of code that are executed before I know
what client is making the request, the log statements on those sections
of code would go to the global file. 
b)  I would also like to be able to change the log level per package per
client. For example, I want to log at DEBUG level for all requests
coming from client X but only at INFO level for client Y for a given
package "com.example.mypackage". 
In other words, package and client would be my orthogonal axis.
   I was wondering if someone may already have this problem and have a
   Here is what I have been thinking on doing:
Option 1)
    Change all Logger.getLogger("x.y.z") for
Logger.getLogger("clientID.x.y.z") in my code.
        Easy to achieve (a) and (b)
        It would only work for my own code, but not for logging produced
by third party libraries. (Vgr. Spring, Hibernate, etc). I would really
like to log all relevant information into the same log file for a given
client. When a request is made, as soon as I know the client, I want all
logging of that transaction (my own code, spring, hibernate, other
libraries) to go to the appropiate appender.
Option 2)
     Write my own Logger class, overriding the the Log4j class. The
Logger.getLogger("x") method will return the logger "clientID.x" if an
InheritableThreadLocal variable is available with the clientID,
otherwise it returns logger  "x".
            It will work for my own code and third party code.
            Little more complex to implement.
  I was wondering if anybody have had a similar requirement. Any ideas
are welcome.

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message