You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by kokoko <ko...@yahoo.com> on 2004/03/02 02:40:30 UTC

Custom Logger Problem

Hi all,
   I am using Log4j for logging in my application. I
want to redirect the logs
info of Velocity to my Logger. Acc. 2 the Velocity
userguide, I implemented
a class 'MyLogger' which extends LogSystem interface.
The logs are being redirected
to one single log file, but my "Velocity" files are
not being displayed. 
Commenting out the param "runtime.log.logsystem.class
in "Velocity.properties" 
file, I dont get the error and the .vm files are being
displayed.

I get the error: ActionServlet ERROR [init] Cannot
find template 'Server.vm'; 
nested exception is:
org.actionframework.TemplateException: Error while
loading 
template 'Server.vm'; nested exception is:
org.apache.velocity.exception.ResourceNotFoundException:

Unable to find resource 'Server.vm'
  ......
  
  
	My Logger class:
   static Logger logger =
Logger.getLogger(MyLogger.class);
   public MyLogger() {
     try {
          
Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM,
this );
           Velocity.init();
       }
       catch (Exception e) {
           logger.error(e);
       }
   }

    public void init( RuntimeServices rsvc ) {
    }

    public void logVelocityMessage(int level, String
message) {    	
    	logger.log(Level.toLevel(level), message);
    }
    
    
My Velocity.properties file consist of:
    file.resource.loader.path = web/vm/
    runtime.log = logs/squid.log
    runtime.log.logsystem.class =
rtimage.squid.MyLogger
    
Please give me any suggestions.    

__________________________________
Do you Yahoo!?
Get better spam protection with Yahoo! Mail.
http://antispam.yahoo.com/tools

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


Re: Custom Logger Problem

Posted by kokoko <ko...@yahoo.com>.
Thanks Simon. It worked.

-Sagar.


--- Geir Magnusson Jr <ge...@4quarters.com> wrote:
> 
> On Mar 2, 2004, at 10:32 AM, Barbara Baughman wrote:
> 
> > I've also noticed that Velocity's Log4J logger is
> of class
> > org.apache.log4j.Category, not class
> org.apache.log4j.Logger.
> > The Category class has been deprecated.  Is
> Velocity going to change
> > their Log4J logger to the recommended Logger
> class?
> 
> That's been fixed, and should be there in 1.5 (which
> I want to start 
> pushing to rc1).  I missed the 3/1 deadline for 1.4,
> so will upgrade 
> the license and foist that out there.
> 
> >
> > So my Log4J definition of the Velocity logger is:
> > log4j.category.VELOCITY=DEBUG, VEL
> >
> > instead of
> >
> > log4j.logger.VELOCITY=DEBUG, VEL
> >
> > All of my other Log4J logs use the logger
> definition.
> >
> > Barbara Baughman
> > X2157
> >
> > On Tue, 2 Mar 2004, Simon Christian wrote:
> >
> >> I haven't followed the same route as you've taken
> here, but there is 
> >> an
> >> easy way to have Velocity put it's log output
> through Log4j:
> >>
> >> Remove/comment out any existing lines starting
> with runtime.log.xxxx,
> >> and add the following lines:
> >>
> >> runtime.log.logsystem.class  =
> >> 
> org.apache.velocity.runtime.log.SimpleLog4JLogSystem
> >> runtime.log.logsystem.log4j.category =
> org.apache.velocity
> >>
> >> The category you can change to whatever is
> appropriate. Note the first
> >> line has split above - there should just be two
> lines.
> >>
> >> - simon
> >>
> >>
> >> kokoko wrote:
> >>> Hi all,
> >>>    I am using Log4j for logging in my
> application. I
> >>> want to redirect the logs
> >>> info of Velocity to my Logger. Acc. 2 the
> Velocity
> >>> userguide, I implemented
> >>> a class 'MyLogger' which extends LogSystem
> interface.
> >>> The logs are being redirected
> >>> to one single log file, but my "Velocity" files
> are
> >>> not being displayed.
> >>> Commenting out the param
> "runtime.log.logsystem.class
> >>> in "Velocity.properties"
> >>> file, I dont get the error and the .vm files are
> being
> >>> displayed.
> >>>
> >>> I get the error: ActionServlet ERROR [init]
> Cannot
> >>> find template 'Server.vm';
> >>> nested exception is:
> >>> org.actionframework.TemplateException: Error
> while
> >>> loading
> >>> template 'Server.vm'; nested exception is:
> >>>
>
org.apache.velocity.exception.ResourceNotFoundException:
> >>>
> >>> Unable to find resource 'Server.vm'
> >>>   ......
> >>>
> >>>
> >>> 	My Logger class:
> >>>    static Logger logger =
> >>> Logger.getLogger(MyLogger.class);
> >>>    public MyLogger() {
> >>>      try {
> >>>
> >>>
> Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM,
> >>> this );
> >>>            Velocity.init();
> >>>        }
> >>>        catch (Exception e) {
> >>>            logger.error(e);
> >>>        }
> >>>    }
> >>>
> >>>     public void init( RuntimeServices rsvc ) {
> >>>     }
> >>>
> >>>     public void logVelocityMessage(int level,
> String
> >>> message) {
> >>>     	logger.log(Level.toLevel(level), message);
> >>>     }
> >>>
> >>>
> >>> My Velocity.properties file consist of:
> >>>     file.resource.loader.path = web/vm/
> >>>     runtime.log = logs/squid.log
> >>>     runtime.log.logsystem.class =
> >>> rtimage.squid.MyLogger
> >>>
> >>> Please give me any suggestions.
> >>>
> >>> __________________________________
> >>> Do you Yahoo!?
> >>> Get better spam protection with Yahoo! Mail.
> >>> http://antispam.yahoo.com/tools
> >>>
> >>>
>
---------------------------------------------------------------------
> >>> 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
> >>
> >>
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> velocity-user-help@jakarta.apache.org
> >
> >
> -- 
> Geir Magnusson Jr                                  
> 203-247-1713(m)
> geir@4quarters.com
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> velocity-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you�re looking for faster
http://search.yahoo.com

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


