I am using the following code in pyqgis to catch errors/warning from a WMS-layer, in order to trigger a repaint as soon as an error/warning is detected (based on previous question: How to catch WMS error message from log messages panel in QGIS with python?)

But obviously the "WMS" provider seems to have a restriction of not sending more than 100 error requests to the messages log, meaning after the 100th error/warning I´m no longer able to catch any signal, even if the WMS-layer is still not responding correctly. Nevertheless, if I send own messages to the log panel there does not seem to be any restriction (see code below).

Is there a possibility to catch the error/warning directly from the instance that is responsible here (I guess it is the WMS-provider), instead of using the messages log panel? Or maybe just clear/reset the log messages panel in a running process or remove the limitation?

I am using QGIS 2.18.2 on Windows 10.

Here is the python code:

# coding=utf-8

from qgis.core import *

url_with_params ='url=http://sg.geodatenzentrum.de/wms_dtk50?&crs=EPSG:25832&featureCount=10&format=image/png&layers=DTK50&styles='

wmsLayer = QgsRasterLayer(url_with_params, wmsLayer_name,'wms')

def errorCatcher( msg, tag, level ):
    if tag == 'WMS' and level != 0:     #Warnings or Errors (0: Info, 1:Warning, 2:Error)
        print "WMS error detected!"
        myWMSLayer = QgsMapLayerRegistry.instance().mapLayersByName("wms-dtk50_wgs")[0]

# connect with messageReceived SIGNAL from QgsMessageLog to an errorCatcher custom function
# instantly reacts if error/warning occurs
QgsMessageLog.instance().messageReceived.connect( errorCatcher )

#after 100 times triggering a "wmsLayer.triggerRepaint()", 
# I get following warning in log messages panel "WMS":
# "2017-01-17T07:17:52  1   Not logging more than 100 request errors."

#this does not raise any issues and prints all 500 test messages in the log panel:
for i in range(500):
    QgsMessageLog.instance().logMessage("Message #{}".format(i),"Test",2)

enter image description here

UPDATE: I submitted a feature request (see: https://hub.qgis.org/issues/16168)

  • 1
    The limit seems to be hard-wired in qgswmsprovider class in the C++ code. Is compiling QGIS from source an option for you?
    – Steven Kay
    Commented Jan 26, 2017 at 22:06
  • @Steven Kay ah ok I see, there is the according section in the code...Unfortunately I have no experience in compiling from source. As soon as my code is running, I need to install QGIS on several machines. but if there is no other option I guess I have no choice...anyway thx for the hint!
    – ADorsch
    Commented Jan 27, 2017 at 7:17

1 Answer 1


Right now, the 100 limit is hard coded in the WMS provider. But QGIS is a wonderful open source project and you can submit a feature request to turn this limit into a configurable parameter.

Any developer can take this feature request and submit a new pull request to QGIS. If the solution is accepted, core developers will be happy to apply the changes both for the upcoming version 3 and for the current 2.14.x and 2.18.x versions.

So, the answer your question is a new feature request submission to QGIS.

  • Ok thx for that advice. Though I was hoping to get some kind of workaround ideas, I guess this is as much of an answer as I will probably get. So I would have to either consider compiling from source by manipulating the source code or submit a feature request and hope that there might be a solution implemented in the future...
    – ADorsch
    Commented Feb 1, 2017 at 6:29
  • If you prepare and submit a feature request, you are helping others in future that will face the same limitation. You are returning something useful back to the community. While you can fix the 100 limitation by changing it to 5000 or 10000, developers will try to attend your request in a way that is suitable for all, not just for you, keeping the code consistent and the documentation updated. By submitting a feature request, you are contributing to improve QGIS. After the feature request is accept and the pull request is merged, you can install and use the nightly builds.
    – jgrocha
    Commented Feb 1, 2017 at 10:35
  • Absolutely, I´m with you here! Thx for your your statement, pointing out, that such an successful open source tool like QGIS is based on an active community what makes it so highly dynamic, and how everybody can contribute to this development.
    – ADorsch
    Commented Feb 3, 2017 at 6:00
  • I will prepare a feature request by the way!
    – ADorsch
    Commented Feb 3, 2017 at 6:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.