[ 
https://jira.qos.ch/browse/SLF4J-419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18966#comment-18966
 ] 

Jan S. commented on SLF4J-419:
------------------------------

Ok, if you don't understand the topic let's try it the other way round. How to 
solve the following problem:

 

I have a Java library that can also be used stand-alone as program. 

This library/program uses slf4j as logging system.

As it is a library it is strongly recommended not to add one of the SLF4J 
bindings as dependency to the library.

However this means that when the library is executed as program slf4j-api 
defaults to the NopLoggerFactory and all logging is disabled which is a serious 
problem.

Please describe the solution to solve this situation.

 

> Make it possible to use a low priority LoggerFactory that is replaced in case 
> a real slf4-implementation is available
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: SLF4J-419
>                 URL: https://jira.qos.ch/browse/SLF4J-419
>             Project: SLF4J
>          Issue Type: Improvement
>          Components: Core API
>            Reporter: Jan S.
>            Assignee: SLF4J developers list
>
> The current implementation of slf4j-api defaults to the NOP_FALLBACK_FACTORY. 
> This behavior can not be changed which is a severe problem for library 
> projects that also contain executable code:
> {quote}Note that embedded components such as libraries or frameworks should 
> not declare a dependency on any SLF4J binding but only depend on slf4j-api.
> {quote}
> because of this you can't link an slf4 implementation into it. Therefore code 
> that gets executed from within that project uses the NOP_FALLBACK_FACTORY 
> logger -> logging is disabled.
>  
> I understand why slf4j-api does not contain a standard logger to System.out 
> or System.err. But why is the NOP_FALLBACK_FACTORY hard-coded? 
> slf4j-api requires to have a possibility to define a LoggerFactory that is 
> different to the default NOPLoggerFactory that will be used in case no other 
> slf4j implementation is available.
>  
> There my request is to make it possible to define "a low priority 
> LoggerFactory" that is replaced in case a real slf4-implementation is 
> available. 
> One possible way would be to allow modify LoggerFactory.NOP_FALLBACK_FACTORY 
> directly or indirectly.
> A second possibility would be to create some sort of marker (e.g. an 
> Annotation) for an org.slf4j.impl.StaticLoggerBinder implementation that 
> defines "this implementation should only be used if no other implementation 
> can be found.
>  
>  



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)
_______________________________________________
slf4j-dev mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/slf4j-dev

Reply via email to