[prev in list] [next in list] [prev in thread] [next in thread] 

List:       velocity-dev
Subject:    Re: Velocity ImportTool Question
From:       "Nathan Bubna" <nbubna () gmail ! com>
Date:       2006-12-14 22:24:32
Message-ID: 4d651da50612141424r2d822f76kb75933b66943f974 () mail ! gmail ! com
[Download RAW message or body]

On 12/14/06, Claude Brisson <claude@renegat.net> wrote:
> (really moving it to the dev list...)
>
> > Yeah, ever since Tomcat 5.5 made the obnoxious decision to use
> > commons-logging (which i could have sworn was supposed to be just a
> > log wrapper/adapter) as a full-on logging solution responsible for
> > generating servlet log files and printing to them, our former method
> > of handling things (pointing all commons-logging messages to
> > Velocity's LogSystem and pointing Velocity's LogSystem at the provided
> > servlet log) fails with an infinite loop.
>
> Yes, I remember that.
>
> > It's been a while since i was fully familiar with the nuances of this
> > issue, but i believe things are currently as follows:
> >
> > Velocity's LogSystem is being pointed at the servlet log, and all
> > VelocityTools messages are being sent to commons-logging.  If you are
> > using Tomcat 5.5.x, then this works fine as the VelocityTools and
> > Velocity methods both end up in the servlet log.   If you are using an
> > older Tomcat or a different servlet container, then you will not get
> > VelocityTools messages in your servlet log without actively
> > configuring commons-logging to print to Velocity's LogSystem (see the
> > LogSystemCommonsLog class for details).
> >
> > Once Velocity 1.5 is released, it is my intent to push forward with
> > work on VelocityTools 2.x and leave the VelocityTools 1.x series
> > behind.  VelocityTools 2.x will require Velocity 1.5+ as a dependency
> > (among other major changes).  Among the benefits of this will be the
> > ability to drop commons-logging from VelocityTools and use the new and
> > improved LogChute support in Velocity 1.5+.   This will once more
> > allow us to funnel all Velocity and VelocityTools messages to the same
> > place, regardless of which servlet container you are using.
>
> Yes, but my concern was that ToolboxManagers and logging tools directly
> uses import org.apache.commons.logging.Log via
> LogFactory.getLog(ServletToolboxManager.class) and not via
> LogSystemCommonsLog.

No, the way we are using commons-logging is the appropriate way.  The
whole idea of it is/was that you use the LogFactory and Log interfaces
so that you can easily swap out implementations of Log (like the
LogSystemCommonsLog).  You are not supposed to use the implementations
directly.  If you do, then you might as well do what i plan to do in
2.x and ditch commons-logging altogether.

> So without Tomcat 5.5.x and any proper commons-loggin configuration,
> you'll see the VVS logs allright (letting you think that tools logging
> is ok) but no error message from the servlet toolbox manager.

No, what you are seeing in such a case is just *Velocity* log
messages.  The VelocityViewServlet does precious little logging of its
own, pretty much only in cases of major initialization errors.  Of
course, it does log directly to the servlet log.  This is because in
such cases it may be that Velocity failed to init and we can't log
there.

> I'm not enough familiar with this problem and with commons-logging to
> know which solution would be best :
>  - implement a LogFactory ?
>  - create setLog(Log) methods (introspected for tools the same way as
> "init" and "configure") ?

No, this is not the way to use commons-logging.  Here are the options:

a) Improve documentation to make it clear that those not using Tomcat
5.5+ must add a commons-logging.properties file to the root of the
classpath that contains the following line:

org.apache.commons.logging.Log=org.apache.velocity.tools.log.LogSystemCommonsLog

or b) by default, point all commons-logging messages to
LogSystemCommonsLog (as i believe we used to do), but stop having
Velocity's LogSystem use the ServletLogger by default.  this will mean
that all log output for Velocity and VelocityTools will follow
Velocity's default logging configuration (unless users change that via
velocity.properties).

> but I definitely think we should do sthing about this for the 1.3
> release.

The options above are our only options for improving the situation in 1.3.

>
>   Claude
>
>
> > In short, the Tomcat people did what Geir could not and successfully
> > convinced me that it is a very bad idea to use commons-logging in a
> > webapp framework.
> >
> > >   Claude
> > >
> > > Le jeudi 14 décembre 2006 à 12:30 -0800, Nathan Bubna a écrit :
> > > > On 12/14/06, Tod Thomas <tthomas@chubb.com> wrote:
> > > > > Nathan Bubna wrote:
> > > > > > and what does your web.xml have?
> > > > >
> > > > > Sorry, plain vanilla:
> > > > >
> > > > >    <!-- Define Velocity template compiler -->
> > > > >    <servlet>
> > > > >     <servlet-name>velocity</servlet-name>
> > > > >     <servlet-class>
> > > > >       org.apache.velocity.tools.view.servlet.VelocityViewServlet
> > > > >     </servlet-class>
> > > > >
> > > > >     <init-param>
> > > > >       <param-name>org.apache.velocity.toolbox</param-name>
> > > > >       <param-value>/WEB-INF/toolbox.xml</param-value>
> > > > >     </init-param>
> > > > >
> > > > >     <init-param>
> > > > >       <param-name>org.apache.velocity.properties</param-name>
> > > > >       <param-value>/WEB-INF/velocity.properties</param-value>
> > > > >     </init-param>
> > > > >
> > > > >     <load-on-startup>10</load-on-startup>
> > > > >    </servlet>
> > > > >
> > > > >    <!-- Map *.vm files to Velocity -->
> > > > >    <servlet-mapping>
> > > > >     <servlet-name>velocity</servlet-name>
> > > > >     <url-pattern>*.vm</url-pattern>
> > > > >    </servlet-mapping>
> > > > >
> > > > >    <!-- Define Velocity template compiler -->
> > > >
> > > > Looks fine.
> > > >
> > > > > I've gotten a little further along.  A number of apache.commons jar
> > > > > files were missing.  Once I copied them over I could see the "Toolbox
> > > > > setup complete" message in the catalina.log.
> > > >
> > > > yeah, having all the dependencies is rather important.  if you aren't
> > > > sure what dependencies you need, unpack the simple.war found in the
> > > > velocity distribution and make sure you've got all the ones in the
> > > > WEB-INF/lib folder in that war.
> > > >
> > > > some lines before the "Toolbox setup complete" message, there should
> > > > have been a message saying "Using config file '<some file path>'"
> > > > What is the file used?
> > > >
> > > > > Still not getting anything to render using "$import.class.name" or
> > > > > $import.read("url") though.
> > > >
> > > > This still makes me doubt that the intended toolbox file is the one
> > > > being loaded.  Try introducing some bad xml into you toolbox.xml and
> > > > see if the application chokes and complains on startup.
> > > >
> > > > >
> > > > > Thanks for all of your help.
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > > > For additional commands, e-mail: user-help@velocity.apache.org
> > > > >
> > > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > > For additional commands, e-mail: user-help@velocity.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > For additional commands, e-mail: user-help@velocity.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic