From mendix docs TRACE level logging of one of these depending on what you need should do it
DataStorage_QueryHandling
Logsmessages related to the queries that are being executed.
QueryParser
Logs messages related to the parsing or interpretation of XPath and OQL queries.
DataStorage_QueryPlan
Queryexecution plan information for installations (currently only supported for PostgreSQL databases)
If you are running postgres and have access to the database I found it easier to just turn on logging in postgres
Also in mendix cloud LogMinDurationQuery custom aetting can be used to log queries longer than X seconds