Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 752207293 for ; Wed, 23 Nov 2011 16:12:36 +0000 (UTC) Received: (qmail 70710 invoked by uid 500); 23 Nov 2011 16:12:33 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 70641 invoked by uid 500); 23 Nov 2011 16:12:33 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 70632 invoked by uid 99); 23 Nov 2011 16:12:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Nov 2011 16:12:33 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [76.96.59.228] (HELO qmta15.westchester.pa.mail.comcast.net) (76.96.59.228) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Nov 2011 16:12:25 +0000 Received: from omta04.westchester.pa.mail.comcast.net ([76.96.62.35]) by qmta15.westchester.pa.mail.comcast.net with comcast id 0f6d1i0040ldTLk5FgC59Z; Wed, 23 Nov 2011 16:12:05 +0000 Received: from Christophers-MacBook-Pro.local ([69.143.109.145]) by omta04.westchester.pa.mail.comcast.net with comcast id 0gC41i00f38FjT13QgC4t6; Wed, 23 Nov 2011 16:12:05 +0000 Message-ID: <4ECD1B53.5070406@christopherschultz.net> Date: Wed, 23 Nov 2011 11:12:03 -0500 From: Christopher Schultz User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Single war file - multiple hosts - can't get log4j to log to different files References: <4ECBFBF2.2030702@pidster.com> <4ECC25C8.1070501@christopherschultz.net> In-Reply-To: X-Enigmail-Version: 1.3.3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Chris, On 11/23/11 8:06 AM, chris derham wrote: >>> We thought this would allow us to monitor all contexts with a >>> single probe install, but it only seems to show a single >>> localhost context. I assume that the hosts are separated, and >>> that the context="priviliged" setting can allow a web app to >>> access other webapps in the same context, but not across >>> hosts. >> >> So... what setting is that? >> > I meant the crossContext="true" setting. I have searched around, > and can see that both tomcat's manager and probe are not able to > monitor virtual hosts other than the one that they reside in. So I > will just have to deploy manager and/or probe for each virtual > host. I just wanted to see everything in a single place - from what > I have read this can't be done If you are lazy/memory conscious/can tolerate the setup, you could put all webapps under a single virtual host (the default, most likely) with aliases (if you even require them) and that would solve the management problem. >> 1. Move your .war files from out of the webapps directory (and >> subdirs) 2. Update the paths in ROOT.xml and probe.xml to point >> to the new location 3. Remove the "local" and "demos" >> directories >> > Thanks for the pointer. What I ended up doing was moving all wars > to /notWebapps. Then I unpacked them, and set the > relevant context.xml's docbase to point to the exploded directory. > Seems to work well now Seems like a reasonable course of action. "notWebapps". I like that. :) >>> The only idea I have left if nobody can see an obvious flaw in >>> our logic is to write some custom code to initialise log4j. We >>> would just need to pick up the context, or a jndi variable and >>> then prefix the log file name with this. Guess it can't be that >>> hard - just figured that somebody would have hit this before. >> >> I think that's your best bet. >> > Yes it was surprisingly easy. We created a subclass of springs > Log4jConfigListener, and then prefix the file parameter of any > file appenders. We set the web.xml value to blank, which is > ignored, and then when required we can override it in context.xml. > Thanks for the pointer You might want to put a comment in the web.xml where you have no value explaining where the value is *really* located. You'll save some sysasmin several hours of screaming in the future. >> I'm not sure that using JMX is going to make your life any >> easier. > > I thought that via some internal to tomcat mechanism, I would be > able to detect which context I was in, and thus be able to use that > to drive the prefix for the log file, rather than having to have a > specific web.xml setting that each context overrides. You should be able to detect the context name during startup. Actually, you can get the path from ServletContext.getContextPath. So, if you have a ServletContextListener, you can do this: event.getServletContext().getContextPath() Of course, that gets you a string that you might need to massage (like changing "" into "ROOT", removing slashes, etc.). - -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/ iEYEARECAAYFAk7NG1MACgkQ9CaO5/Lv0PCLdwCfQMZWqd0wDtwTXxiZgYyqtPTE lowAn1tZMiEh1Qb4/NRpMeqKwXK18Glo =wsFf -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org