You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Xavier Outhier <xa...@anfdata.cz> on 2003/04/25 10:04:49 UTC

Is it possible to use Log4j from within a jar?

Hi all,

Newbie question (off course).
Is it possible to use Log4J for an application that is in a jar?

I add Log4J logger in my applications and it works fine when
using NetBeans internal execution. Unfortunately, I was not
able to use it when my application was put into a jar.
I tried to add classpath to the Log4j jar but without success.
Here are the error output:

D:\Manta4>java -jar aanthill.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
        at Debug.AppliManta.<clinit>(AppliManta.java:20)
        at Application.Manta.<init>(Manta.java:27)
        at Application.Manta.main(Manta.java:78)

D:\Manta4>java -cp D:\log4j\log4j-1.2.7.jar -jar aanthill.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
        at Debug.AppliManta.<clinit>(AppliManta.java:20)
        at Application.Manta.<init>(Manta.java:27)
        at Application.Manta.main(Manta.java:78)

Any idea? Problem in the jar manifext classpath? Should I include the
log4j jar in my jar, how?

Best Regards,

Xavier.
--
#-------------------------------------------------------#
| Artificial Anthill Project (*)                        |
|  http://aanthill.org                                  |
#-------------------------------------------------------#
| D2SET Science and Technology Association              |
|  http://d2set.free.fr                                 |
#-------------------------------------------------------#
| Group of exchange regarding imagery technics (French) |
|  http://fr.groups.yahoo.com/group/imagerie-tech/      |
#-------------------------------------------------------#
| Employement in imagery: offers and demands (French)   |
|  http://fr.groups.yahoo.com/group/imagerie-emploi/    |
#-------------------------------------------------------#

(*) We are seaking for webmasters, graphic designers,
 biologists, biochimists, translators.

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


Re: Is it possible to use Log4j from within a jar?

Posted by Jacob Kjome <ho...@visi.com>.
Put it In the classpath for default configuration or load it up yourself 
and pass it to the appropriate configure() method.

Jake

At 04:05 PM 4/25/2003 +0000, you wrote:
>I have another (newbie too :-\) question related to this one:
>
>Where do I have to put a properties file for log4j in a jar so that it is
>found when calling DOMConfigurator.configure() method?
>
>On Friday 25 April 2003 08:04 am, Xavier Outhier wrote:
> > Hi all,
> >
> > Newbie question (off course).
> > Is it possible to use Log4J for an application that is in a jar?
> >
> > I add Log4J logger in my applications and it works fine when
> > using NetBeans internal execution. Unfortunately, I was not
> > able to use it when my application was put into a jar.
> > I tried to add classpath to the Log4j jar but without success.
> > Here are the error output:
> >
> > D:\Manta4>java -jar aanthill.jar
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > org/apache/log4j/Logger at Debug.AppliManta.<clinit>(AppliManta.java:20)
> >         at Application.Manta.<init>(Manta.java:27)
> >         at Application.Manta.main(Manta.java:78)
> >
> > D:\Manta4>java -cp D:\log4j\log4j-1.2.7.jar -jar aanthill.jar
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > org/apache/log4j/Logger at Debug.AppliManta.<clinit>(AppliManta.java:20)
> >         at Application.Manta.<init>(Manta.java:27)
> >         at Application.Manta.main(Manta.java:78)
> >
> > Any idea? Problem in the jar manifext classpath? Should I include the
> > log4j jar in my jar, how?
> >
> > Best Regards,
> >
> > Xavier.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org

Re: Is it possible to use Log4j from within a jar?

Posted by Andreea Stefanescu <an...@axetel.com>.
I have another (newbie too :-\) question related to this one:

Where do I have to put a properties file for log4j in a jar so that it is 
found when calling DOMConfigurator.configure() method?

On Friday 25 April 2003 08:04 am, Xavier Outhier wrote:
> Hi all,
>
> Newbie question (off course).
> Is it possible to use Log4J for an application that is in a jar?
>
> I add Log4J logger in my applications and it works fine when
> using NetBeans internal execution. Unfortunately, I was not
> able to use it when my application was put into a jar.
> I tried to add classpath to the Log4j jar but without success.
> Here are the error output:
>
> D:\Manta4>java -jar aanthill.jar
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/log4j/Logger at Debug.AppliManta.<clinit>(AppliManta.java:20)
>         at Application.Manta.<init>(Manta.java:27)
>         at Application.Manta.main(Manta.java:78)
>
> D:\Manta4>java -cp D:\log4j\log4j-1.2.7.jar -jar aanthill.jar
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/log4j/Logger at Debug.AppliManta.<clinit>(AppliManta.java:20)
>         at Application.Manta.<init>(Manta.java:27)
>         at Application.Manta.main(Manta.java:78)
>
> Any idea? Problem in the jar manifext classpath? Should I include the
> log4j jar in my jar, how?
>
> Best Regards,
>
> Xavier.


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