[slf4j-user] Fwd: SLF4J Warning - Loggers will not work as they were created during initialization phase

Debraj Manna subharaj.manna at gmail.com
Tue Jan 16 17:52:50 CET 2018


This is not an issue with slf4j. I am hitting the below issue with
dropwizard and logback.

https://github.com/dropwizard/dropwizard/issues/1367

It seems this has been fixed in 1.2.0 as explained here
<https://github.com/dropwizard/dropwizard/pull/1900>.

Once I manage to upgrade dropwizard to 1.2.0. I will post my finding here
again.

On Tue, Jan 16, 2018 at 3:24 PM, Ceki <ceki at qos.ch> wrote:

> If you are going to update, go for the latest.
>
> On 16.01.2018 05:13, Debraj Manna wrote:
>
>> Thanks Ceki.
>>
>> 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.
>>
>> On Tue, Jan 16, 2018 at 2:51 AM, Ceki <ceki at qos.ch <mailto:ceki at qos.ch>>
>> wrote:
>>
>>
>>     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.
>>
>>     I suggest upgrading slf4j-api to 1.7.25.
>>
>>     On 15.01.2018 20:14, Debraj Manna wrote:
>>
>>
>>         ---------- Forwarded message ----------
>>         From: *Debraj Manna* <subharaj.manna at gmail.com
>>         <mailto:subharaj.manna at gmail.com>
>>         <mailto:subharaj.manna at gmail.com <mailto:subharaj.manna at gmail.com
>> >>>
>>         Date: Tue, Jan 16, 2018 at 12:30 AM
>>         Subject: SLF4J Warning - Loggers will not work as they were
>>         created during initialization phase
>>         To: slf4j-user at qos.ch <mailto:slf4j-user at qos.ch>
>>         <mailto:slf4j-user at qos.ch <mailto:slf4j-user at qos.ch>>
>>
>>
>>         Cross-posting from stackoverflow
>>         <https://stackoverflow.com/questions/48268724/slf4j-warning-
>> loggers-will-not-work-as-they-were-created-during-initialization
>>         <https://stackoverflow.com/questions/48268724/slf4j-warning-
>> loggers-will-not-work-as-they-were-created-during-initialization>>
>>
>>         I am using slf4j with logback in a dropwizard application.
>>         During the application initialization I am seeing logs like below
>>
>>         |SLF4J:Thefollowing loggers will not work because they were
>>         created SLF4J:during the defaultconfiguration phase of the
>>         underlying logging system.SLF4J:Seealso
>>         http://www.slf4j.org/codes.html#substituteLogger
>>         <http://www.slf4j.org/codes.html#substituteLogger>
>>         <http://www.slf4j.org/codes.html#substituteLogger
>>         <http://www.slf4j.org/codes.html#substituteLogger>>SLF4J:com
>> .vnera.healthandmetrics.VneraMetrics|
>>
>>         I am using |logback.xml| with my dropwizard application. My code
>>         flow looks like below
>>
>>         |publicclassVneraMetrics{privatestaticfinalLoggerlogger
>>         =LoggerFactory.getLogger(VneraMetrics.class);...// This method
>>         is getting called from Service.run() during the dropwizard
>>         application initializationpublicStringgetSomeValue(){// logger
>>         is not accessed from this functionreturn"Some initialized
>>         value";}}publicclassServiceextendsApplication<Conf>{publicst
>> aticfinalLoggerlogger
>>         =LoggerFactory.getLogger(Service.class);publicstaticvoidmain
>> (Stringargs[]){logger.info
>>         <http://logger.info>("Some logs");Serviceservice
>>
>>         =newService();service.run(dropWizardArgs);Utils.reloadLogger
>> ();}}|
>>
>>         |Utils.reloadLogger()| is loading the loggback configuration as
>>         discussed here
>>
>>         |publicstaticvoidreloadLogger(){StringloggingConfig
>>         =System.getProperty("logback.configurationFile");if(loggingConfig
>> ==null){System.out.println("Logging
>>         Config is null");}LoggerContextloggerContext
>>         =(LoggerContext)LoggerFactory.getILoggerFactory();loggerCont
>> ext.reset();JoranConfiguratorconfigurator
>>         =newJoranConfigurator();try{InputStreamconfigStream
>>         =FileUtils.openInputStream(newFile(loggingConfig));configura
>> tor.setContext(loggerContext);configurator.doConfigure(configStream);//
>>         loads logback
>>         fileconfigStream.close();System.out.println("Loaded
>>         configuration
>>         file");}catch(JoranException|IOExceptione){e.printStackTrace
>> ();System.out.println("Failed
>>         to log configuration file");System.exit(1);}}}|
>>
>>         *Versions*
>>
>>            * Logback - 1.2.3
>>            * Dropwizard - 1.0.2
>>
>>         Can some one let me know what does the SLF4J warning denotes? I
>>         have seen the substituteLogger
>>         <http://www.slf4j.org/codes.html#substituteLogger
>>         <http://www.slf4j.org/codes.html#substituteLogger>> page but
>>         this does not mention how can I get around this? On trying to
>>         use logger in |VneraMetrics| it is not printing anything.
>>
>>
>>
>>
>>         _______________________________________________
>>         slf4j-user mailing list
>>         slf4j-user at qos.ch <mailto:slf4j-user at qos.ch>
>>         http://mailman.qos.ch/mailman/listinfo/slf4j-user
>>         <http://mailman.qos.ch/mailman/listinfo/slf4j-user>
>>
>>     _______________________________________________
>>     slf4j-user mailing list
>>     slf4j-user at qos.ch <mailto:slf4j-user at qos.ch>
>>     http://mailman.qos.ch/mailman/listinfo/slf4j-user
>>     <http://mailman.qos.ch/mailman/listinfo/slf4j-user>
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/slf4j-user/attachments/20180116/7439bee2/attachment.html>


More information about the slf4j-user mailing list