<div dir="ltr">Loggers should be static.<div style>  (*Chris*)</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 6, 2013 at 8:17 AM, Ulrich <span dir="ltr"><<a href="mailto:Forums@gombers.de" target="_blank">Forums@gombers.de</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When calling override-method in a subclass from the constructor of the<br>
superclass the LOGGER in the subclass is not initialized; the program fails with<br>
NullPointerException.<br>
E.g:<br>
Subclass is:<br>
import org.slf4j.Logger;<br>
import org.slf4j.LoggerFactory;<br>
<br>
public class TestLoggerSubClass extends TestLoggerSuperClass {<br>
<br>
        private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());<br>
        public TestLoggerSubClass() {<br>
                super("TestLoggerSubClass");<br>
        }<br>
<br>
        @Override<br>
        public void display() {<br>
                int summe = 15+5;<br>
                LOGGER.info("Summe={}",summe);<br>
        }<br>
}<br>
<br>
<br>
Superclass is:<br>
import org.slf4j.Logger;<br>
import org.slf4j.LoggerFactory;<br>
<br>
public class TestLoggerSuperClass {<br>
<br>
        private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());<br>
        public TestLoggerSuperClass(String name) {<br>
                LOGGER.info("wurde mit Namen {} gerufen", name);<br>
                display();<br>
        }<br>
<br>
        public void display() {<br>
                int summe = 5+5;<br>
                LOGGER.info("Summe={}",summe);<br>
        }<br>
}<br>
<br>
The program fails, as already said, with NullPointerException in the<br>
LOGGER-Statement of the Override-Method in the subclass.<br>
<br>
Can I anything do to have the LOGGER initialized before invoking the constructor<br>
of the superclass?<br>
<br>
Thanks in advance,<br>
Ulrich<br>
_______________________________________________<br>
slf4j-user mailing list<br>
<a href="mailto:slf4j-user@qos.ch">slf4j-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/slf4j-user" target="_blank">http://mailman.qos.ch/mailman/listinfo/slf4j-user</a><br>
</blockquote></div><br></div>