tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jerry Malcolm <>
Subject Re: Logging - including host name in log file?
Date Fri, 02 Dec 2011 04:34:00 GMT
Thanks so much, Chris.  Yes, I did see those lines in the properties file.
But it didn't have a lot of explanation.  Thanks for the clarification.

Where should the properties file be located?  All of the docs say it should
be in /common/classes.  But in my install, it's in /conf.

At the risk of opening another bag of worms.... in your example, you said:
(But, of course, you don't have that because you shouldn't put <Context>s
in server.xml, but I have it here for the sake of brevity).  Ok, I DO have
context statements in my server.xml. I'm obviously not following best
practices.... but it's worked fine for years. Can you point me to
documentation that explains the negatives of doing it the way I'm doing it
vs. the best practices way, and what the best practices way to do that is?

Thanks again.


On Thu, Dec 1, 2011 at 8:50 PM, Christopher Schultz <> wrote:

> Hash: SHA1
> Jerry,
> On 12/1/11 9:21 PM, Jerry Malcolm wrote:
> > I'm trying to get my hands around the whole tomcat logging system.
> > I've read the docs, wikis, samples, etc.  But I still struggling a
> > bit.  I've been just using System.out.println for years, and it's
> > getting totally out of control.  So time to learn tomcat logging.
> Yup. System.out is insanely inflexible.
> > Basically, I host quite a few domains.  I'd like to separate the
> > log files per host (and possibly further subdivide by webapps).  I
> > can't find any way to specify the host as part of the logger file
> > handler directory.  This may be something intuitively obvious.  But
> > I haven't found it yet.
> Which logging system are you using? Tomcat's default is to use JULI
> which connects commons-logging up to the java.util.logging (or J-U-L
> Interface, hence "JULI").
> At any rate, the standard file should have examples
> that make this work. For instance, I can see the following in mine:
> org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level
> = INFO
> org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers
> =
> All that mess configures a logger that captures the logs for the
> "manager" <Context> that is deployed into the "localhost" <Host> under
> the "Catalina" <Service>.
> You can easily create one of these for each of your webapps (or even
> just per host) in the same way: just use the proper Service, Host, and
> context path (contexts don't have names, so you use the context path
> instead -- the above for an example).
> So, let's say that you have:
> <Service name="Catalina">
>  <Host name="">
>    <Context path="/sweetwebapp" docBase="..." ... />
>  </Host>
> </Service>
> (But, of course, you don't have that because you shouldn't put
> <Context>s in server.xml, but I have it here for the sake of brevity).
> Anyhow, you can configure a logger for that context like this:
> org.apache.catalina.core.ContainerBase.[Catalina].[
> ].[/sweetwebapp].level=INFO
> (plus the other configuration you'll need like which file to use, etc.)
> > If it can't be configured statically to plug the host name into the
> > log file name with a variable or something like ${catalina_home},
> > alternatively is there a way to change the file name on the fly
> > after getting an instance of the java.utils.logging.Logger class?
> If you are using Tomcat's internal logging (which is done by calling
> ServletContext.log(...)) then you should use lib/ as
> described above.
> If you are using java.util.logging directly in your own webapp, then
> you are on your own :(
> If you are using AccessLogValve, well then you just need to use "%v"
> to get the name of the local server -- but that's for the actual log
> data, not for the filename.
> - -chris
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools -
> Comment: Using GnuPG with Mozilla -
> iEYEARECAAYFAk7YPN4ACgkQ9CaO5/Lv0PA0ZgCgq2ckmo/fw88FbeV0UhOVuYTm
> 7uwAn1D/sE+YHVw3juxVWFVZTdMMey6T
> =0R0X
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message