On Thu, Jun 19, 2008 at 12:41:30AM +0200, André Warnier wrote: > My idea was, maybe naively, that Tomcat was like any other program, fairly > logical, and that things in it happen for a reason. > Thus that when Tomcat starts, it knows, from some top-level configuration > file, where to look for instructions as to what logging system to use, and > has an idea about where the configuration for that stuff is. > And that this knowledge could be communicated to me somehow without > breaking some official secrecy vow. > > What really puzzled me however, was that going down the hierarchy of > configuration files and directories, I never seemed to find a link between > Tomcat and the logging it was doing.
What you are missing is that Tomcat is not the top of the chain of userspace software here; the Java Runtime Environment is. The JRE loads Tomcat and quite a bit of other stuff as well. That "other stuff" is available to Tomcat. A sufficiently new Tomcat version includes Commons Logging (JCL), which is a generalized interface to logging functions which depends on some other package to actually do the logging. Commons Logging has its own internal rules for figuring out what it is supposed to do, and it can get information from the JRE to help in that process. This information does not pass through Tomcat; Commons Logging asks the JRE directly for the values of various "system properties", which values are assigned on the commandline which starts the JRE and directs it to load Tomcat. The actual logging package wrapped by Commons Logging (such as JULI or Log4j) in turn has its own rules to locate its configuration data, and again some of those rules depend on information that it may be able to get from the JRE, again without Tomcat's intervention. So Tomcat, Commons Logging, and e.g. JULI each have their own configuration and none really knows about any of the others. The JRE knits it all together. So, to understand the behavior of logging in Tomcat, you don't need to know much at all about Tomcat, but you do need to understand the actual logger, Commons Logging, and some aspects of the JRE. What you *may* need to know about Tomcat is how it rearranges class loading, because if one of these packages is not told where to find its configuration then some of its built-in rules will search for a configuration file using the classloader hierarchy. > I am starting to see the error of my ways. > What I am, ever so slowly, starting to think I understand (I hope), is that > Tomcat /may/ not itself know; that your refusal to tell me may not after > all have been motivated by a desire to keep the knowledge into your inner > circle of initiates; but that instead, it is some other piece of software > that "hooks" into Tomcat to "steal" the things to be logged, and that this > other piece of thing is the (only) one that knows it's own configuration. Close. The JRE mediates. Tomcat asks for an instance of JCL and the JRE creates one, which (while being created) will have groped around and found a logging package to wrap. The loggin package instance will have groped around and found a configuration which tells it how to log stuff. Tomcat doesn't know or need to know what JCL is using to emit log records; JCL knows that. In turn JCL doesn't know or need to know what the selected logging package is supposed to do; the logger knows. Each component uses the JRE to find the stuff it wants to know. > And thus that for instance Tomcat itself knows nothing about that file > /var/lib/tomcat5.5/conf/logging.properties Correct. It's only there rather than somewhere else because a default search for a properties file will look there, given the classloading setup established by Tomcat. > which I discovered long ago on my Linux Debian Etch system, but could not > figure out how Tomcat found it or used it. Tomcat doesn't find or use it. The logging package does that. -- Mark H. Wood, Lead System Programmer [EMAIL PROTECTED] Typically when a software vendor says that a product is "intuitive" he means the exact opposite.
pgpInunMsNEg7.pgp
Description: PGP signature