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 Christian Haase <ha...@siteface.de> on 2006/05/17 19:40:25 UTC

Initialize problem on linux machine

Hi all!

After a frustrating day without success I hope you can help me.
I've trouble running my Java-Apps at Suse Linux. On WinXP all works fine.

Problem description:
===============

Error:
log4j:WARN No appenders could be found for logger (me.objects.Environment).
log4j:WARN Please initialize the log4j system properly.


My Java Source (Snippet):
public class XmlSplitter {
private static final org.apache.log4j.Logger logger = 
org.apache.log4j.Logger.getLogger( XmlSplitter.class.getName() );
...
 public static void main( String[] args )  throws Exception
   {
      System.setProperty("log4j.file.name", "XmlSplitter");
      // Only for debugging:
      System.getProperties().list(System.out);
     ....  

Produces following System.out:
-- listing properties --
java.runtime.name=Java(TM) 2 Runtime Environment, Stand...
sun.boot.library.path=/usr/lib/SunJava2-1.4.2/jre/lib/i386
java.vm.version=1.4.2_08-b03
java.vm.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
path.separator=:
java.vm.name=Java HotSpot(TM) Client VM
file.encoding.pkg=sun.io
user.country=DE
sun.os.patch.level=unknown
java.vm.specification.name=Java Virtual Machine Specification
user.dir=/work
java.runtime.version=1.4.2_08-b03
java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment
java.endorsed.dirs=/usr/lib/SunJava2-1.4.2/jre/lib/endorsed
os.arch=i386
java.io.tmpdir=/tmp
java.vm.specification.vendor=Sun Microsystems Inc.
os.name=Linux
sun.java2d.fontpath=
log4j.configuration=/work/fop/entwicklung/log4j.properties   <--- Looks 
right, or not?
java.library.path=/usr/lib/SunJava2-1.4.2/jre/lib/i386/...


Contents of my log4j.properties:
log4j.rootLogger=INFO, FILE, stdout
#### First appender writes to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
# Error-Log in rollierendes ASCII-File, max. 1 MB:
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.File=/work/fop/entwicklung/log/${log4j.file.name}.log
log4j.appender.FILE.MaxFileSize=1000KB
log4j.appender.FILE.MaxBackupIndex=3
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d %p %l - %m%n
-- 

Any ideas where the problem is?

Greetings,
Christain


-------------------------------------
Christian Haase, Hans-Mertens-Str. 37
30655 Hannover, GERMANY
Tel: +49-511-697916 / +49-178-7772617
Fax: +49-511-3948280
ICQ: 307628315
-------------------------------------

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


Re: Initialize problem on linux machine

Posted by James Stauffer <st...@gmail.com>.
I think your properties file needs to be in your classpath.  Is it?

On 5/18/06, Christian Haase <ha...@siteface.de> wrote:
> Have done a run with -Dlog4j.debug, but doesn't helps me:
>
> log4j: Trying to find [/work/fop/entwicklung/log4j.properties] using
> context classloader sun.misc.Launcher$AppClassLoader@7b7072.
> log4j: Trying to find [/work/fop/entwicklung/log4j.properties] using
> sun.misc.Launcher$AppClassLoader@7b7072 class loader.
> log4j: Trying to find [/work/fop/entwicklung/log4j.properties] using
> ClassLoader.getSystemResource().
> log4j: Could not find resource: [/work/fop/entwicklung/log4j.properties].
>
>
> The path to log4j.poperties file is absolutely correct and the user the
> java application runs with has authorization for reading the file.
> I've no idea what's going wrong here. If you have any ideas, please let
> me know!
>
> Greetings,
> Christian
>
>
>
>
> James Stauffer schrieb:
>
> > Run with -Dlog4j.debug and it should show you how it it trying to
> > configure itself.
> >
> > On 5/17/06, Christian Haase <ha...@siteface.de> wrote:
> >
> >> Hi all!
> >>
> >> After a frustrating day without success I hope you can help me.
> >> I've trouble running my Java-Apps at Suse Linux. On WinXP all works
> >> fine.
> >>
> >> Problem description:
> >> ===============
> >>
> >> Error:
> >> log4j:WARN No appenders could be found for logger
> >> (me.objects.Environment).
> >> log4j:WARN Please initialize the log4j system properly.
> >>
> >>
> >> My Java Source (Snippet):
> >> public class XmlSplitter {
> >> private static final org.apache.log4j.Logger logger =
> >> org.apache.log4j.Logger.getLogger( XmlSplitter.class.getName() );
> >> ...
> >>  public static void main( String[] args )  throws Exception
> >>    {
> >>       System.setProperty("log4j.file.name", "XmlSplitter");
> >>       // Only for debugging:
> >>       System.getProperties().list(System.out);
> >>      ....
> >>
> >> Produces following System.out:
> >> -- listing properties --
> >> java.runtime.name=Java(TM) 2 Runtime Environment, Stand...
> >> sun.boot.library.path=/usr/lib/SunJava2-1.4.2/jre/lib/i386
> >> java.vm.version=1.4.2_08-b03
> >> java.vm.vendor=Sun Microsystems Inc.
> >> java.vendor.url=http://java.sun.com/
> >> path.separator=:
> >> java.vm.name=Java HotSpot(TM) Client VM
> >> file.encoding.pkg=sun.io
> >> user.country=DE
> >> sun.os.patch.level=unknown
> >> java.vm.specification.name=Java Virtual Machine Specification
> >> user.dir=/work
> >> java.runtime.version=1.4.2_08-b03
> >> java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment
> >> java.endorsed.dirs=/usr/lib/SunJava2-1.4.2/jre/lib/endorsed
> >> os.arch=i386
> >> java.io.tmpdir=/tmp
> >> java.vm.specification.vendor=Sun Microsystems Inc.
> >> os.name=Linux
> >> sun.java2d.fontpath=
> >> log4j.configuration=/work/fop/entwicklung/log4j.properties   <--- Looks
> >> right, or not?
> >> java.library.path=/usr/lib/SunJava2-1.4.2/jre/lib/i386/...
> >>
> >>
> >> Contents of my log4j.properties:
> >> log4j.rootLogger=INFO, FILE, stdout
> >> #### First appender writes to console
> >> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> >> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
> >> log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
> >> # Error-Log in rollierendes ASCII-File, max. 1 MB:
> >> log4j.appender.FILE=org.apache.log4j.RollingFileAppender
> >> log4j.appender.FILE.File=/work/fop/entwicklung/log/${log4j.file.name}.log
> >>
> >> log4j.appender.FILE.MaxFileSize=1000KB
> >> log4j.appender.FILE.MaxBackupIndex=3
> >> log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
> >> log4j.appender.FILE.layout.ConversionPattern=%d %p %l - %m%n
> >> --
> >>
> >> Any ideas where the problem is?
> >>
> >> Greetings,
> >> Christain
> >>
> >>
> >> -------------------------------------
> >> Christian Haase, Hans-Mertens-Str. 37
> >> 30655 Hannover, GERMANY
> >> Tel: +49-511-697916 / +49-178-7772617
> >> Fax: +49-511-3948280
> >> ICQ: 307628315
> >> -------------------------------------
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >> For additional commands, e-mail: log4j-user-help@logging.apache.org
> >>
> >>
> >
> >
>
> --
>
> -------------------------------------
> Christian Haase, Hans-Mertens-Str. 37
> 30655 Hannover, GERMANY
> Tel: +49-511-697916 / +49-178-7772617
> Fax: +49-511-3948280
> ICQ: 307628315
> -------------------------------------
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


-- 
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

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


Re: Initialize problem on linux machine

Posted by Curt Arnold <ca...@apache.org>.
On May 18, 2006, at 2:19 PM, Christian Haase wrote:

> Have done a run with -Dlog4j.debug, but doesn't helps me:
>
> log4j: Trying to find [/work/fop/entwicklung/log4j.properties]  
> using context classloader sun.misc.Launcher$AppClassLoader@7b7072.
> log4j: Trying to find [/work/fop/entwicklung/log4j.properties]  
> using sun.misc.Launcher$AppClassLoader@7b7072 class loader.
> log4j: Trying to find [/work/fop/entwicklung/log4j.properties]  
> using ClassLoader.getSystemResource().
> log4j: Could not find resource: [/work/fop/entwicklung/ 
> log4j.properties].
>
>
> The path to log4j.poperties file is absolutely correct and the user  
> the java application runs with has authorization for reading the file.
> I've no idea what's going wrong here. If you have any ideas, please  
> let me know!
>
> Greetings,
> Christian
>
>



>>>

>>> log4j.configuration=/work/fop/entwicklung/log4j.properties   <---  
>>> Looks
>>> right, or not?
>>> java.library.path=/usr/lib/SunJava2-1.4.2/jre/lib/i386/...
>>>


The code that handles this in in org.apache.log4j.LogManager's static  
initializer.  The value log4j.configuration is expected to be either  
a URL or an resource identifier in the class path.  The debug log  
confirms that it is was not recognized as a URL and it could not be  
found on the classpath (where it would be looking inside the jars in  
the same way it would try to find org.apache.log4j.Logger.class).   
Since the java.net.URL class likely delegates to the OS on Windows,  
then invalid URL's (particular ones with backslashes) might be  
accepted that fail on other platforms.

Your options would be to set log4j.configuration to a file: URL (for  
example, file:///work/fop/entwicklung/log4j.properties), add the root  
directory to the classpath or add the log4j.properties files to one  
of the jars or directories already in the classpath.


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


Re: Initialize problem on linux machine

Posted by Christian Haase <ha...@siteface.de>.
Have done a run with -Dlog4j.debug, but doesn't helps me:

log4j: Trying to find [/work/fop/entwicklung/log4j.properties] using 
context classloader sun.misc.Launcher$AppClassLoader@7b7072.
log4j: Trying to find [/work/fop/entwicklung/log4j.properties] using 
sun.misc.Launcher$AppClassLoader@7b7072 class loader.
log4j: Trying to find [/work/fop/entwicklung/log4j.properties] using 
ClassLoader.getSystemResource().
log4j: Could not find resource: [/work/fop/entwicklung/log4j.properties].


The path to log4j.poperties file is absolutely correct and the user the 
java application runs with has authorization for reading the file.
I've no idea what's going wrong here. If you have any ideas, please let 
me know!

Greetings,
Christian


 

James Stauffer schrieb:

> Run with -Dlog4j.debug and it should show you how it it trying to
> configure itself.
>
> On 5/17/06, Christian Haase <ha...@siteface.de> wrote:
>
>> Hi all!
>>
>> After a frustrating day without success I hope you can help me.
>> I've trouble running my Java-Apps at Suse Linux. On WinXP all works 
>> fine.
>>
>> Problem description:
>> ===============
>>
>> Error:
>> log4j:WARN No appenders could be found for logger 
>> (me.objects.Environment).
>> log4j:WARN Please initialize the log4j system properly.
>>
>>
>> My Java Source (Snippet):
>> public class XmlSplitter {
>> private static final org.apache.log4j.Logger logger =
>> org.apache.log4j.Logger.getLogger( XmlSplitter.class.getName() );
>> ...
>>  public static void main( String[] args )  throws Exception
>>    {
>>       System.setProperty("log4j.file.name", "XmlSplitter");
>>       // Only for debugging:
>>       System.getProperties().list(System.out);
>>      ....
>>
>> Produces following System.out:
>> -- listing properties --
>> java.runtime.name=Java(TM) 2 Runtime Environment, Stand...
>> sun.boot.library.path=/usr/lib/SunJava2-1.4.2/jre/lib/i386
>> java.vm.version=1.4.2_08-b03
>> java.vm.vendor=Sun Microsystems Inc.
>> java.vendor.url=http://java.sun.com/
>> path.separator=:
>> java.vm.name=Java HotSpot(TM) Client VM
>> file.encoding.pkg=sun.io
>> user.country=DE
>> sun.os.patch.level=unknown
>> java.vm.specification.name=Java Virtual Machine Specification
>> user.dir=/work
>> java.runtime.version=1.4.2_08-b03
>> java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment
>> java.endorsed.dirs=/usr/lib/SunJava2-1.4.2/jre/lib/endorsed
>> os.arch=i386
>> java.io.tmpdir=/tmp
>> java.vm.specification.vendor=Sun Microsystems Inc.
>> os.name=Linux
>> sun.java2d.fontpath=
>> log4j.configuration=/work/fop/entwicklung/log4j.properties   <--- Looks
>> right, or not?
>> java.library.path=/usr/lib/SunJava2-1.4.2/jre/lib/i386/...
>>
>>
>> Contents of my log4j.properties:
>> log4j.rootLogger=INFO, FILE, stdout
>> #### First appender writes to console
>> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
>> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
>> log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
>> # Error-Log in rollierendes ASCII-File, max. 1 MB:
>> log4j.appender.FILE=org.apache.log4j.RollingFileAppender
>> log4j.appender.FILE.File=/work/fop/entwicklung/log/${log4j.file.name}.log 
>>
>> log4j.appender.FILE.MaxFileSize=1000KB
>> log4j.appender.FILE.MaxBackupIndex=3
>> log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
>> log4j.appender.FILE.layout.ConversionPattern=%d %p %l - %m%n
>> -- 
>>
>> Any ideas where the problem is?
>>
>> Greetings,
>> Christain
>>
>>
>> -------------------------------------
>> Christian Haase, Hans-Mertens-Str. 37
>> 30655 Hannover, GERMANY
>> Tel: +49-511-697916 / +49-178-7772617
>> Fax: +49-511-3948280
>> ICQ: 307628315
>> -------------------------------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
>
>

-- 

-------------------------------------
Christian Haase, Hans-Mertens-Str. 37
30655 Hannover, GERMANY
Tel: +49-511-697916 / +49-178-7772617
Fax: +49-511-3948280
ICQ: 307628315
-------------------------------------


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


RE: Initialize problem on linux machine

Posted by Néstor Boscán <ne...@tcsapp.com.ve>.
Hi Curt

I downloaded a patch utility but I'm getting:

Appender.patch
patching file AsyncAppender.java
Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 339

This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.

Do you have the AsyncAppender file already patched so I can simply replace
the file and build.

Regards,

Néstor Boscán 

-----Mensaje original-----
De: Curt Arnold [mailto:carnold@apache.org] 
Enviado el: Wednesday, May 17, 2006 2:48 PM
Para: Log4J Users List
Asunto: Re: Initialize problem on linux machine


On May 17, 2006, at 1:00 PM, James Stauffer wrote:

> Run with -Dlog4j.debug and it should show you how it it trying to 
> configure itself.
>

Default configuration should occur BEFORE XmlSplitter.main() is entered and
the "log4j.file.name" system property is set.  To me, it looks like it would
occur during the getLogger() call.  If you want to set the property, either:

a) use a command line option, -Dlog4j.file.name=XmlSplitter
b) ensure that the system property is set before the call to
Logger.getLogger()
c) explicitly initialize logging

For option b, you could do something like:

private static final Logger logger = createLogger();

private static final Logger createLogger() {
           System.setProperty("log4j.file.name", "XmlSplitter");
           return Logger.getLogger(XmlSplitter.class.getName());
}

However, if something else triggers default initialization, you could still
have the same issue of setting the property after it was attempted to be
used.

If your problem wasn't a bungled file name due to the property not being
set, then please elaborate on what appears to be going wrong.


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




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


Re: Initialize problem on linux machine

Posted by Curt Arnold <ca...@apache.org>.
On May 17, 2006, at 1:00 PM, James Stauffer wrote:

> Run with -Dlog4j.debug and it should show you how it it trying to
> configure itself.
>

Default configuration should occur BEFORE XmlSplitter.main() is  
entered and the "log4j.file.name" system property is set.  To me, it  
looks like it would occur during the getLogger() call.  If you want  
to set the property, either:

a) use a command line option, -Dlog4j.file.name=XmlSplitter
b) ensure that the system property is set before the call to  
Logger.getLogger()
c) explicitly initialize logging

For option b, you could do something like:

private static final Logger logger = createLogger();

private static final Logger createLogger() {
           System.setProperty("log4j.file.name", "XmlSplitter");
           return Logger.getLogger(XmlSplitter.class.getName());
}

However, if something else triggers default initialization, you could  
still have the same issue of setting the property after it was  
attempted to be used.

If your problem wasn't a bungled file name due to the property not  
being set, then please elaborate on what appears to be going wrong.


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


Re: Initialize problem on linux machine

Posted by James Stauffer <st...@gmail.com>.
Run with -Dlog4j.debug and it should show you how it it trying to
configure itself.

On 5/17/06, Christian Haase <ha...@siteface.de> wrote:
> Hi all!
>
> After a frustrating day without success I hope you can help me.
> I've trouble running my Java-Apps at Suse Linux. On WinXP all works fine.
>
> Problem description:
> ===============
>
> Error:
> log4j:WARN No appenders could be found for logger (me.objects.Environment).
> log4j:WARN Please initialize the log4j system properly.
>
>
> My Java Source (Snippet):
> public class XmlSplitter {
> private static final org.apache.log4j.Logger logger =
> org.apache.log4j.Logger.getLogger( XmlSplitter.class.getName() );
> ...
>  public static void main( String[] args )  throws Exception
>    {
>       System.setProperty("log4j.file.name", "XmlSplitter");
>       // Only for debugging:
>       System.getProperties().list(System.out);
>      ....
>
> Produces following System.out:
> -- listing properties --
> java.runtime.name=Java(TM) 2 Runtime Environment, Stand...
> sun.boot.library.path=/usr/lib/SunJava2-1.4.2/jre/lib/i386
> java.vm.version=1.4.2_08-b03
> java.vm.vendor=Sun Microsystems Inc.
> java.vendor.url=http://java.sun.com/
> path.separator=:
> java.vm.name=Java HotSpot(TM) Client VM
> file.encoding.pkg=sun.io
> user.country=DE
> sun.os.patch.level=unknown
> java.vm.specification.name=Java Virtual Machine Specification
> user.dir=/work
> java.runtime.version=1.4.2_08-b03
> java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment
> java.endorsed.dirs=/usr/lib/SunJava2-1.4.2/jre/lib/endorsed
> os.arch=i386
> java.io.tmpdir=/tmp
> java.vm.specification.vendor=Sun Microsystems Inc.
> os.name=Linux
> sun.java2d.fontpath=
> log4j.configuration=/work/fop/entwicklung/log4j.properties   <--- Looks
> right, or not?
> java.library.path=/usr/lib/SunJava2-1.4.2/jre/lib/i386/...
>
>
> Contents of my log4j.properties:
> log4j.rootLogger=INFO, FILE, stdout
> #### First appender writes to console
> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
> log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
> # Error-Log in rollierendes ASCII-File, max. 1 MB:
> log4j.appender.FILE=org.apache.log4j.RollingFileAppender
> log4j.appender.FILE.File=/work/fop/entwicklung/log/${log4j.file.name}.log
> log4j.appender.FILE.MaxFileSize=1000KB
> log4j.appender.FILE.MaxBackupIndex=3
> log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
> log4j.appender.FILE.layout.ConversionPattern=%d %p %l - %m%n
> --
>
> Any ideas where the problem is?
>
> Greetings,
> Christain
>
>
> -------------------------------------
> Christian Haase, Hans-Mertens-Str. 37
> 30655 Hannover, GERMANY
> Tel: +49-511-697916 / +49-178-7772617
> Fax: +49-511-3948280
> ICQ: 307628315
> -------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


-- 
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

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