you could probably look at the java.util.logging.Logger class it has a getLogger(String name) method which might be of use for your purposes.
Joined: Jul 28, 2002
No it won't. I want to get the logger from a servlet container. I'm thinking there must be something in the spec that says it's available through the API, right? It'd be dumb (in my opinion) not to make it available somewhere. i mean, put security on it if you want, but have an interface to get it.
Why would I, as a servlet container developer, want to give you, some programmer that I don't know from Adam, access to my logging object? You might do something to it that disables it. A logger logs. What else do you need it to do? I give you everything you need. You don't need direct access to the object. Principle of 'least privelege' and 'don't touch that you might break it!'.
But that's me as a servlet container programmer.
Me as a programmer also wonders: What do you need it for ? I'm just curious.
As for the spec, I've searched through the Servlet 2.3 spec and nowhere does it mention that a servlet container need give access to the logger, only that it provide a logging service.
If I anticipate correctly, and you are wanting to do some funky logging type things on conditions or certain events (change where the logger logs to if condition 'a' is met, etc...) then while searching through the spec I had a couple good hints... use Filters and/or Context lifecycle listeners. (SRV 6.1.1 and SRV 10.4, respectively)
And finally, if the built-in logger is just not going to do it for you... that's what log4j was made for.
Joined: Jul 28, 2002
I'm writing a DataSource implementation (it is a connection pool manager that works with a ConnectionPoolDataSource "a la" JDBC 2.0 Optional Extension Spec). I was hoping there would be an easy way for people to direct my DataSource to log to the servlet container's logger. However, if you're right, I have no idea how I'll do that. But it seems there must be a way because otherwise, everyone's going to have a different log file for every component plugged in to the container - ugh.