I was trying to get Logging configured by specifying a Configuration and
a DefaultLogKitManager and ran into a NullPointerException because I had
not called setLogger() on the DefaultLogKitManager before calling
configure(). I figured out the problem after digging around in the code,
but things would have been a lot easier had I gotten an
IllegalStateException describing the problem or something along those lines.

Following the examples in the docs, I have been trying to design my
components to be fairly defensive about their own state by adding checks
to make sure that say configure is not called before setLogger has been
correctly called.

What are peoples thoughts on this? I think that making these classes
more defensive would also really help shorten the learning curve for new
users by pointing out mistakes like mine without requiring the user to
roll up their sleeves and dig into the code.

Here is the exception that I got:
java.lang.NullPointerException
at
org.apache.avalon.excalibur.logger.DefaultLogTargetFactoryManager.configure(DefaultLogTargetFactoryManager.java:144)
at
org.apache.avalon.excalibur.logger.DefaultLogKitManager.setupTargetFactoryManager(DefaultLogKitManager.java:191)
at
org.apache.avalon.excalibur.logger.DefaultLogKitManager.configure(DefaultLogKitManager.java:154)
... rest of stack trace.

Thrown on:
if( getLogger().isDebugEnabled() )

Cheers,
Leif




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to