[4.1] Add getQueryLogState()

In reference to [#3600], now to 4.1 branch