Re: Custom Logger Problem

Posted by Geir Magnusson Jr <ge...@4quarters.com>.
On Mar 2, 2004, at 10:32 AM, Barbara Baughman wrote:

> I've also noticed that Velocity's Log4J logger is of class
> org.apache.log4j.Category, not class org.apache.log4j.Logger.
> The Category class has been deprecated.  Is Velocity going to change
> their Log4J logger to the recommended Logger class?

That's been fixed, and should be there in 1.5 (which I want to start 
pushing to rc1).  I missed the 3/1 deadline for 1.4, so will upgrade 
the license and foist that out there.

>
> So my Log4J definition of the Velocity logger is:
> log4j.category.VELOCITY=DEBUG, VEL
>
> instead of
>
> log4j.logger.VELOCITY=DEBUG, VEL
>
> All of my other Log4J logs use the logger definition.
>
> Barbara Baughman
> X2157
>
> On Tue, 2 Mar 2004, Simon Christian wrote:
>
>> I haven't followed the same route as you've taken here, but there is 
>> an
>> easy way to have Velocity put it's log output through Log4j:
>>
>> Remove/comment out any existing lines starting with runtime.log.xxxx,
>> and add the following lines:
>>
>> runtime.log.logsystem.class  =
>> 	org.apache.velocity.runtime.log.SimpleLog4JLogSystem
>> runtime.log.logsystem.log4j.category = org.apache.velocity
>>
>> The category you can change to whatever is appropriate. Note the first
>> line has split above - there should just be two lines.
>>
>> - simon
>>
>>
>> kokoko wrote:
>>> Hi all,
>>>    I am using Log4j for logging in my application. I
>>> want to redirect the logs
>>> info of Velocity to my Logger. Acc. 2 the Velocity
>>> userguide, I implemented
>>> a class 'MyLogger' which extends LogSystem interface.
>>> The logs are being redirected
>>> to one single log file, but my "Velocity" files are
>>> not being displayed.
>>> Commenting out the param "runtime.log.logsystem.class
>>> in "Velocity.properties"
>>> file, I dont get the error and the .vm files are being
>>> displayed.
>>>
>>> I get the error: ActionServlet ERROR [init] Cannot
>>> find template 'Server.vm';
>>> nested exception is:
>>> org.actionframework.TemplateException: Error while
>>> loading
>>> template 'Server.vm'; nested exception is:
>>> org.apache.velocity.exception.ResourceNotFoundException:
>>>
>>> Unable to find resource 'Server.vm'
>>>   ......
>>>
>>>
>>> 	My Logger class:
>>>    static Logger logger =
>>> Logger.getLogger(MyLogger.class);
>>>    public MyLogger() {
>>>      try {
>>>
>>> Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM,
>>> this );
>>>            Velocity.init();
>>>        }
>>>        catch (Exception e) {
>>>            logger.error(e);
>>>        }
>>>    }
>>>
>>>     public void init( RuntimeServices rsvc ) {
>>>     }
>>>
>>>     public void logVelocityMessage(int level, String
>>> message) {
>>>     	logger.log(Level.toLevel(level), message);
>>>     }
>>>
>>>
>>> My Velocity.properties file consist of:
>>>     file.resource.loader.path = web/vm/
>>>     runtime.log = logs/squid.log
>>>     runtime.log.logsystem.class =
>>> rtimage.squid.MyLogger
>>>
>>> Please give me any suggestions.
>>>
>>> __________________________________
>>> Do you Yahoo!?
>>> Get better spam protection with Yahoo! Mail.
>>> http://antispam.yahoo.com/tools
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geir@4quarters.com


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


Re: Custom Logger Problem

Posted by Barbara Baughman <ba...@utdallas.edu>.
I've also noticed that Velocity's Log4J logger is of class
org.apache.log4j.Category, not class org.apache.log4j.Logger.
The Category class has been deprecated.  Is Velocity going to change
their Log4J logger to the recommended Logger class?

So my Log4J definition of the Velocity logger is:
log4j.category.VELOCITY=DEBUG, VEL

