Logging in Ktor

    If you don’t add a logging provider, you will see thefollowing message when you run your application:

    We can set up logging to remove these warning messages and geta better idea of what is happening with the app by adding a provider.

    Providers use Java’s mechanism,and so are discovered and added automatically without having to do anythingelse by code.

    Gradle’s or build.gradle.kts:

    Mavens’s pom.xml:

    Once added, run the app, and you should now see the logging messagesin the Run pane of IDEA. However, these logging messages are not ashelpful as they could be.

    Configuring the Logback provider

    logback.xml

    After it is added, if you stop your app, and run it again, after goingto localhost:8080 in your browser, you should see a log message now in the IDEA run pane, something like:

    You can install the feature to catch and log requests.

    Accessing the main logger

    The ApplicationEnvironment interface has a log property.You can access it inside an with call.application.environment.log.