At 16:42 18.07.2002 -0500, Jacob Kjome wrote: >One update. I got an email from another user who said to explicitly >cast to a Logger because "Logger.getInstance() returns a Category for >backwards compatibility, >so you need to cast."
The above sentence although formally correct can be misread. To avoid confusion, let me insist that log4j 1.2 ALWAYS produces Logger instances. It is actually quite impossible to force log4j to produce Category instances which are not of type Logger. The signatures of the Logger.getInstance() or Category.getInstance() methods specify that they return a Category object. But in reality they actually return a Logger object. (Logger extends Category implying that a Logger *is* a Category. The cast to Logger you mention would not work otherwise.) >So, it would be: > >transient final private static Logger logger = >(Logger)Logger.getLogger{MyClass.class.getName()); > >or does that not affect getLogger(), but only getInstance()? > >Jake -- Ceki -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>