You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Christoph Reck <Ch...@dlr.de> on 2001/11/15 10:02:03 UTC

Contribution: StderrLogSystem

Hi,

for anyone interested, I've created a simple StderrLogSystem as a 
drop-in for Velocity - see attachment. Either it can be taken into
the velocity contribution section, or put into velocity as the
standard logger, or you can change the package name to whatever
you want and include it in your ditsribution.

The reason for this is that I do not want stray files created
(velocity.log) in my file system when running my Anakia commandline
tool.

I use it as follows:

within main()
    // The classname of the default logger to be used
    String loggerClass =
      "de.dlr.dfd.dims.tools.xmlTransformer.StderrLogSystem";

    Vector vargs = new Vector();
    for( int i = 0; i < args.length; ++i )
    {
      if( args[i].equals("-quiet") )
        loggerClass = "org.apache.velocity.runtime.log.NullLogSystem";
      else if( args[i].equals("-verbose") )
        loggerClass = "de.dlr.dfd.dims.tools.xmlTransformer.StderrLogSystem";
      else
        vargs.add( args[i] );
    }

and for the ve.init():
    templatePath = new File(templatePath).getCanonicalPath();
    velocity = new VelocityEngine();
    velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templatePath);
    velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, loggerClass);
    velocity.init();
NOTE: templatePath is "." for my current XmlTransformer batch tool.

This is within a commandline (batchable) tool to do XML-Transformations
using Anakia (takes XML and VSL files als parameters and outputs anything 
the VSL creates). I can submit this code if anyone is interested.
It is a streamlined version extracted out of the AnakiaTask.

:) Christoph

Re: Contribution: StderrLogSystem

Posted by Christoph Reck <Ch...@dlr.de>.
"Geir Magnusson Jr." wrote:
> 
> Can you resend the code with an appropriate license at the top?  Thanks.

Here it is (placed properly into package org.apache.velocity.runtime.log).

Along goes the BatchTransformer tool that uses this and Anakia. It will
need a standalone startup script that invokes it with the correct jar files:

setenv CLASSPATH jakarta-velocity.jar:jakarta-commons-collections.jar
setenv CLASSPATH $CLASSPATH:werken-xpath.jar:antlr-runtime.jar
setenv CLASSPATH $CLASSPATH:jdom.jar:xerces.jar
java -mx128000000 -CLASSPATH $CLASSPATH de.dlr.dfd.dims.tools.xmlTransformer.XmlTransformer $*


:) Christoph

Re: Contribution: StderrLogSystem

Posted by "Geir Magnusson Jr." <ge...@yahoo.com>.
Can you resend the code with an appropriate license at the top?  Thanks.

On 11/15/01 4:02 AM, "Christoph Reck" <Ch...@dlr.de> wrote:

> Hi,
> 
> for anyone interested, I've created a simple StderrLogSystem as a
> drop-in for Velocity - see attachment. Either it can be taken into
> the velocity contribution section, or put into velocity as the
> standard logger, or you can change the package name to whatever
> you want and include it in your ditsribution.
> 
> The reason for this is that I do not want stray files created
> (velocity.log) in my file system when running my Anakia commandline
> tool.
> 
> I use it as follows:
> 
> within main()
>   // The classname of the default logger to be used
>   String loggerClass =
>     "de.dlr.dfd.dims.tools.xmlTransformer.StderrLogSystem";
> 
>   Vector vargs = new Vector();
>   for( int i = 0; i < args.length; ++i )
>   {
>     if( args[i].equals("-quiet") )
>       loggerClass = "org.apache.velocity.runtime.log.NullLogSystem";
>     else if( args[i].equals("-verbose") )
>       loggerClass = "de.dlr.dfd.dims.tools.xmlTransformer.StderrLogSystem";
>     else
>       vargs.add( args[i] );
>   }
> 
> and for the ve.init():
>   templatePath = new File(templatePath).getCanonicalPath();
>   velocity = new VelocityEngine();
>   velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
> templatePath);
>   velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
> loggerClass);
>   velocity.init();
> NOTE: templatePath is "." for my current XmlTransformer batch tool.

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Contribution: StderrLogSystem

Posted by "Geir Magnusson Jr." <ge...@yahoo.com>.
On 11/15/01 4:02 AM, "Christoph Reck" <Ch...@dlr.de> wrote:

> Hi,
> 
> for anyone interested, I've created a simple StderrLogSystem as a
> drop-in for Velocity - see attachment. Either it can be taken into
> the velocity contribution section, or put into velocity as the
> standard logger, or you can change the package name to whatever
> you want and include it in your ditsribution.
> 
> The reason for this is that I do not want stray files created
> (velocity.log) in my file system when running my Anakia commandline
> tool.
> 
> I use it as follows:
> 
> within main()
>   // The classname of the default logger to be used
>   String loggerClass =
>     "de.dlr.dfd.dims.tools.xmlTransformer.StderrLogSystem";
> 
>   Vector vargs = new Vector();
>   for( int i = 0; i < args.length; ++i )
>   {
>     if( args[i].equals("-quiet") )
>       loggerClass = "org.apache.velocity.runtime.log.NullLogSystem";
>     else if( args[i].equals("-verbose") )
>       loggerClass = "de.dlr.dfd.dims.tools.xmlTransformer.StderrLogSystem";
>     else
>       vargs.add( args[i] );
>   }
> 
> and for the ve.init():
>   templatePath = new File(templatePath).getCanonicalPath();
>   velocity = new VelocityEngine();
>   velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
> templatePath);
>   velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
> loggerClass);
>   velocity.init();
> NOTE: templatePath is "." for my current XmlTransformer batch tool.
> 
> This is within a commandline (batchable) tool to do XML-Transformations
> using Anakia (takes XML and VSL files als parameters and outputs anything
> the VSL creates). I can submit this code if anyone is interested.
> It is a streamlined version extracted out of the AnakiaTask.
> 
> :) Christoph
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

Send it along.  We'll dump in the contrib section immediately...

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>