Loggers should be static.
  (*Chris*)

On Thu, Jun 6, 2013 at 8:17 AM, Ulrich <[email protected]> wrote:

> When calling override-method in a subclass from the constructor of the
> superclass the LOGGER in the subclass is not initialized; the program
> fails with
> NullPointerException.
> E.g:
> Subclass is:
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
>
> public class TestLoggerSubClass extends TestLoggerSuperClass {
>
>         private final Logger LOGGER =
> LoggerFactory.getLogger(this.getClass());
>         public TestLoggerSubClass() {
>                 super("TestLoggerSubClass");
>         }
>
>         @Override
>         public void display() {
>                 int summe = 15+5;
>                 LOGGER.info("Summe={}",summe);
>         }
> }
>
>
> Superclass is:
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
>
> public class TestLoggerSuperClass {
>
>         private final Logger LOGGER =
> LoggerFactory.getLogger(this.getClass());
>         public TestLoggerSuperClass(String name) {
>                 LOGGER.info("wurde mit Namen {} gerufen", name);
>                 display();
>         }
>
>         public void display() {
>                 int summe = 5+5;
>                 LOGGER.info("Summe={}",summe);
>         }
> }
>
> The program fails, as already said, with NullPointerException in the
> LOGGER-Statement of the Override-Method in the subclass.
>
> Can I anything do to have the LOGGER initialized before invoking the
> constructor
> of the superclass?
>
> Thanks in advance,
> Ulrich
> _______________________________________________
> slf4j-user mailing list
> [email protected]
> http://mailman.qos.ch/mailman/listinfo/slf4j-user
>
_______________________________________________
slf4j-user mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/slf4j-user

Reply via email to