You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Thomas Åhlen <th...@obidobi.net> on 2001/11/22 00:03:16 UTC

problems when trying to use Log4JLogSystem

I have problem when trying to use Velocity's Log4JLogSystem

[Jars]
log4j-1.2alpha2.jar
velocity-1.2-rc3.jar

[properties]
runtime.log.logsystem.class=org.apache.velocity.runtime.log.Log4JLogSystem
runtime.log = velocity.log
runtime.log.logsystem.log4j.pattern=%d - %m%n
runtime.log.logsystem.log4j.file.size=100000
runtime.log.logsystem.log4j.file.backups=1

[Error]
Exception in thread "main" java.lang.NoSuchMethodError
        at
org.apache.velocity.runtime.log.Log4JLogSystem.internalInit(Log4JLogSystem.j
ava:129)
        at
org.apache.velocity.runtime.log.Log4JLogSystem.init(Log4JLogSystem.java:109)
        at
org.apache.velocity.runtime.log.LogManager.createLogSystem(LogManager.java:1
08)
        at
org.apache.velocity.runtime.RuntimeInstance.initializeLogger(RuntimeInstance
.java:468)
        at
org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:259)
        at
org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:438)
        at
org.apache.velocity.runtime.RuntimeSingleton.init(RuntimeSingleton.java:260)
        at org.apache.velocity.app.Velocity.init(Velocity.java:149)
        at
com.obidobi.obiwebapp.wrapper.velocity.Parser.init(Parser.java:40)
        at
com.obidobi.obiwebapp.module.template.TemplateBuilder.main(TemplateBuilder.j
ava:35)

[Log4JLogSystem.java:129]
126    private void internalInit()
127        throws Exception
128    {
129        logger = Category.getInstance("");
130        logger.setAdditivity(false);

[Category]
  public static Logger getInstance(String name) {
    return LogManager.getLogger(name);
  }

A call to Category.getInstance(""); in my code works without any problem. So
I can't see why Log4JLogSystem can't call it without Exception?

Can there be any problems with the fact that Category's getInstance(String
name) had been changed in Log4J1.2
from:
public static Category getInstance(String name);
to:
public static Logger getInstance(String name);

Since Logger extends Category I don't think that should be the problem??

Thomas Åhlén



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


Re: problems when trying to use Log4JLogSystem

Posted by Thomas Åhlen <th...@obidobi.net>.
>I really, really, really want to deprecate this class and get rid of it, as
>I think that the configuration of a category should be left up to the
>application - there is no way we will be able to deftly offer parameters
>that cover all the bases.

I fully agree with you! and even tried to use SimpleLog4JLogSystem at first
but it wasn't included in the latest jar :).

I did as you said and now it works, thanks!

Thomas


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


Re: problems when trying to use Log4JLogSystem

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
I really, really, really want to deprecate this class and get rid of it, as
I think that the configuration of a category should be left up to the
application - there is no way we will be able to deftly offer parameters
that cover all the bases.

In the current CVS HEAD, there is a simplified Log4J logger that you can
pass a category name to, and it will use that.

So you can configure the category (or use an existing one) and just pass it.

Also, now that I look at what you are doing, you just want a file-based
log4j logger, which the current CVS HEAD will do automatically.  Here's what
you should do :

1) get the current CVS or use the nightly snapshot.
2) build the default jar target. This will have no dependencies w/in it.
3) remove all that logsystem crap from your properties file except for the
name of the file you want to log to....
    runtime.log = velocity.log
4) put the log4j jar in your classpath, and make sure you don't have a
logkit jar in the classpath.
5) run.

Velocity will now automatically use log4j for simple file logging if logkit
is not in the classpath, and log4j is.

If you want to be sure, add
 
 runtime.log.logsystem.class =
org.apache.velocity.runtime.log.SimpleLog4JLogSystem

This isn't documented yet - it is brand new, and I wanted to see the
community's reaction before I documented it.

geir


On 11/21/01 6:03 PM, "Thomas Åhlen" <th...@obidobi.net> wrote:

> I have problem when trying to use Velocity's Log4JLogSystem
> 
> [Jars]
> log4j-1.2alpha2.jar
> velocity-1.2-rc3.jar
> 
> [properties]
> runtime.log.logsystem.class=org.apache.velocity.runtime.log.Log4JLogSystem
> runtime.log = velocity.log
> runtime.log.logsystem.log4j.pattern=%d - %m%n
> runtime.log.logsystem.log4j.file.size=100000
> runtime.log.logsystem.log4j.file.backups=1
> 
> [Error]
> Exception in thread "main" java.lang.NoSuchMethodError
>       at
> org.apache.velocity.runtime.log.Log4JLogSystem.internalInit(Log4JLogSystem.j
> ava:129)
>       at
> org.apache.velocity.runtime.log.Log4JLogSystem.init(Log4JLogSystem.java:109)
>       at
> org.apache.velocity.runtime.log.LogManager.createLogSystem(LogManager.java:1
> 08)
>       at
> org.apache.velocity.runtime.RuntimeInstance.initializeLogger(RuntimeInstance
> .java:468)
>       at
> org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:259)
>       at
> org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:438)
>       at
> org.apache.velocity.runtime.RuntimeSingleton.init(RuntimeSingleton.java:260)
>       at org.apache.velocity.app.Velocity.init(Velocity.java:149)
>       at
> com.obidobi.obiwebapp.wrapper.velocity.Parser.init(Parser.java:40)
>       at
> com.obidobi.obiwebapp.module.template.TemplateBuilder.main(TemplateBuilder.j
> ava:35)
> 
> [Log4JLogSystem.java:129]
> 126    private void internalInit()
> 127        throws Exception
> 128    {
> 129        logger = Category.getInstance("");
> 130        logger.setAdditivity(false);
> 
> [Category]
> public static Logger getInstance(String name) {
>   return LogManager.getLogger(name);
> }
> 
> A call to Category.getInstance(""); in my code works without any problem. So
> I can't see why Log4JLogSystem can't call it without Exception?
> 
> Can there be any problems with the fact that Category's getInstance(String
> name) had been changed in Log4J1.2
> from:
> public static Category getInstance(String name);
> to:
> public static Logger getInstance(String name);
> 
> Since Logger extends Category I don't think that should be the problem??
> 
> Thomas Åhlén
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.                       geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.



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