1

I am in process of creating a library code in scala that would be used by a number of different applications. I did research and found that right approach for logging is to use a facade like slf4j. I also found that we have 'scala-logging' library available which wraps around slf4j logger beneath. However it needs some logging backend like 'logback' to actually print the logs.

Now my question is if I include the logback dependency in my library codebase so that while coding I can check my own logs but also provide the library user the flexibility to use their own preferred logging framework, then how can I achieve that as now I have used a particular implementation of logging framework in my code?

Should I just scope the 'logback' dependency to 'Test' and is there any other way to do so?

KaustubhN
  • 195
  • 1
  • 2
  • 11
  • 1
    The idea of a facade is that it doesn't do anything until you inject a real backend, and the idea of using a facade instead of a proper logging library is to let users use the logging library they want. So, if you include logback then you are not doing anything. If you want to see logs during tests add logback just for tests so when you publish the library it is not included as a transitive dependency. – Luis Miguel Mejía Suárez Mar 18 '21 at 13:25

0 Answers0