Hi, I am currently using log4j 1.2.4, but I had to create a facade over the logging package so as to avoid direct imports in the application. Also, this facade implements certain business rules that I require. Everything from that point of view works, but now I need to write my junit test cases to test my facade. Now the problem arises... In order to test the facade I need to have logging enabled (as nothing gets returned from the logging facade), so I created a simple SocketAppender and send all my messages to that. I have also created 2 additional pieces to help me test, these are:
A basic receiver type class, that will connect to the socket and accept messages. These LoggingEvent messages are then fed into a simple model. This model class is shared by both the receiver class and my actual junit test class. So, in the execution of a given test the following scenario is setup: I use the following appender, configured via the PropertyConfiguration: log4j.rootLogger=,A2 log4j.appender.A2=org.apache.log4j.net.SocketAppender log4j.appender.A2.Port=8890 log4j.appender.A2.RemoteHost=localhost log4j.appender.A2.LocationInfo=true * this is a very cut down version, but should be enuf to get the point across * setup() { m = new FooModel(); FooReceiver r = new FooReceiver( m ); // setups up my logging package based on the PropertyConfiguration. // See configuration above } // pseudo code - but it should get the message across. testFoo() { log.message( "some message goes here" ); assert( m.getMessage( 0 ).equals( "some message goes here" ) ); model.clear(); } Basically, I am sending a message through my facade into the log4j package. And will test the LoggingEvent and do something appropriate. And, since I have configured the log4j package to use a socket appender, that message should get sent to the socket. I did have this working, but I now receive the following for any appender I configure.. I get the same message now for ANY appender I try to setup. log4j:ERROR Could not instantiate appender named "A2". log4j:ERROR A "org.apache.log4j.net.SocketAppender" object is not assignable to a "org.apache.log4j.Appender" variable. log4j:ERROR Could not instantiate appender named "A2". log4j: Parsing for [root] with value=[,A2]. log4j: Parsing appender named "A2". log4j: Finished configuring. log4j:ERROR A "org.apache.log4j.net.SocketAppender" object is not assignable to a "org.apache.log4j.Appender" variable. log4j:ERROR Could not instantiate appender named "A2". Any thoughts, Thanks -Reg