instead of

log4j.logger.VELOCITY=DEBUG, VEL

All of my other Log4J logs use the logger definition.

Barbara Baughman
X2157

On Tue, 2 Mar 2004, Simon Christian wrote:

> I haven't followed the same route as you've taken here, but there is an
> easy way to have Velocity put it's log output through Log4j:
>
> Remove/comment out any existing lines starting with runtime.log.xxxx,
> and add the following lines:
>
> runtime.log.logsystem.class  =
> 	org.apache.velocity.runtime.log.SimpleLog4JLogSystem
> runtime.log.logsystem.log4j.category = org.apache.velocity
>
> The category you can change to whatever is appropriate. Note the first
> line has split above - there should just be two lines.
>
> - simon
>
>
> kokoko wrote:
> > Hi all,
> >    I am using Log4j for logging in my application. I
> > want to redirect the logs
> > info of Velocity to my Logger. Acc. 2 the Velocity
> > userguide, I implemented
> > a class 'MyLogger' which extends LogSystem interface.
> > The logs are being redirected
> > to one single log file, but my "Velocity" files are
> > not being displayed.
> > Commenting out the param "runtime.log.logsystem.class
> > in "Velocity.properties"
> > file, I dont get the error and the .vm files are being
> > displayed.
> >
> > I get the error: ActionServlet ERROR [init] Cannot
> > find template 'Server.vm';
> > nested exception is:
> > org.actionframework.TemplateException: Error while
> > loading
> > template 'Server.vm'; nested exception is:
> > org.apache.velocity.exception.ResourceNotFoundException:
> >
> > Unable to find resource 'Server.vm'
> >   ......
> >
> >
> > 	My Logger class:
> >    static Logger logger =
> > Logger.getLogger(MyLogger.class);
> >    public MyLogger() {
> >      try {
> >
> > Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM,
> > this );
> >            Velocity.init();
> >        }
> >        catch (Exception e) {
> >            logger.error(e);
> >        }
> >    }
> >
> >     public void init( RuntimeServices rsvc ) {
> >     }
> >
> >     public void logVelocityMessage(int level, String
> > message) {
> >     	logger.log(Level.toLevel(level), message);
> >     }
> >
> >
> > My Velocity.properties file consist of:
> >     file.resource.loader.path = web/vm/
> >     runtime.log = logs/squid.log
> >     runtime.log.logsystem.class =
> > rtimage.squid.MyLogger
> >
> > Please give me any suggestions.
> >
> > __________________________________
> > Do you Yahoo!?
> > Get better spam protection with Yahoo! Mail.
> > http://antispam.yahoo.com/tools
> >
> > ---------------------------------------------------------------------
> > 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
>
>

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


Re: Custom Logger Problem

Posted by Simon Christian <si...@stoutstick.com>.
I haven't followed the same route as you've taken here, but there is an 
easy way to have Velocity put it's log output through Log4j:

Remove/comment out any existing lines starting with runtime.log.xxxx, 
and add the following lines:

runtime.log.logsystem.class  =
	org.apache.velocity.runtime.log.SimpleLog4JLogSystem
runtime.log.logsystem.log4j.category = org.apache.velocity

The category you can change to whatever is appropriate. Note the first 
line has split above - there should just be two lines.

- simon


kokoko wrote:
> Hi all,
>    I am using Log4j for logging in my application. I
> want to redirect the logs
> info of Velocity to my Logger. Acc. 2 the Velocity
> userguide, I implemented
> a class 'MyLogger' which extends LogSystem interface.
> The logs are being redirected
> to one single log file, but my "Velocity" files are
> not being displayed. 
> Commenting out the param "runtime.log.logsystem.class
> in "Velocity.properties" 
> file, I dont get the error and the .vm files are being
> displayed.
> 
> I get the error: ActionServlet ERROR [init] Cannot
> find template 'Server.vm'; 
> nested exception is:
> org.actionframework.TemplateException: Error while
> loading 
> template 'Server.vm'; nested exception is:
> org.apache.velocity.exception.ResourceNotFoundException:
> 
> Unable to find resource 'Server.vm'
>   ......
>   
>   
> 	My Logger class:
>    static Logger logger =
> Logger.getLogger(MyLogger.class);
>    public MyLogger() {
>      try {
>           
> Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM,
> this );
>            Velocity.init();
>        }
>        catch (Exception e) {
>            logger.error(e);
>        }
>    }
> 
>     public void init( RuntimeServices rsvc ) {
>     }
> 
>     public void logVelocityMessage(int level, String
> message) {    	
>     	logger.log(Level.toLevel(level), message);
>     }
>     
>     
> My Velocity.properties file consist of:
>     file.resource.loader.path = web/vm/
>     runtime.log = logs/squid.log
>     runtime.log.logsystem.class =
> rtimage.squid.MyLogger
>     
> Please give me any suggestions.    
> 
> __________________________________
> Do you Yahoo!?
> Get better spam protection with Yahoo! Mail.
> http://antispam.yahoo.com/tools
> 
> ---------------------------------------------------------------------
> 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