can i define a custom logger for ktor ? specifical...
# ktor
n
can i define a custom logger for ktor ? specifically on native i would like to make this align:

https://nikky.catgirl.host/i/x00fif8f.png

it seems like i will have to copy the
embeddedServer
call chain and add a custom
KtorSimpleLogger
implementation
a
You can create an instance of a
NativeApplicationEngineEnvironment
and pass it as the
environment
argument in the
embeddedServer
call. Here is an example:
Copy code
embeddedServer(
    CIO,
    NativeApplicationEngineEnvironment(
        log = logger,
        config = MapApplicationConfig(),
        connectors = mutableListOf(EngineConnectorBuilder().apply {
            port = 9090
        }),
        modules = mutableListOf({
            routing {
                get("/") {
                    call.respondText { "Hello" }
                }
            }
        }),
        parentCoroutineContext = EmptyCoroutineContext,
        rootPath = "/",
        developmentMode = false
    )
) {
    
}.start(wait = true)
n
thanls for the hint, i condensed it down to this code which seems to do what i want..
Copy code
server = embeddedServer(
    factory = CIO,
    environment = applicationEngineEnvironment {
        log = KtorKLogger()
        connectors += EngineConnectorBuilder().apply {
            host = serverOptions.host
            port = serverOptions.port
        }
        module {
            configureHTTP()
            configureRouting()
        }
    }
)
server.start(wait = false)
a
Yeah, that's better.