https://kotlinlang.org logo
#exposed
Title
# exposed
m

Marcin Wisniowski

05/22/2018, 3:56 PM
Ok,
logger.removeLogger(Slf4jSqlLogger)
seems to work, but only for one transaction when put into that transaction.
a

Allan Wang

05/22/2018, 4:02 PM
You can create your own extension function to configure the original transaction to your liking. It'll also be easier to change things in the future since everything is in one function
m

Marcin Wisniowski

05/22/2018, 4:05 PM
Where do I start with doing that?
a

Allan Wang

05/22/2018, 4:10 PM
Something like this
Copy code
fun <T> transaction(statement: Transaction.() -> T): T = org.jetbrains.exposed.sql.transactions.transaction {
    logger.removeLogger(Slf4jSqlLogger)
    statement()
}
Though you need to make sure you call your own transaction. You can change the name if you'd like it to be explicit. You may also look into slf4j configs and exclude the exposed packages. I use log4j2 and I don't see any sql statement outputs by default
m

Marcin Wisniowski

05/22/2018, 4:12 PM
Ah, this way, makes sense. How do you not use slf4j if you are using something else? Because I certainly never wanted it and it came with Exposed.
a

Allan Wang

05/22/2018, 4:14 PM
I'm not entirely familiar with slf4j and all the logging libraries. From what I understand, it's just an interface to allow you to bind to the logging framework of your choice. I also don't have any unwanted output unless I specify stdout, so perhaps we have different configurations?
m

Marcin Wisniowski

05/22/2018, 4:22 PM
All right, I managed to set the log level of the logger to something that doesn't output DEBUG messages in slf4j and the SQL queries are gone. Thanks for your help.
9 Views