aspose file tools*
The moose likes Other Open Source Projects and the fly likes log4j.xml No appenders could be found for logger() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "log4j.xml No appenders could be found for logger()" Watch "log4j.xml No appenders could be found for logger()" New topic
Author

log4j.xml No appenders could be found for logger()

Jeff Garrison
Greenhorn

Joined: Apr 09, 2004
Posts: 3
Update. . .Fixed no appenders found problem
I was using:
PropertyConfigurator.configure(args[0]);
Today I'm using:
DOMConfigurator.configure(args[0]);
Hope this post helps people make the move to xml properties. . .



My BIG mystery. . .
We're using log4j 1.2.8. . .
We're an MQSeries workflow shop. . .
We're running strictly in AIX 5.1 with JVM 1.3.1. . .
We were using flat log4j.properties. . .
Each of many java programs with a reference to it's own logger, appender and subsequent log file.
I've consolidated these properties and in the same motion made the move to xml format for the properties file.
I'm not the sharpest tool in the shed. . .and I'm humble. . .so be nice.
So far so good?
Here's where the trouble begins, I did my testing with a couple of dummy classes, a single xml log4j properties file and script, all in a logtesting folder in AIX. . .success. . . Now it's time to move to our actual dev environment. . .My classes are in the javasource folder, xml properties in a configs folder (along with my original properties files), kornshell in the scripts folder, a place for everything, and everything in it's place. . .great. . .Not so great, mind you this has been the setup for a couple of great and functional years with plain text properties files. In the kornshell, all I changed was log4j.properties to log4j.xml. . .It fails to find appenders for the logger. . .
Here's the odd bit if I take the kornshell script and log4j.xml and put them in any floder together it works great, separate the two and fail.

I haven't tested in windows yet, there's good reason for that. My prod box is AIX. . .

Anyone with any insight. . .?

Here's the important bits from my java, script, and xml. . .

JAVA SNIPPET EXAMPLE: public static Logger logger = Logger.getLogger
("Program1.class");

# SCRIPT SNIPPET EXAMPLE:
# Set the directory where code is at
# ------------------------------------------------------
export APP_DIR=/dvm/workflow/server


# Set to the location of log4jSTE.properties
# ------------------------------------------------------
#the way we were.
#export CONFIGFILE=$APP_DIR/configs/log4jSTE.properties
#the way we are. Big change huh. . .
export LOG4JFILE=$APP_DIR/configs/log4j.xml

java -classpath $CP -Djava.library.path=$PT CreateKeyUPES $LOG4JFILE

I'll throw in the entire log4j.xml as example maybe it will help someone somewhere trying to do a similar setup. . .I changed most of my real classes, log names, appenders to generic in order to help protect the innocent, that would be ME!

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

<appender name="Console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.SimpleLayout"/>
</appender>


<appender name="Program1Appender" class="org.apache.log4j.RollingFileAppender">
<!-- set the absolute path and log file name to create. -->
<param name="File" value="/dvm/workflow/server/logs/Program1.log"/>
<!-- set the max file size. -->
<param name="MaxFileSize" value="1000KB"/>
<!-- set the number of files. -->
<param name="MaxBackupIndex" value="3"/>
<!-- LAYOUT SETUP-->
<!-- set the pattern layout. -->
<layout class="org.apache.log4j.PatternLayout">
<!-- print the date in ISO 8601 format -->
<param name ="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>

<appender name="Program2Appender" class="org.apache.log4j.RollingFileAppender">
<!-- set the absolute path and log file name to create. -->
<param name="File" value="/dvm/workflow/server/logs/Program2.log"/>
<!-- set the max file size. -->
<param name="MaxFileSize" value="10000KB"/>
<!-- set the number of files. -->
<param name="MaxBackupIndex" value="10"/>
<!-- LAYOUT SETUP-->
<!-- set the pattern layout. -->
<layout class="org.apache.log4j.PatternLayout">
<!-- print the date in ISO 8601 format -->
<param name ="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>

<appender name="Program3Appender" class="org.apache.log4j.RollingFileAppender">
<!-- set the absolute path and log file name to create. -->
<param name="File" value="/dvm/workflow/server/logs/Program3.log"/>
<!-- set the max file size. -->
<param name="MaxFileSize" value="10000KB"/>
<!-- set the number of files. -->
<param name="MaxBackupIndex" value="1"/>
<!-- LAYOUT SETUP-->
<!-- set the pattern layout. -->
<layout class="org.apache.log4j.PatternLayout">
<!-- print the date in ISO 8601 format -->
<param name ="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>

<appender name="Program4Appender" class="org.apache.log4j.RollingFileAppender">
<!-- set the absolute path and log file name to create. -->
<param name="File" value="/dvm/workflow/server/logs/Program4.log"/>
<!-- set the max file size. -->
<param name="MaxFileSize" value="1000KB"/>
<!-- set the number of files. -->
<param name="MaxBackupIndex" value="3"/>
<!-- LAYOUT SETUP-->
<!-- set the pattern layout. -->
<layout class="org.apache.log4j.PatternLayout">
<!-- print the date in ISO 8601 format -->
<param name ="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>

<appender name="Program5Appender" class="org.apache.log4j.RollingFileAppender">
<!-- set the absolute path and log file name to create. -->
<param name="File" value="/dvm/workflow/server/logs/Program5.log"/>
<!-- set the max file size. -->
<param name="MaxFileSize" value="10000KB"/>
<!-- set the number of files. -->
<param name="MaxBackupIndex" value="1"/>
<!-- LAYOUT SETUP-->
<!-- set the pattern layout. -->
<layout class="org.apache.log4j.PatternLayout">
<!-- print the date in ISO 8601 format -->
<param name ="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>


<logger name="Program1.class">
<appender-ref ref="Program1Appender"/>
</logger>

<logger name="Program2.class">
<appender-ref ref="Program2Appender"/>
</logger>

<logger name="Program3.class">
<appender-ref ref="Program3Appender"/>
</logger>

<logger name="Program4.class">
<appender-ref ref="Program4Appender"/>
</logger>

<logger name="Program5.class">
<appender-ref ref="Program5Appender"/>
</logger>


<root>
<level value ="info"/>
<appender-ref ref="Console" />
</root>

</log4j:configuration>

Thanks, and I hope someone else is out there trying to log certain java programs to aptly named log files respectively. . .

Regards,

-J. Garrison
[ June 10, 2004: Message edited by: Jeff Garrison ]
Eugene Fahy
Greenhorn

Joined: Apr 23, 2004
Posts: 1
Hi Jeff,
you're message is a week or two old so I don't know if you'll pick up this reply, but I spent a bit of time sweating over the same log4j warning messages. I'm not a real expert on log4j myself, but I can tell you that I got rid of the warnings by putting the following into my command to execute my program:
-Dlog4j.configuration=./log4j.xml
so the full command for me to run Eugene.class was:
java -Dlog4j.configuration=./log4j.xml -cp .;"%CLASSPATH%" Eugene
Perhaps it'll do the trick for you too.
Thanks,
Eugene
Jeff Garrison
Greenhorn

Joined: Apr 09, 2004
Posts: 3
Thanks for the info Eugene, I'll post again after I've given it a try. . .

-Jeff
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: log4j.xml No appenders could be found for logger()