Anders Kreinøe
Anders Kreinøe

Reputation: 1054

How to convert a Akka LoggingAdapter to a SLF4J Logger

I am using akka LoggingAdapter instances inside my actors to log, but i have some library code that i am calling from an actor, that takes a SLF4J Logger instance as parameter.

Is there an easy way to convert or wrap the LoggingAdapter, so that i can pass it to the library code as a SLF4J Logger.

I could write such a wrapper by hand, but i think it sounds like a pretty normal use case, so I thought that there mayby is a way to do this already, that I just had no luck finding.

Upvotes: 2

Views: 807

Answers (2)

Anders Kreinøe
Anders Kreinøe

Reputation: 1054

I ended up creating a wrapper class, that implements the Slf4j Logger interface, and delegates all calls to a wrapped LoggingAdapter. The class can be found in this project on bitbucket

Upvotes: 1

Dragisa Krsmanovic
Dragisa Krsmanovic

Reputation: 596

You can always create a slf4j logger with

   Logger logger = LoggerFactory.getLogger(Foo.class);

and pass it to your library. Regardless if you use Akka slf4j logger or not.

Upvotes: 0

Related Questions