How to use the LoggerUIService


I am trying to use the LoggerUIService to redirect the UI logs to my defined logger instead of the console.

What I tried to do is create the following file: {myProject}/src/main/resources/META-INF/services/liquibase.ui.UIService

Inside this file, I added the following line: liquibase.ui.LoggerUIService in the hope that it will use the LoggerUIService instead of the ConsoleUIService.

However, this did not work.

Can anyone help me understand how I can use the LoggerUIService?

Thank you !!

Are you looking to use that in the CLI application? Or are you setting up liquibase within your application somehow?


Hello @nvoxland,

I think it’s more like the latter, i.e setting up liquibase within my application.

In the getCurrentScope() method, I can see where we can overwrite the logger or service locator with the biggest priorities. However, it doesn’t look like we can do the same for the UI service.
Am I wrong ?

Thank you for your time and help!

You are right, that is something we need to improve. There are a few services (logging, service lookup, etc.) which get tricky to bootstrap and UIService is one of them. Currently working on it in a branch, though.

But, your best route is to just replace the UIService in the scope for your code.

If you run something like

Scope.child(Scope.Attr.ui, new LoggingUIService(), () -> {
    .... your code ...

then everything within that scope.child will use the other UIService.

The scope class acts like a “smart global variable” system, and the UI gets looked up off that right now.


Okay understood!

Thank you very much :smiley: