Thanks a lot for your reply Chris

From: slf4j-user [mailto:[email protected]] On Behalf Of Chris Pratt
Sent: Wednesday, February 22, 2017 5:41 PM
To: User list for the slf4j project
Subject: Re: [slf4j-user] Question on SLF4J - binding

That is EXACTLY what SLF4j is there for.  You call the SLF4j API front-end and 
leave the decision about what logging engine up to whoever writes the main 
program.

In the example from your first message:
Application used by client A: would have to do nothing, but they would never 
see any output from your logging statements.
Application used by client B: would add slf4j-log4j.jar to their application 
and all your logging statements would show up in their normal logs (depending 
on how they configured the logging for your package)
Application used by client C: would add slf4j-jul.jar to their application and 
all your logging statements would show up in their normal logs (depending on 
how they configured the logging for your package)

You should not be using ANYTHING directly from the log4j-simple.jar file, only 
use things made public by log4j-api.jar and you will be fine.

As Joachim said, if you need to do testing on your library (a very good idea), 
that is when you would add the log4j-simple.jar to your test harness and the 
messages would magically appear in System.out.
  (*Chris*)

On Wed, Feb 22, 2017 at 2:05 PM, Chen, Richard - 2 
<[email protected]<mailto:[email protected]>> wrote:
Thanks for the reply, Jo.

The java library is developed by my team. Our java library doesn’t know about 
the main program (various clients applications). And the original goal for 
using SLF4J is logging for our java library, not for the main program(clients 
applications). I want to keep one version of our java library, in other words, 
having just one JAR file, (not multiple versions of JARs with different 
bindings). Is that possible?
And between the binding used in our java library and the logging framework used 
by a client's application, if they are different, will it cause any 
error/problem?
Thanks.



-----Original Message-----
From: slf4j-user 
[mailto:[email protected]<mailto:[email protected]>] On Behalf 
Of Joachim Durchholz
Sent: Wednesday, February 22, 2017 4:55 PM
To: [email protected]<mailto:[email protected]>
Subject: Re: [slf4j-user] Question on SLF4J - binding

On 22.02.2017 22<tel:22.02.2017%2022>:40, Chen, Richard - 2 wrote:
> Since I am bind to simple, I understand logging wouldn’t work, but
> will it cause any errors/issues for having it bind to simple?

Since the backend is a per-application decision, that decision should be made 
by the main program, not by any library (SLF4J was built specifically to allow 
libraries to do logging without committing to a specific backend).

If you want to see log output from your test code, then your test code should 
bind to a backend, yes.

That's why you typically add logging backends to the "test" scope in
Maven: These are used just during testing and not made part of the generated 
jar files.

HTH
Jo
_______________________________________________
slf4j-user mailing list
[email protected]<mailto:[email protected]>
http://mailman.qos.ch/mailman/listinfo/slf4j-user
----------------------------------------------------------------------
This message, and any attachments, is for the intended recipient(s) only, may 
contain information that is privileged, confidential and/or proprietary and 
subject to important terms and conditions available at 
http://www.bankofamerica.com/emaildisclaimer.   If you are not the intended 
recipient, please delete this message.
_______________________________________________
slf4j-user mailing list
[email protected]<mailto:[email protected]>
http://mailman.qos.ch/mailman/listinfo/slf4j-user


----------------------------------------------------------------------
This message, and any attachments, is for the intended recipient(s) only, may 
contain information that is privileged, confidential and/or proprietary and 
subject to important terms and conditions available at 
http://www.bankofamerica.com/emaildisclaimer.   If you are not the intended 
recipient, please delete this message.
_______________________________________________
slf4j-user mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/slf4j-user

Reply via email to