Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

RE: Retrieving the context path from a standalone class

Jacob Kjome

2004-01-08

Replies:

Quoting "Shapira, Yoav" <Yoav.Shapira@(protected)>:

>
> Howdy,
>
> >One way is by taking advantage of Tomcat's naming conventions with the
> >tempdir....
> >
> >      String tempdir =
> >       "" + context.getAttribute("javax.servlet.context.tempdir");
> >      int lastSlash = tempdir.lastIndexOf(File.separator);
> >
> >      if ((tempdir.length() - 1) > lastSlash) {
> >       logHomePropName = tempdir.substring(lastSlash + 1) +
> >".log.home";
> >      }
>
> Very tomcat-specific and subject to change ;)

Yep, that's why I don't use that anymore and use the second approach.

But the 2nd approach is
> much better, as I mentioned using ServletContext#getResource is a good
> way to go. As I was reading the code, I could swear I'd seen it before,
> and then I realized it's a paste from the log4j repository selector you
> wrote ;)

Yes, with your help :-)

(BTW how come we haven't moved it from log4j-sandbox to log4j
> for 1.3 yet?)
>

Not sure, but we will probably want to update it to work with Ceki's new
configuration mechanism which is to replace the DOMConfigurator (what was it
called again?) and also use the new watchdogs instead of configureAndWatch()
(which is only used in cases where it is configured to be used *and* we detect
that we have file system access to the configured [proposed] location of the
log file). However, I am unfamiliar with how these work, so any help on this
effort would be appreciated.

For my purposes, I use a jar built off the unofficial 0.2 tagged version of the
log4j-sandbox CVS code. BTW, ContextJNDISelector has been moved to Log4j
already. I think we should also move the other optional appenders as well as
the configuration stuff as they have been very useful (to me, at least). I'd
like to hear the opinions of some of the other developers on this before an
alpha release of log4j-1.3.

Jake

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)



©2008 junlu.com - Jax Systems, LLC, U.S.A.