Exposed: How to optionally disable logging in using DSL API

Created on 1 May 2019  路  3Comments  路  Source: JetBrains/Exposed

Hi,

I am using KTOR as my web framework and using default SLF4J for logging,
how can I disable exposed logging whenever I perform a query to DB using DSL API?

waiting for reply

Most helpful comment

@blackmo18 It seems that you just need to configure your logger framework. I am using logback too, and this logback.xml resource below worked for me. HTH.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <!-- ... appender config, up to you ... -->
    </appender>

    <!-- Set Exposed logger on INFO level  -->
    <logger name="Exposed" level="info" additivity="false">
        <appender-ref ref="STDOUT"/>
    </logger>

    <!-- Set root logger on another level  -->
    <root level="debug">
        <appender-ref ref="STDOUT"/>
    </root>

</configuration>

All 3 comments

@blackmo18, what kind of logging do you want to suppress? Could you provide an example message?

@Tapac sorry for the late reply

here is my setup of Gradle dependencies and I'm using your SQL DSL API

//-- ktor
implementation "io.ktor:ktor-server-core:$ktor_version"
implementation "io.ktor:ktor-server-netty:$ktor_version"

//-- logging: Logback provider
implementation "ch.qos.logback:logback-classic:1.2.3"

//-- exposed "
implementation org.jetbrains.exposed:exposed:0.13.6"

for example, I call an API succesfully:
localhost:port/home/player/find-one-by-id?id=1

on the logs it displays
DEBUG Exposed - SELECT player.id, player.external_id...FROM player WHERE player.id = 1

where I supposed I only wanted to display on the logs is that this API is called successfully or whatever the result. This happens whenever any query is performed via SQL DSL

@blackmo18 It seems that you just need to configure your logger framework. I am using logback too, and this logback.xml resource below worked for me. HTH.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <!-- ... appender config, up to you ... -->
    </appender>

    <!-- Set Exposed logger on INFO level  -->
    <logger name="Exposed" level="info" additivity="false">
        <appender-ref ref="STDOUT"/>
    </logger>

    <!-- Set root logger on another level  -->
    <root level="debug">
        <appender-ref ref="STDOUT"/>
    </root>

</configuration>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

raderio picture raderio  路  4Comments

junhwong picture junhwong  路  3Comments

mgmeiner picture mgmeiner  路  3Comments

gcscaglia picture gcscaglia  路  3Comments

power721 picture power721  路  3Comments