<div dir="ltr"><div>Thanks Ceki. </div><div><br></div>Ok I am using slf4j-api 1.7.5. Even after initialization I am not seeing the logging events being logged while using that logger. I will update to the slf4j 1.7.15 and post back with the results.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 16, 2018 at 2:51 AM, Ceki <span dir="ltr"><<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
As of SLF4J 1.7.15, slf4j-api stores and replays events that were created during the initialization phase. In previous versions, these events were lost. However, logging events occurring after initialization should work fine in all versions.<br>
<br>
I suggest upgrading slf4j-api to 1.7.25.<span class=""><br>
<br>
On 15.01.2018 20:14, Debraj Manna wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<br>
---------- Forwarded message ----------<br>
From: *Debraj Manna* <<a href="mailto:subharaj.manna@gmail.com" target="_blank">subharaj.manna@gmail.com</a> <mailto:<a href="mailto:subharaj.manna@gmail.com" target="_blank">subharaj.manna@gmail.c<wbr>om</a>>><br>
Date: Tue, Jan 16, 2018 at 12:30 AM<br>
Subject: SLF4J Warning - Loggers will not work as they were created during initialization phase<br></span><span class="">
To: <a href="mailto:slf4j-user@qos.ch" target="_blank">slf4j-user@qos.ch</a> <mailto:<a href="mailto:slf4j-user@qos.ch" target="_blank">slf4j-user@qos.ch</a>><br>
<br>
<br>
Cross-posting from stackoverflow <<a href="https://stackoverflow.com/questions/48268724/slf4j-warning-loggers-will-not-work-as-they-were-created-during-initialization" rel="noreferrer" target="_blank">https://stackoverflow.com/que<wbr>stions/48268724/slf4j-warning-<wbr>loggers-will-not-work-as-they-<wbr>were-created-during-initializa<wbr>tion</a>><br>
<br></span><span class="">
I am using slf4j with logback in a dropwizard application. During the application initialization I am seeing logs like below<br>
<br></span>
|SLF4J:Thefollowing loggers will not work because they were created SLF4J:during the defaultconfiguration phase of the underlying logging system.SLF4J:Seealso <a href="http://www.slf4j.org/codes.html#substituteLogger" rel="noreferrer" target="_blank">http://www.slf4j.org/codes.htm<wbr>l#substituteLogger</a> <<a href="http://www.slf4j.org/codes.html#substituteLogger" rel="noreferrer" target="_blank">http://www.slf4j.org/codes.ht<wbr>ml#substituteLogger</a>>SLF4J:com.<wbr>vnera.healthandmetrics.VneraMe<wbr>trics|<span class=""><br>
<br>
I am using |logback.xml| with my dropwizard application. My code flow looks like below<br>
<br></span>
|publicclassVneraMetrics{priva<wbr>testaticfinalLoggerlogger =LoggerFactory.getLogger(Vnera<wbr>Metrics.class);...// This method is getting called from Service.run() during the dropwizard application initializationpublicStringgetS<wbr>omeValue(){// logger is not accessed from this functionreturn"Some initialized value";}}publicclassServiceext<wbr>endsApplication<Conf>{publicst<wbr>aticfinalLoggerlogger =LoggerFactory.getLogger(Servi<wbr>ce.class);publicstaticvoidmain<wbr>(Stringargs[]){<a href="http://logger.info" rel="noreferrer" target="_blank">logger.info</a>("So<wbr>me logs");Serviceservice =newService();service.run(drop<wbr>WizardArgs);Utils.reloadLogger<wbr>();}}|<span class=""><br>
<br>
|Utils.reloadLogger()| is loading the loggback configuration as discussed here<br>
<br></span><span class="">
|publicstaticvoidreloadLogger(<wbr>){StringloggingConfig =System.getProperty("logback.c<wbr>onfigurationFile");if(loggingC<wbr>onfig ==null){System.out.println("Lo<wbr>gging Config is null");}LoggerContextloggerCon<wbr>text =(LoggerContext)LoggerFactory.<wbr>getILoggerFactory();loggerCont<wbr>ext.reset();JoranConfiguratorc<wbr>onfigurator =newJoranConfigurator();try{In<wbr>putStreamconfigStream =FileUtils.openInputStream(new<wbr>File(loggingConfig));configura<wbr>tor.setContext(loggerContext);<wbr>configurator.doConfigure(<wbr>configStream);// loads logback fileconfigStream.close();Syste<wbr>m.out.println("Loaded configuration file");}catch(JoranException|I<wbr>OExceptione){e.printStackTrace<wbr>();System.out.println("Failed to log configuration file");System.exit(1);}}}|<br>
<br>
*Versions*<br>
<br>
  * Logback - 1.2.3<br></span>
  * Dropwizard - 1.0.2<br>
<br>
Can some one let me know what does the SLF4J warning denotes? I have seen the substituteLogger <<a href="http://www.slf4j.org/codes.html#substituteLogger" rel="noreferrer" target="_blank">http://www.slf4j.org/codes.ht<wbr>ml#substituteLogger</a>> page but this does not mention how can I get around this? On trying to use logger in |VneraMetrics| it is not printing anything.<span class=""><br>
<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
slf4j-user mailing list<br>
<a href="mailto:slf4j-user@qos.ch" target="_blank">slf4j-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/slf4j-user" rel="noreferrer" target="_blank">http://mailman.qos.ch/mailman/<wbr>listinfo/slf4j-user</a><br>
<br>
</span></blockquote><div class="HOEnZb"><div class="h5">
______________________________<wbr>_________________<br>
slf4j-user mailing list<br>
<a href="mailto:slf4j-user@qos.ch" target="_blank">slf4j-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/slf4j-user" rel="noreferrer" target="_blank">http://mailman.qos.ch/mailman/<wbr>listinfo/slf4j-user</a></div></div></blockquote></div><br></div>