You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by John Rodriguez <jr...@columbia.edu> on 2005/01/10 14:55:11 UTC

setting up velocity to log to servlet log

Right now, Tomcat is set up to log to
${TOMCAT_HOME}/logs/localhost_log.yyyy-mm-dd.txt (yyyy-mm-dd being the
current date, of course).
I tire of Velocity using the AvalonLogSystem and logging to my app tree,
instead I wish to point it to the servlet logs (at least for this
particular app).
 
I read the manual and several docs online but I don't seem to be setting
it up correctly.  One way I figure this is the case, is that none of the
info messages I used to get in the WEB-INF/logs/velocity.log appear now,
e.g.
 
Resource Loader Instantiated:
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
 
I set up my velocity.properties as follows:
runtime.log.logsystem.class =
org.apache.velocity.runtime.log.SimpleLog4JLogSystem
runtime.log = blah.log #from my understanding, not needed, but just
renamed as check to make sure
 
This is all I do, and I reload the webapp in Tomcat and nothing happens.
 
I have seen configurations where the webapp creates logger objects at
runtime but I'd like to configure this outside of the code (via config
files or env vars) if possible.
 
All I want is to see something similar to the following in my
localhost_log.yyyy-mm-dd.txt (I'll worry about date formatting, etc.
later)
 
.
2005-01-10 00:05:44 StandardContext[/jrod/myproject]: Reloading this
Context is completed    #tomcat logs
Thu Jan 06 17:37:03 EST 2005   [info] Resource Loader Instantiated:
org.apache.velocity.runtime.resource.loader.FileResourceLoader
#velocity logs
.
 
Any ideas for this noob? :-)
 
Respectfully,
-John

Re: setting up velocity to log to servlet log

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi John,

> Thanks for your quick response, Shinobu.

No problem.  I was still awake.  :)

> While this appears to be a great model to use and explore for my future
> projects, my deadline prevents me from investing time to familiarize
> myself with alternatives at this time.
> 
> Any suggestions on how to fix this, using what is already in place?

Let's see.  You're right about log4j not being in the dep jar.  Have
you tried putting the log4j jar in your classpath?

One more thing.  Assuming you are using VelocityServlet, it uses the
singleton model, causing all Velocity to have the same configuration.
    http://jakarta.apache.org/velocity/developer-guide.html#Singleton

Best regards,
-- Shinobu

--
Shinobu "Kawai" Yoshida <sh...@gmail.com>

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


RE: setting up velocity to log to servlet log

Posted by John Rodriguez <jr...@columbia.edu>.
Thanks for your quick response, Shinobu.

While this appears to be a great model to use and explore for my future
projects, my deadline prevents me from investing time to familiarize
myself with alternatives at this time.

Any suggestions on how to fix this, using what is already in place?

Respectfully,
-John

-----Original Message-----
From: Shinobu Kawai [mailto:shinobu.kawai@gmail.com] 
Sent: Monday, January 10, 2005 10:00 AM
To: Velocity Users List
Subject: Re: setting up velocity to log to servlet log

Hi John,

> Right now, Tomcat is set up to log to
> ${TOMCAT_HOME}/logs/localhost_log.yyyy-mm-dd.txt (yyyy-mm-dd being the
> current date, of course).
> I tire of Velocity using the AvalonLogSystem and logging to my app
tree,
> instead I wish to point it to the servlet logs (at least for this
> particular app).

## snip

> Any ideas for this noob? :-)

I recommend using VelocityViewServlet, which by default uses
ServletLogger, which logs using ServletContext#log().
  http://jakarta.apache.org/velocity/tools/view/
 
http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/too
ls/view/servlet/ServletLogger.html


Best regards,
-- Shinobu

--
Shinobu "Kawai" Yoshida <sh...@gmail.com>

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


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


Re: setting up velocity to log to servlet log

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi John,

> Right now, Tomcat is set up to log to
> ${TOMCAT_HOME}/logs/localhost_log.yyyy-mm-dd.txt (yyyy-mm-dd being the
> current date, of course).
> I tire of Velocity using the AvalonLogSystem and logging to my app tree,
> instead I wish to point it to the servlet logs (at least for this
> particular app).

## snip

> Any ideas for this noob? :-)

I recommend using VelocityViewServlet, which by default uses
ServletLogger, which logs using ServletContext#log().
  http://jakarta.apache.org/velocity/tools/view/
  http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/servlet/ServletLogger.html


Best regards,
-- Shinobu

--
Shinobu "Kawai" Yoshida <sh...@gmail.com>

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


RE: setting up velocity to log to servlet log

Posted by John Rodriguez <jr...@columbia.edu>.
Another pecularity is that a 'blah.log' appears in another webapp
hierarchy, using AvalonLogSystem even though I commented it out in the
velocity.properties file?

By now, I'm assuming that Log4j is not built into velocity-dep.jar and
so when it's looked for, it fails, and attempts to save face by
including AvalonLogSystem rather than complain to the user (possibly too
user-friendly since it may be a pain for sysadmins to debug?).  But why
what setting could cause it to log messages for one project into
another's file hierarchy?

Slightly befuddled,
-John

-----Original Message-----
From: John Rodriguez [mailto:jr534@columbia.edu] 
Sent: Monday, January 10, 2005 8:55 AM
To: 'Velocity Users List'
Subject: setting up velocity to log to servlet log

Right now, Tomcat is set up to log to
${TOMCAT_HOME}/logs/localhost_log.yyyy-mm-dd.txt (yyyy-mm-dd being the
current date, of course).
I tire of Velocity using the AvalonLogSystem and logging to my app tree,
instead I wish to point it to the servlet logs (at least for this
particular app).
 
I read the manual and several docs online but I don't seem to be setting
it up correctly.  One way I figure this is the case, is that none of the
info messages I used to get in the WEB-INF/logs/velocity.log appear now,
e.g.
 
Resource Loader Instantiated:
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
 
I set up my velocity.properties as follows:
runtime.log.logsystem.class =
org.apache.velocity.runtime.log.SimpleLog4JLogSystem
runtime.log = blah.log #from my understanding, not needed, but just
renamed as check to make sure
 
This is all I do, and I reload the webapp in Tomcat and nothing happens.
 
I have seen configurations where the webapp creates logger objects at
runtime but I'd like to configure this outside of the code (via config
files or env vars) if possible.
 
All I want is to see something similar to the following in my
localhost_log.yyyy-mm-dd.txt (I'll worry about date formatting, etc.
later)
 
.
2005-01-10 00:05:44 StandardContext[/jrod/myproject]: Reloading this
Context is completed    #tomcat logs
Thu Jan 06 17:37:03 EST 2005   [info] Resource Loader Instantiated:
org.apache.velocity.runtime.resource.loader.FileResourceLoader
#velocity logs
.
 
Any ideas for this noob? :-)
 
Respectfully,
-John


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