Extending the Logger class is strongly discouraged.
Anyway, the examples file mycat.good had a mistake. I have attached a corrected version. Try it first before continuing. HTH, At 17:18 10.06.2002 -0700, you wrote: >Hi >I have extended org.apache.log4j.Logger and have implemented the >loggerfactory interface. >(When I say that I did this...I mean that I copied the examples and maed a >few minor changes!) >My xml configuration file looks like > ><?xml version="1.0" encoding="UTF-8"?> ><!DOCTYPE log4j:configuration SYSTEM "D:\logs\log4j\log4j.dtd"> ><log4j:configuration debug="true" >xmlns:log4j="http://jakarta.apache.org/log4j/"> > <appender name="A1" class="org.apache.log4j.DailyRollingFileAppender"> > <param name="File" value="D:/logs/generalLog.xml"/> > <layout class="my.log.MyLayout"> > <param name="ConversionPattern" value="%m"/> > </layout> > </appender> > <appender name="ServiceLogFile" >class="org.apache.log4j.DailyRollingFileAppender"> > <param name="File" value="D:/logs/serviceLog.xml"/> > <param name="DatePattern" value="'.'yyyy-MM-dd"/> > <layout class="my.log.MyLayout"> > <param name="ConversionPattern" value="%m"/> > </layout> > </appender> > <category name="my.log.Test" additivity="false"class="my.log.MyLogger"> > <level value="info"/> > <appender-ref ref="ServiceLogFile"/> > </logger> > > > <root> > <priority value="info"/> > <appender-ref ref="A1"/> > </root> > <categoryFactory class="my.log.MyLoggerFactory"/> ></log4j:configuration> > >I am getting a ClassCastException when I try to get an onstance of my logger >class. > >I have looked at the examples provided in the examples\subclass directory. >I even imported them into my IDE and ran the test with "mycat.good". This >also gives a ClassCastException. > >Am I missing sometyhing silly! I have been going stir-crazy looking at this. >Can anybody offer a suggestion? > >Thanks you >S -- Ceki SUICIDE BOMBING - A CRIME AGAINST HUMANITY Sign the petition: http://www.petitiononline.com/1234567b I am signatory number 22106. What is your number?
# Setting the category factory to MyLoggerFactory solves the # ClassCastException problem encountered with the "mycat.bad" # configuration file. log4j.loggerFactory=examples.subclass.MyLoggerFactory # The usual stuff. Note that A1 is configured in root not in "some.cat" log4j.rootCategory=DEBUG, A1 log4j.appender.A1=org.apache.log4j.ConsoleAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%5p [%t] %c - %m%n # Set the priority of "some.cat" to TRACE (defined in # examples.customLevel.XLevel). Since we specified MyLoggerFactory as # the logger factory, the following line willl also have the side # effect of instanciating a MyLogger object having the name # "some.cat". log4j.category.some.cat=TRACE#examples.customLevel.XLevel
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>