tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jerry Malcolm <2ndgenfi...@gmail.com>
Subject Re: Logging - including host name in log file?
Date Fri, 02 Dec 2011 17:46:27 GMT
Ok, I'm digging into this.  Slowly but surely.... Just to confirm...

So if I have, say 2 hosts, each with 3 web apps, and I want a different log
file for each web app on each host, I need to define 6 of the following:

10host1webapp1.org.apache.juli.FileHandler.level = FINE
10host1webapp1.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
10host1webapp1.org.apache.juli.FileHandler.prefix = Host1App1.

.... through

15host2webapp3.org.apache.juli.FileHandler.level = FINE
15host2webapp3.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
15host2webapp3.org.apache.juli.FileHandler.prefix = Host2App3.

And then define 6 of the following:

org.apache.catalina.core.ContainerBase.[Catalina].[host1].[/webapp1].level
= INFO
org.apache.catalina.core.ContainerBase.[Catalina].[host1].[/webapp1].handlers
= 10host1webapp1.org.apache.juli.FileHandler

...through

org.apache.catalina.core.ContainerBase.[Catalina].[host2].[/webapp3].level
= INFO
org.apache.catalina.core.ContainerBase.[Catalina].[host2].[/webapp3].handlers
= 15host2webapp3.org.apache.juli.FileHandler

and I put all of this in /conf/logging.properties

All of this is required in order to get separate log files per webapp per
host, right?

Thanks.

Jerry

On Thu, Dec 1, 2011 at 8:50 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> 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 logging.properties 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
> = 3manager.org.apache.juli.FileHandler
>
> 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="www.awesomehost.com">
>    <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].[www.awesomehost.com
> ].[/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/logging.properties 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
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk7YPN4ACgkQ9CaO5/Lv0PA0ZgCgq2ckmo/fw88FbeV0UhOVuYTm
> 7uwAn1D/sE+YHVw3juxVWFVZTdMMey6T
> =0R0X
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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