-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdebugging.html
More file actions
1033 lines (982 loc) · 78.2 KB
/
debugging.html
File metadata and controls
1033 lines (982 loc) · 78.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Debugging MapServer — MapServer 8.6.1 documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../_static/sphinx.css?v=48f05237" />
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="../_static/custom.css?v=dd298242" />
<link rel="stylesheet" type="text/css" href="../_static/ribbon.css?v=ea091bf4" />
<script src="../_static/jquery.js?v=5d32c60e"></script>
<script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../_static/documentation_options.js?v=ad95d4c4"></script>
<script src="../_static/doctools.js?v=fd6eb6e6"></script>
<script src="../_static/sphinx_highlight.js?v=6ffebe34"></script>
<script src="../_static/clipboard.min.js?v=a7894cd8"></script>
<script src="../_static/copybutton.js?v=f281be69"></script>
<link rel="icon" href="../_static/mapserver.ico"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="copyright" title="Copyright" href="../copyright.html" />
<link rel="next" title="Environment Variables" href="environment_variables.html" />
<link rel="prev" title="Optimization" href="index.html" />
</head><body>
<!-- for main branch only, do not backport this -->
<table width="100%" style="width: 100%; background-color: white;">
<tr>
<td rowspan="2" style="padding: 10px 0px 10px 10px;">
<a href="../index.html" title="Home"><img src="../_static/banner.png" alt="MapServer banner" border="0" /></a>
</td>
<td style="padding: 10px 10px 0px 0px; text-align: right; vertical-align: top;">
<a href="../index.html" title="Home">Home</a> |
<a href="../products.html" title="Products (MapServer core, MapCache, TinyOWS">Products</a> |
<a href="https://github.com/mapserver/mapserver/issues/" title="Issue Tracker (MapServer core)">Issue Tracker</a> |
<a href="../community/service_providers.html" title="Professional Service Providers">Service Providers</a> |
<a href="../faq.html" title="Frequently Asked Questions">FAQ</a> |
<a href="https://fosstodon.org/@mapserver" title="Mastodon" target="_blank">Mastodon</a> |
<a href="../download.html" title="Download Source or Binaries">Download </a> |
<a class="badge" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KRJ2X44N3HA6U&source=url" target="_blank">
<img src="https://img.shields.io/badge/donate-%E2%9D%A4%C2%A0-ff69b4.svg?style=flat" alt="Donate to MapServer">
</a>
</td>
</tr>
<tr>
<td style="padding: 0px 10px 0px 0px; text-align: right; vertical-align: bottom;">
<img src="../_static/flagicons/en.png" alt="en" title="en" border="0" width="18px" height="13px"/>
<a href="../ar/optimization/debugging.html"><img src="../_static/flagicons/ar.png" alt="ar" title="ar" border="0" /></a>
<a href="../de/optimization/debugging.html"><img src="../_static/flagicons/de.png" alt="de" title="de" border="0" /></a>
<a href="../el/optimization/debugging.html"><img src="../_static/flagicons/el.png" alt="el" title="el" border="0" /></a>
<a href="../es/optimization/debugging.html"><img src="../_static/flagicons/es.png" alt="es" title="es" border="0" /></a>
<a href="../fr/optimization/debugging.html"><img src="../_static/flagicons/fr.png" alt="fr" title="fr" border="0" /></a>
<a href="../id/optimization/debugging.html"><img src="../_static/flagicons/id.png" alt="id" title="id" border="0" /></a>
<a href="../it/optimization/debugging.html"><img src="../_static/flagicons/it.png" alt="it" title="it" border="0" /></a>
<a href="../ja/optimization/debugging.html"><img src="../_static/flagicons/ja.png" alt="ja" title="ja" border="0" /></a>
<a href="../nl_NL/optimization/debugging.html"><img src="../_static/flagicons/nl_NL.png" alt="nl_NL" title="nl_NL" border="0" /></a>
<a href="../pl/optimization/debugging.html"><img src="../_static/flagicons/pl.png" alt="pl" title="pl" border="0" /></a>
<a href="../ru/optimization/debugging.html"><img src="../_static/flagicons/ru.png" alt="ru" title="ru" border="0" /></a>
<a href="../sq/optimization/debugging.html"><img src="../_static/flagicons/sq.png" alt="sq" title="sq" border="0" /></a>
<a href="../tr/optimization/debugging.html"><img src="../_static/flagicons/tr.png" alt="tr" title="tr" border="0" /></a>
</td>
</tr>
</table>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="environment_variables.html" title="Environment Variables"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="index.html" title="Optimization"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Home</a> »</li>
<li class="nav-item nav-item-1"><a href="../documentation.html" >MapServer 8.6.1 Documentation</a> »</li>
<li class="nav-item nav-item-2"><a href="index.html" accesskey="U">Optimization</a> »</li>
<li class="nav-item nav-item-this"><a href="">Debugging MapServer</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="debugging-mapserver">
<span id="debugging"></span><span id="index-0"></span><h1><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Debugging MapServer</a><a class="headerlink" href="#debugging-mapserver" title="Link to this heading">¶</a></h1>
<dl class="field-list simple">
<dt class="field-odd">Author<span class="colon">:</span></dt>
<dd class="field-odd"><p>Jeff McKenna</p>
</dd>
<dt class="field-even">Contact<span class="colon">:</span></dt>
<dd class="field-even"><p>jmckenna at gatewaygeomatics.com</p>
</dd>
<dt class="field-odd">Last Updated<span class="colon">:</span></dt>
<dd class="field-odd"><p>2025-10-05</p>
</dd>
</dl>
<nav class="contents" id="table-of-contents">
<p class="topic-title">Table of Contents</p>
<ul class="simple">
<li><p><a class="reference internal" href="#debugging-mapserver" id="id1">Debugging MapServer</a></p>
<ul>
<li><p><a class="reference internal" href="#introduction" id="id2">Introduction</a></p>
<ul>
<li><p><a class="reference internal" href="#links-to-related-information" id="id3">Links to Related Information</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#steps-to-enable-mapserver-debugging" id="id4">Steps to Enable MapServer Debugging</a></p>
<ul>
<li><p><a class="reference internal" href="#step-1-set-the-ms-errorfile-variable" id="id5">Step 1: Set the MS_ERRORFILE Variable</a></p></li>
<li><p><a class="reference internal" href="#step-2-set-the-debug-level" id="id6">Step 2: Set the DEBUG Level</a></p></li>
<li><p><a class="reference internal" href="#step-3-turn-on-cpl-debug-optional" id="id7">Step 3: Turn on CPL_DEBUG (optional)</a></p></li>
<li><p><a class="reference internal" href="#step-4-turn-on-proj-debug-optional" id="id8">Step 4: Turn on PROJ_DEBUG (optional)</a></p></li>
<li><p><a class="reference internal" href="#step-5-test-your-mapfile" id="id9">Step 5: Test your Mapfile</a></p></li>
<li><p><a class="reference internal" href="#step-6-check-your-web-server-logs" id="id10">Step 6: Check your Web Server Logs</a></p></li>
<li><p><a class="reference internal" href="#step-7-verify-your-application-settings" id="id11">Step 7: Verify your Application Settings</a></p></li>
<li><p><a class="reference internal" href="#step-8-use-qgis-to-test-your-ogc-services" id="id12">Step 8: Use QGIS to test your OGC services</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#debugging-mapserver-using-compiler-debugging-tools" id="id13">Debugging MapServer using Compiler Debugging Tools</a></p>
<ul>
<li><p><a class="reference internal" href="#running-mapserver-in-gdb-linux-unix" id="id14">Running MapServer in GDB (Linux/Unix)</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#debugging-older-versions-of-mapserver-before-5-0" id="id15">Debugging Older Versions of MapServer (before 5.0)</a></p></li>
</ul>
</li>
</ul>
</nav>
<section id="introduction">
<h2><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Introduction</a><a class="headerlink" href="#introduction" title="Link to this heading">¶</a></h2>
<p>When developing an application for the Internet, you will inevitably
across problems many problems in your environment. The goal of this
guide is to assist you with locating the problem with your MapServer
application.</p>
<section id="links-to-related-information">
<h3><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Links to Related Information</a><a class="headerlink" href="#links-to-related-information" title="Link to this heading">¶</a></h3>
<ul class="simple">
<li><p><a class="reference internal" href="../development/rfc/ms-rfc-28.html#rfc28"><span class="std std-ref">RFC 28: Redesign of LOG/DEBUG output mechanisms</span></a></p></li>
<li><p><a class="reference internal" href="../errors.html#errors"><span class="std std-ref">MapServer Errors</span></a></p></li>
</ul>
</section>
</section>
<section id="steps-to-enable-mapserver-debugging">
<h2><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Steps to Enable MapServer Debugging</a><a class="headerlink" href="#steps-to-enable-mapserver-debugging" title="Link to this heading">¶</a></h2>
<p>Starting with MapServer 5.0, you are able to control the levels of
debugging/logging information returned to you by MapServer, and also
control the location of the output log file.</p>
<p>In technical terms, there are msDebug() calls in various areas of the
MapServer code that generate information that may be useful in tuning
and troubleshooting applications.</p>
<section id="step-1-set-the-ms-errorfile-variable">
<span id="index-1"></span><h3><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Step 1: Set the MS_ERRORFILE Variable</a><a class="headerlink" href="#step-1-set-the-ms-errorfile-variable" title="Link to this heading">¶</a></h3>
<p>The <strong>MS_ERRORFILE</strong> variable is used to specify the output of debug
messages from MapServer. You can pass the following values to
<strong>MS_ERRORFILE</strong>:</p>
<dl>
<dt><strong>[filename]</strong></dt><dd><p>Full path and filename of a log file, to contain MapServer’s debug
messages. Any file extension can be used, but <em>.log</em> or <em>.txt</em> is
recommended. The file will be created, if it does not already
exist.</p>
<p>Starting with MapServer 6.0, a filename with relative path can be passed
via the CONFIG MS_ERRORFILE directive, in which case the filename is
relative to the mapfile location. Note that setting MS_ERRORFILE via an
environment variable always requires an absolute path since there would
be no mapfile to make the path relative to.</p>
<p>Note that on Linux, if your are using a path from the <cite>/tmp</cite> directory
like <cite>/tmp/ms_error.txt</cite>, the log will actually output in
(<a class="reference external" href="https://systemd.io/TEMPORARY_DIRECTORIES/">private directory provided by systemd</a>)
generated for the web server used (like Apache).</p>
</dd>
<dt><strong>stderr</strong></dt><dd><p>Use this to send MapServer’s debug messages to the Web server’s log
file (i.e. “standard error”). If you are using Apache, your debug
messages will be placed in the Apache <em>error_log</em> file. If you are
using Microsoft IIS, your debug messages will be sent to <em>stdout</em>
(i.e. the browser), so its use is discouraged. With IIS it is
recommended to direct output to a file instead.</p>
</dd>
<dt><strong>stdout</strong></dt><dd><p>Use this to send MapServer’s debug messages to the standard output
(i.e. the browser), combined with the rest of MapServer’s output.</p>
</dd>
<dt><strong>windowsdebug</strong></dt><dd><p>Use this to send MapServer’s debug messages to the Windows
OutputDebugString API, allowing the use of external programs like
SysInternals debugview to display the debug output.</p>
</dd>
</dl>
<section id="through-the-mapfile">
<h4>Through the Mapfile<a class="headerlink" href="#through-the-mapfile" title="Link to this heading">¶</a></h4>
<p>The recommended way to set the <strong>MS_ERRORFILE</strong> variable is in your
mapfile, within the <a class="reference internal" href="../mapfile/map.html#map"><span class="std std-ref">MAP</span></a> object, such as:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">MAP</span>
<span class="p">...</span>
<span class="k">CONFIG</span> <span class="s">"MS_ERRORFILE"</span> <span class="s">"/ms4w/tmp/ms_error.txt"</span>
<span class="p">...</span>
<span class="k">LAYER</span>
<span class="p">...</span>
<span class="k">END</span>
<span class="k">END</span>
</pre></div>
</div>
</section>
<section id="through-an-environment-variable">
<h4>Through an Environment Variable<a class="headerlink" href="#through-an-environment-variable" title="Link to this heading">¶</a></h4>
<p>You can also set the <strong>MS_ERRORFILE</strong> variable as an environment
variable on your system. Apache users can set the environment
variable in Apache’s <em>httpd.conf</em> file, such as:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">SetEnv</span> <span class="n">MS_ERRORFILE</span> <span class="s2">"/ms4w/tmp/ms_error.txt"</span>
</pre></div>
</div>
<p>Windows users can alternatively set the environment variable through
the Windows System Properties; but make sure to set a SYSTEM
environment variable.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>If both the <em>MS_ERRORFILE</em> environment variable is set and a
<em>CONFIG MS_ERRORFILE</em> is also set, then the CONFIG directive takes
precedence.</p>
</div>
</section>
</section>
<section id="step-2-set-the-debug-level">
<span id="index-2"></span><h3><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Step 2: Set the DEBUG Level</a><a class="headerlink" href="#step-2-set-the-debug-level" title="Link to this heading">¶</a></h3>
<p>You can retrieve varying types of debug messages by setting the
<em>DEBUG</em> parameter in the <a class="reference internal" href="../mapfile/index.html#mapfile"><span class="std std-ref">Mapfile</span></a>. You can place the <em>DEBUG</em>
parameter in any LAYER in the mapfile for layer-specific debug information,
or instead, set it once in the MAP object to get general debug information.
Use the value of the <em>DEBUG</em> parameter to set the type of information
returned, as follows:</p>
<section id="debug-levels">
<h4>DEBUG Levels<a class="headerlink" href="#debug-levels" title="Link to this heading">¶</a></h4>
<dl>
<dt><strong>Level 0</strong></dt><dd><p>Errors only (DEBUG OFF, or DEBUG 0)</p>
<p>In level 0, only msSetError() calls are logged to MS_ERORFILE. No
msDebug() output at all. This is the default and corresponds to the
original behavior of MS_ERRORFILE in MapServer 4.x</p>
</dd>
<dt><strong>Level 1</strong></dt><dd><p>Errors and Notices (DEBUG ON, or DEBUG 1)</p>
<p>Level 1 includes all output from Level 0 plus msDebug() warnings
about common pitfalls, failed assertions or non-fatal error
situations (e.g. missing or invalid values for some parameters,
missing shapefiles in tileindex, timeout error from remote WMS/WFS
servers, etc.)</p>
</dd>
<dt><strong>Level 2</strong></dt><dd><p>Map Tuning (DEBUG 2)</p>
<p>Level 2 includes all output from Level 1 plus notices and timing
information useful for tuning mapfiles and applications. <em>this is
the recommended minimal debugging level</em></p>
</dd>
<dt><strong>Level 3</strong></dt><dd><p>Verbose Debug (DEBUG 3)</p>
<p>All of Level 2 plus some debug output useful in troubleshooting
problems such as WMS connection URLs being called, database
connection calls, etc.</p>
</dd>
<dt><strong>Level 4</strong></dt><dd><p>Very Verbose Debug (DEBUG 4)</p>
<p>Level 3 plus even more details…</p>
</dd>
<dt><strong>Level 5</strong></dt><dd><p>Very Very Verbose Debug (DEBUG 5)</p>
<p>Level 4 plus any msDebug() output that might be more useful to
developers than to users.</p>
</dd>
</dl>
</section>
<section id="mapfile-example-map-level-debug">
<h4>Mapfile Example: Map-Level Debug<a class="headerlink" href="#mapfile-example-map-level-debug" title="Link to this heading">¶</a></h4>
<p>The following example is the recommended method to set the <em>DEBUG</em> parameter
for the map-level:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">MAP</span>
<span class="p">...</span>
<span class="k">CONFIG</span> <span class="s">"MS_ERRORFILE"</span> <span class="s">"/ms4w/tmp/ms_error.txt"</span>
<span class="k">DEBUG</span> <span class="mi">5</span>
<span class="p">...</span>
<span class="k">LAYER</span>
<span class="p">...</span>
<span class="k">END</span>
<span class="k">END</span>
</pre></div>
</div>
</section>
<section id="mapfile-example-layer-level-debug">
<span id="index-3"></span><h4>Mapfile Example: Layer-Level Debug<a class="headerlink" href="#mapfile-example-layer-level-debug" title="Link to this heading">¶</a></h4>
<p>The following example is the recommended method to set the <em>DEBUG</em> parameter
for a layer:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">MAP</span>
<span class="p">...</span>
<span class="k">CONFIG</span> <span class="s">"MS_ERRORFILE"</span> <span class="s">"/ms4w/tmp/ms_error.txt"</span>
<span class="p">...</span>
<span class="k">LAYER</span>
<span class="k">DEBUG</span> <span class="mi">5</span>
<span class="p">...</span>
<span class="k">END</span>
<span class="k">END</span>
</pre></div>
</div>
</section>
<section id="the-ms-debuglevel-environment-variable">
<span id="index-4"></span><h4>The MS_DEBUGLEVEL Environment Variable<a class="headerlink" href="#the-ms-debuglevel-environment-variable" title="Link to this heading">¶</a></h4>
<p>Instead of setting the <em>DEBUG</em> Debug level in each of your mapfiles,
you can also be set the level globally by using the <em>MS_DEBUGLEVEL</em>
environment variable.</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>Although setting the MS_DEBUGLEVEL environment variable is possible,
it is strongly encouraged to set DEBUG inside your mapfile for the map,
layer, or class objects instead.</p>
</div>
<p>When set, this value is used as the default debug level value for all
map and layer objects as they are loaded by the mapfile parser. This
option also sets the debug level for any msDebug() call located
outside of the context of a map or layer object, for instance for
debug statements relating to initialization before a map is loaded. If
a DEBUG value is also specified in the mapfile in some map or layer
objects then the local value (in the mapfile) takes precedence over
the value of the environment variable; debug info coming from outside
of the context of a map or layer object cannot be turned off by
having DEBUG OFF in the mapfile.</p>
<p>Setting this option (<em>MS_DEBUGLEVEL</em>) is mostly useful when tuning
applications by enabling timing/debug output before the map is loaded,
to capture the full process initialization and map loading time,
for instance.</p>
<p>Apache users can set the environment variable in Apache’s <em>httpd.conf</em>
file, such as:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">SetEnv</span> <span class="n">MS_DEBUGLEVEL</span> <span class="mi">5</span>
</pre></div>
</div>
<p>Windows users can alternatively set the environment variable through
the Windows System Properties; but make sure to set a SYSTEM
environment variable.</p>
</section>
</section>
<section id="step-3-turn-on-cpl-debug-optional">
<span id="index-5"></span><h3><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Step 3: Turn on CPL_DEBUG (optional)</a><a class="headerlink" href="#step-3-turn-on-cpl-debug-optional" title="Link to this heading">¶</a></h3>
<p>MapServer relies on the <a class="reference external" href="https://gdal.org/">GDAL</a> library to
access most data layers, so you may wish to turn on GDAL debugging, to
hopefully get more information on how GDAL is accessing your data
file. This could be very helpful for problems with accessing raster
files and PostGIS tables. You can trigger this GDAL output by setting
the <strong>CPL_DEBUG</strong> variable in your mapfile, within the <a class="reference internal" href="../mapfile/map.html#map"><span class="std std-ref">MAP</span></a>
object, such as:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">MAP</span>
<span class="p">...</span>
<span class="k">CONFIG</span> <span class="s">"CPL_DEBUG"</span> <span class="s">"ON"</span>
<span class="p">...</span>
<span class="k">LAYER</span>
<span class="p">...</span>
<span class="k">END</span>
<span class="k">END</span>
</pre></div>
</div>
<p>You can also add a timestamp (a date/time on each line) to that report
with the <strong>CPL_TIMESTAMP</strong> variable, such as:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">MAP</span>
<span class="p">...</span>
<span class="k">CONFIG</span> <span class="s">"CPL_DEBUG"</span> <span class="s">"ON"</span>
<span class="k">CONFIG</span> <span class="s">"CPL_TIMESTAMP"</span> <span class="s">"ON"</span>
<span class="p">...</span>
<span class="k">LAYER</span>
<span class="p">...</span>
<span class="k">END</span>
<span class="k">END</span>
</pre></div>
</div>
<p>You can also add verbose output from the cURL library, which could be
very useful for debugging network-hosted layer connections through GDAL such as
<a class="reference external" href="https://gdal.org/user/virtual_file_systems.html">/vsicurl</a>
with the <strong>CPL_CURL_VERBOSE</strong> variable, such as:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">MAP</span>
<span class="p">...</span>
<span class="k">CONFIG</span> <span class="s">"CPL_DEBUG"</span> <span class="s">"ON"</span>
<span class="k">CONFIG</span> <span class="s">"CPL_CURL_VERBOSE"</span> <span class="s">"ON"</span>
<span class="p">...</span>
<span class="k">LAYER</span>
<span class="p">...</span>
<span class="k">END</span>
<span class="k">END</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="../input/virtual-file.html#virtual-file"><span class="std std-ref">Virtual File System Connections in MapServer</span></a></p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>For a list of GDAL’s possible variables to use, see the
GDAL official <a class="reference external" href="https://gdal.org/user/configoptions.html">list</a>.
The old <a class="reference external" href="https://web.archive.org/web/20220324035447/https://trac.osgeo.org/gdal/wiki/ConfigOptions">GDAL wiki</a>
is still a good source of information for these variables, even if outdated.</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="vector.html#debugging-postgis"><span class="std std-ref">Additional PostGIS debugging for MapServer</span></a></p>
</div>
</section>
<section id="step-4-turn-on-proj-debug-optional">
<span id="index-6"></span><h3><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Step 4: Turn on PROJ_DEBUG (optional)</a><a class="headerlink" href="#step-4-turn-on-proj-debug-optional" title="Link to this heading">¶</a></h3>
<p>MapServer relies on the <a class="reference external" href="https://proj.org/">PROJ</a>
library to handle data projections, so you may wish to turn on PROJ
debugging, to hopefully get more information back from the PROJ
library. You can trigger this PROJ output by setting the
<strong>PROJ_DEBUG</strong> variable in your mapfile, within the <a class="reference internal" href="../mapfile/map.html#map"><span class="std std-ref">MAP</span></a> object,
such as:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">MAP</span>
<span class="p">...</span>
<span class="k">CONFIG</span> <span class="s">"CPL_DEBUG"</span> <span class="s">"ON"</span>
<span class="k">CONFIG</span> <span class="s">"PROJ_DEBUG"</span> <span class="s">"ON"</span>
<span class="p">...</span>
<span class="k">LAYER</span>
<span class="p">...</span>
<span class="k">END</span>
<span class="k">END</span>
</pre></div>
</div>
<p>Since the PROJ 9.3.0 release, there are 4 levels that you can set to
increase the information returned from <cite>PROJ_DEBUG</cite>, such as:</p>
<dl class="simple">
<dt><strong>Level 0</strong></dt><dd><p>No message (PROJ_DEBUG 0)</p>
</dd>
<dt><strong>Level 1</strong></dt><dd><p>Error messages only (PROJ_DEBUG 1)</p>
</dd>
<dt><strong>Level 2</strong></dt><dd><p>Same as level 1, but with debug messages. Setting <cite>“PROJ_DEBUG” “ON”</cite>
is an alias to this level 2. (PROJ_DEBUG 2)</p>
</dd>
<dt><strong>Level 3</strong></dt><dd><p>Same as level 2, with verbose messages (PROJ_DEBUG 3)</p>
</dd>
<dt><strong>Level 4</strong></dt><dd><p>Same as level 3, with very verbose messages (PROJ_DEBUG 4)</p>
</dd>
</dl>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>You can set <em>“CPL_DEBUG” “PROJ”</em> to restrict the information returned to PROJ
(and not GDAL in general)</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>For the full list of possible PROJ variables to use see the
<a class="reference external" href="https://proj.org/usage/environmentvars.html">official list</a>.</p>
</div>
</section>
<section id="step-5-test-your-mapfile">
<h3><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Step 5: Test your Mapfile</a><a class="headerlink" href="#step-5-test-your-mapfile" title="Link to this heading">¶</a></h3>
<p>Once you have set the <em>MS_ERRORFILE</em> and <em>DEBUG</em> level in your
mapfile, you should now test your mapfile and read your generated log
file.</p>
<section id="using-map2img">
<span id="index-7"></span><h4>Using map2img<a class="headerlink" href="#using-map2img" title="Link to this heading">¶</a></h4>
<p>The recommended way to test your mapfile is to use the MapServer
commandline utility <a class="reference internal" href="../utilities/map2img.html#map2img"><span class="std std-ref">map2img</span></a>, to verify that your mapfile
creates a valid map image. <a class="reference internal" href="../utilities/map2img.html#map2img"><span class="std std-ref">map2img</span></a> should be included in your
MapServer installation (<a class="reference external" href="https://ms4w.com">MS4W</a> users
need to execute <em>setenv.bat</em> before using the utility).</p>
<p>You can set the <em>DEBUG</em> level by passing the <a class="reference internal" href="../utilities/map2img.html#map2img"><span class="std std-ref">map2img</span></a> following
parameters to your commandline call:</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>If you have already set <em>MS_ERRORFILE</em> in your mapfile, you must
comment this out in order to use these <a class="reference internal" href="../utilities/map2img.html#map2img"><span class="std std-ref">map2img</span></a> options</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>When using <a class="reference internal" href="../utilities/map2img.html#map2img"><span class="std std-ref">map2img</span></a> to debug, your layer’s STATUS should be
set to ON or DEFAULT. If the layer’s STATUS is set to OFF, you
must additionally pass the layer name to <a class="reference internal" href="../utilities/map2img.html#map2img"><span class="std std-ref">map2img</span></a> by using
the “<cite>-l layername</cite>” syntax</p>
</div>
<section id="all-debug">
<h5>-all_debug<a class="headerlink" href="#all-debug" title="Link to this heading">¶</a></h5>
<p>Use this setting to set the debug level for the MAP object and all
layers. <em>this is the recommended switch to use</em></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">map2img</span> <span class="o">-</span><span class="n">m</span> <span class="n">spain</span><span class="o">.</span><span class="n">map</span> <span class="o">-</span><span class="n">o</span> <span class="n">test</span><span class="o">.</span><span class="n">png</span> <span class="o">-</span><span class="n">all_debug</span> <span class="mi">5</span>
<span class="n">msLoadMap</span><span class="p">():</span> <span class="mf">0.002</span><span class="n">s</span>
<span class="n">msDrawMap</span><span class="p">():</span> <span class="n">Layer</span> <span class="mi">0</span> <span class="p">(</span><span class="n">spain</span> <span class="n">provinces</span><span class="p">),</span> <span class="mf">0.012</span><span class="n">s</span>
<span class="n">msDrawRasterLayerLow</span><span class="p">(</span><span class="n">orthophoto</span><span class="p">):</span> <span class="n">entering</span><span class="o">.</span>
<span class="n">msDrawGDAL</span><span class="p">():</span> <span class="n">src</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">3540</span><span class="p">,</span><span class="mi">2430</span><span class="p">,</span> <span class="n">dst</span><span class="o">=</span><span class="mi">188</span><span class="p">,</span><span class="mi">48</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span>
<span class="n">source</span> <span class="n">raster</span> <span class="n">PL</span> <span class="p">(</span><span class="o">-</span><span class="mf">793.394</span><span class="p">,</span><span class="o">-</span><span class="mf">1712.627</span><span class="p">)</span> <span class="k">for</span> <span class="n">dst</span> <span class="n">PL</span> <span class="p">(</span><span class="mi">188</span><span class="p">,</span><span class="mi">48</span><span class="p">)</span><span class="o">.</span>
<span class="n">msDrawGDAL</span><span class="p">():</span> <span class="n">red</span><span class="p">,</span><span class="n">green</span><span class="p">,</span><span class="n">blue</span><span class="p">,</span><span class="n">alpha</span> <span class="n">bands</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">0</span>
<span class="n">msDrawMap</span><span class="p">():</span> <span class="n">Layer</span> <span class="mi">1</span> <span class="p">(</span><span class="n">orthophoto</span><span class="p">),</span> <span class="mf">0.150</span><span class="n">s</span>
<span class="n">msDrawMap</span><span class="p">():</span> <span class="n">Layer</span> <span class="mi">2</span> <span class="p">(</span><span class="n">urban</span> <span class="n">areas</span><span class="p">),</span> <span class="mf">0.004</span><span class="n">s</span>
<span class="n">msDrawMap</span><span class="p">():</span> <span class="n">Layer</span> <span class="mi">3</span> <span class="p">(</span><span class="n">species</span> <span class="n">at</span> <span class="n">risk</span><span class="p">),</span> <span class="mf">0.008</span><span class="n">s</span>
<span class="n">msDrawMap</span><span class="p">():</span> <span class="n">Layer</span> <span class="mi">4</span> <span class="p">(</span><span class="n">populated</span> <span class="n">places</span><span class="p">),</span> <span class="mf">1.319</span><span class="n">s</span>
<span class="n">msDrawMap</span><span class="p">():</span> <span class="n">Drawing</span> <span class="n">Label</span> <span class="n">Cache</span><span class="p">,</span> <span class="mf">0.014</span><span class="n">s</span>
<span class="n">msDrawMap</span><span class="p">()</span> <span class="n">total</span> <span class="n">time</span><span class="p">:</span> <span class="mf">1.513</span><span class="n">s</span>
<span class="n">msSaveImage</span><span class="p">()</span> <span class="n">total</span> <span class="n">time</span><span class="p">:</span> <span class="mf">0.039</span><span class="n">s</span>
<span class="n">msFreeMap</span><span class="p">():</span> <span class="n">freeing</span> <span class="nb">map</span> <span class="n">at</span> <span class="mi">0218</span><span class="n">C1A8</span><span class="o">.</span>
<span class="n">freeLayer</span><span class="p">():</span> <span class="n">freeing</span> <span class="n">layer</span> <span class="n">at</span> <span class="mi">0218</span><span class="n">F5E0</span><span class="o">.</span>
<span class="n">freeLayer</span><span class="p">():</span> <span class="n">freeing</span> <span class="n">layer</span> <span class="n">at</span> <span class="mi">030</span><span class="n">C33A0</span><span class="o">.</span>
<span class="n">freeLayer</span><span class="p">():</span> <span class="n">freeing</span> <span class="n">layer</span> <span class="n">at</span> <span class="mi">030</span><span class="n">C3BC8</span><span class="o">.</span>
<span class="n">freeLayer</span><span class="p">():</span> <span class="n">freeing</span> <span class="n">layer</span> <span class="n">at</span> <span class="mi">030</span><span class="n">C4948</span><span class="o">.</span>
<span class="n">freeLayer</span><span class="p">():</span> <span class="n">freeing</span> <span class="n">layer</span> <span class="n">at</span> <span class="mi">030</span><span class="n">C7678</span><span class="o">.</span>
<span class="n">map2img</span> <span class="n">total</span> <span class="n">time</span><span class="p">:</span> <span class="mf">1.567</span><span class="n">s</span>
</pre></div>
</div>
</section>
<section id="map-debug">
<h5>-map_debug<a class="headerlink" href="#map-debug" title="Link to this heading">¶</a></h5>
<p>Use this setting to set the debug level for the MAP object only.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">map2img</span> <span class="o">-</span><span class="n">m</span> <span class="n">spain</span><span class="o">.</span><span class="n">map</span> <span class="o">-</span><span class="n">o</span> <span class="n">test</span><span class="o">.</span><span class="n">png</span> <span class="o">-</span><span class="n">map_debug</span> <span class="mi">5</span>
<span class="n">msDrawMap</span><span class="p">():</span> <span class="n">Layer</span> <span class="mi">0</span> <span class="p">(</span><span class="n">spain</span> <span class="n">provinces</span><span class="p">),</span> <span class="mf">0.012</span><span class="n">s</span>
<span class="n">msDrawRasterLayerLow</span><span class="p">(</span><span class="n">orthophoto</span><span class="p">):</span> <span class="n">entering</span><span class="o">.</span>
<span class="n">msDrawMap</span><span class="p">():</span> <span class="n">Layer</span> <span class="mi">1</span> <span class="p">(</span><span class="n">orthophoto</span><span class="p">),</span> <span class="mf">0.144</span><span class="n">s</span>
<span class="n">msDrawMap</span><span class="p">():</span> <span class="n">Layer</span> <span class="mi">2</span> <span class="p">(</span><span class="n">urban</span> <span class="n">areas</span><span class="p">),</span> <span class="mf">0.004</span><span class="n">s</span>
<span class="n">msDrawMap</span><span class="p">():</span> <span class="n">Layer</span> <span class="mi">3</span> <span class="p">(</span><span class="n">species</span> <span class="n">at</span> <span class="n">risk</span><span class="p">),</span> <span class="mf">0.008</span><span class="n">s</span>
<span class="n">msDrawMap</span><span class="p">():</span> <span class="n">Layer</span> <span class="mi">4</span> <span class="p">(</span><span class="n">populated</span> <span class="n">places</span><span class="p">),</span> <span class="mf">1.323</span><span class="n">s</span>
<span class="n">msDrawMap</span><span class="p">():</span> <span class="n">Drawing</span> <span class="n">Label</span> <span class="n">Cache</span><span class="p">,</span> <span class="mf">0.013</span><span class="n">s</span>
<span class="n">msDrawMap</span><span class="p">()</span> <span class="n">total</span> <span class="n">time</span><span class="p">:</span> <span class="mf">1.511</span><span class="n">s</span>
<span class="n">msSaveImage</span><span class="p">()</span> <span class="n">total</span> <span class="n">time</span><span class="p">:</span> <span class="mf">0.039</span><span class="n">s</span>
<span class="n">msFreeMap</span><span class="p">():</span> <span class="n">freeing</span> <span class="nb">map</span> <span class="n">at</span> <span class="mi">0205</span><span class="n">C1A8</span><span class="o">.</span>
</pre></div>
</div>
</section>
<section id="layer-debug">
<h5>-layer_debug<a class="headerlink" href="#layer-debug" title="Link to this heading">¶</a></h5>
<p>Use this setting to set the debug level for one layer object only.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">map2img</span> <span class="o">-</span><span class="n">m</span> <span class="n">spain</span><span class="o">.</span><span class="n">map</span> <span class="o">-</span><span class="n">o</span> <span class="n">test</span><span class="o">.</span><span class="n">png</span> <span class="o">-</span><span class="n">layer_debug</span> <span class="n">orthophoto</span> <span class="mi">5</span>
<span class="n">msDrawRasterLayerLow</span><span class="p">(</span><span class="n">orthophoto</span><span class="p">):</span> <span class="n">entering</span><span class="o">.</span>
<span class="n">msDrawGDAL</span><span class="p">():</span> <span class="n">src</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">3540</span><span class="p">,</span><span class="mi">2430</span><span class="p">,</span> <span class="n">dst</span><span class="o">=</span><span class="mi">188</span><span class="p">,</span><span class="mi">48</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span>
<span class="n">source</span> <span class="n">raster</span> <span class="n">PL</span> <span class="p">(</span><span class="o">-</span><span class="mf">793.394</span><span class="p">,</span><span class="o">-</span><span class="mf">1712.627</span><span class="p">)</span> <span class="k">for</span> <span class="n">dst</span> <span class="n">PL</span> <span class="p">(</span><span class="mi">188</span><span class="p">,</span><span class="mi">48</span><span class="p">)</span><span class="o">.</span>
<span class="n">msDrawGDAL</span><span class="p">():</span> <span class="n">red</span><span class="p">,</span><span class="n">green</span><span class="p">,</span><span class="n">blue</span><span class="p">,</span><span class="n">alpha</span> <span class="n">bands</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">0</span>
<span class="n">msDrawMap</span><span class="p">():</span> <span class="n">Layer</span> <span class="mi">1</span> <span class="p">(</span><span class="n">orthophoto</span><span class="p">),</span> <span class="mf">0.151</span><span class="n">s</span>
<span class="n">freeLayer</span><span class="p">():</span> <span class="n">freeing</span> <span class="n">layer</span> <span class="n">at</span> <span class="mi">02</span><span class="n">F23390</span><span class="o">.</span>
</pre></div>
</div>
</section>
<section id="set-cpl-debug">
<h5>Set CPL_DEBUG<a class="headerlink" href="#set-cpl-debug" title="Link to this heading">¶</a></h5>
<p>At the commandline execute the following:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">set</span> <span class="n">CPL_DEBUG</span><span class="o">=</span><span class="n">ON</span>
<span class="n">map2img</span> <span class="o">-</span><span class="n">m</span> <span class="n">spain</span><span class="o">.</span><span class="n">map</span> <span class="o">-</span><span class="n">o</span> <span class="n">test</span><span class="o">.</span><span class="n">png</span> <span class="o">-</span><span class="n">layer_debug</span> <span class="n">orthophoto</span> <span class="mi">5</span>
<span class="n">msDrawRasterLayerLow</span><span class="p">(</span><span class="n">orthophoto</span><span class="p">):</span> <span class="n">entering</span><span class="o">.</span>
<span class="n">GDAL</span><span class="p">:</span> <span class="n">GDALOpen</span><span class="p">(</span><span class="n">D</span><span class="p">:</span>\<span class="n">ms4w</span>\<span class="n">apps</span>\<span class="n">spain</span>\<span class="nb">map</span><span class="o">/.</span>\<span class="o">../</span><span class="n">data</span><span class="o">/</span><span class="n">ov172068_200904_c100u50x75c24n</span><span class="o">.</span><span class="n">jpg</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="mi">0</span>
<span class="mi">4059840</span><span class="p">)</span> <span class="n">succeeds</span> <span class="k">as</span> <span class="n">JPEG</span><span class="o">.</span>
<span class="n">msDrawGDAL</span><span class="p">():</span> <span class="n">src</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">3540</span><span class="p">,</span><span class="mi">2430</span><span class="p">,</span> <span class="n">dst</span><span class="o">=</span><span class="mi">188</span><span class="p">,</span><span class="mi">48</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span>
<span class="n">source</span> <span class="n">raster</span> <span class="n">PL</span> <span class="p">(</span><span class="o">-</span><span class="mf">793.394</span><span class="p">,</span><span class="o">-</span><span class="mf">1712.627</span><span class="p">)</span> <span class="k">for</span> <span class="n">dst</span> <span class="n">PL</span> <span class="p">(</span><span class="mi">188</span><span class="p">,</span><span class="mi">48</span><span class="p">)</span><span class="o">.</span>
<span class="n">msDrawGDAL</span><span class="p">():</span> <span class="n">red</span><span class="p">,</span><span class="n">green</span><span class="p">,</span><span class="n">blue</span><span class="p">,</span><span class="n">alpha</span> <span class="n">bands</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">0</span>
<span class="n">GDAL</span><span class="p">:</span> <span class="n">GDALDefaultOverviews</span><span class="p">::</span><span class="n">OverviewScan</span><span class="p">()</span>
<span class="n">msDrawMap</span><span class="p">():</span> <span class="n">Layer</span> <span class="mi">1</span> <span class="p">(</span><span class="n">orthophoto</span><span class="p">),</span> <span class="mf">0.155</span><span class="n">s</span>
<span class="n">freeLayer</span><span class="p">():</span> <span class="n">freeing</span> <span class="n">layer</span> <span class="n">at</span> <span class="mf">03113390.</span>
<span class="n">GDAL</span><span class="p">:</span> <span class="n">GDALDeregister_GTiff</span><span class="p">()</span> <span class="n">called</span><span class="o">.</span>
</pre></div>
</div>
</section>
<section id="reading-errors-returned-by-map2img">
<h5>Reading Errors Returned by map2img<a class="headerlink" href="#reading-errors-returned-by-map2img" title="Link to this heading">¶</a></h5>
<p>If there is a problem with your mapfile, <a class="reference internal" href="../utilities/map2img.html#map2img"><span class="std std-ref">map2img</span></a> should output
the line number in your mapfile that is causing the trouble. The
following tells us that there is a problem on line 85 of my mapfile:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">getSymbol</span><span class="p">():</span> <span class="n">Symbol</span> <span class="n">definition</span> <span class="n">error</span><span class="o">.</span> <span class="n">Parsing</span> <span class="n">error</span> <span class="n">near</span> <span class="p">(</span><span class="n">truetype2</span><span class="p">):(</span><span class="n">line</span> <span class="mi">85</span><span class="p">)</span>
</pre></div>
</div>
<p>If you are using mapfile <a class="reference internal" href="../mapfile/include.html#include"><span class="std std-ref">INCLUDEs</span></a>, it may be tricky
to track down this line number, but most of the time the line number
is useful.</p>
</section>
</section>
<section id="using-mapserv-cgi">
<h4>Using mapserv CGI<a class="headerlink" href="#using-mapserv-cgi" title="Link to this heading">¶</a></h4>
<p>Another handy way to test your mapfile is to call the mapserv CGI
executable at the <a class="reference internal" href="../cgi/mapserv.html#mapserv"><span class="std std-ref">commandline</span></a>, such as the following:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mapserv</span> <span class="o">-</span><span class="n">nh</span> <span class="s2">"QUERY_STRING=map=/ms4w/apps/spain/map/spain.map&mode=map"</span>
</pre></div>
</div>
</section>
<section id="on-missing-data">
<span id="index-8"></span><h4>ON_MISSING_DATA<a class="headerlink" href="#on-missing-data" title="Link to this heading">¶</a></h4>
<p>If you are using tile indexes to access your data, you should also be
aware of the configuration settings added in MapServer 5.4 that allow
you to tell MapServer how to handle missing data in tile indexes.
Please see the <em>CONFIG</em> parameter’s <em>ON_MISSING_DATA</em> setting in the
<a class="reference internal" href="../mapfile/map.html#map"><span class="std std-ref">MAP</span></a> object for more information.</p>
<div class="admonition hint">
<p class="admonition-title">Hint</p>
<p>You can check the attributes in the tileindex by executing
“<em>ogrinfo -al</em>” on your data file</p>
</div>
</section>
</section>
<section id="step-6-check-your-web-server-logs">
<h3><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Step 6: Check your Web Server Logs</a><a class="headerlink" href="#step-6-check-your-web-server-logs" title="Link to this heading">¶</a></h3>
<p>Once you have verified that there are no problems with you mapfile,
next you should check your Web server log files, for any related
information that may help you narrow down your problem.</p>
<section id="apache">
<h4>Apache<a class="headerlink" href="#apache" title="Link to this heading">¶</a></h4>
<p>Unix users will usually find Apache’s <em>error_log</em> file in a path
similar to:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">log</span><span class="o">/</span><span class="n">apache2</span><span class="o">/</span>
</pre></div>
</div>
<p>Windows users will usually find Apache’s log files in a path similar to:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">:</span>\<span class="n">Program</span> <span class="n">Files</span>\<span class="n">Apache</span> <span class="n">Group</span>\<span class="n">Apache2</span>\<span class="n">logs</span>
</pre></div>
</div>
<p>MapServer for Windows (<a class="reference external" href="https://ms4w.com">MS4W</a>) users
will find Apache’s log files at:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>\<span class="n">ms4w</span>\<span class="n">Apache</span>\<span class="n">logs</span>
</pre></div>
</div>
</section>
<section id="microsoft-iis">
<h4>Microsoft IIS<a class="headerlink" href="#microsoft-iis" title="Link to this heading">¶</a></h4>
<p>IIS log files can be located by:</p>
<ol class="arabic">
<li><p>Go to Start -> Control Panel -> Administrative Tools</p></li>
<li><p>Open the Internet Information Services (IIS) Manager.</p></li>
<li><p>Find your Web site under the tree on the left.</p></li>
<li><p>Right-click on it and choose Properties.</p></li>
<li><p>On the Web site tab, you will see an option near the bottom that
says “Active Log Format.” Click on the Properties button.</p>
<blockquote>
<div><img alt="../_images/iis-debug.png" src="../_images/iis-debug.png" />
</div></blockquote>
</li>
<li><p>At the bottom of the General Properties tab, you will see a box
that contains the log file directory and the log file name. The
full log path is comprised of the log file directory plus the first
part of the log file name, for example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">C</span><span class="p">:</span>\<span class="n">WINDOWS</span>\<span class="n">system32</span>\<span class="n">LogFiles</span>\<span class="n">W3SVC1</span>\<span class="n">ex100507</span><span class="o">.</span><span class="n">log</span>
</pre></div>
</div>
</li>
</ol>
<p>You may also want to check the Windows Event Viewer logs, which is located at:</p>
<ol class="arabic simple">
<li><p>Go to Start -> Control Panel -> Administrative Tools</p></li>
<li><p>Computer Management</p></li>
<li><p>Event Viewer</p></li>
</ol>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>As mentioned previously, in IIS the MapServer <em>stderr</em> debug output
is returned to the client instead of routed to the Web Server logs,
so be sure to log the output to a file, by setting the following in
your mapfile:</p>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">CONFIG</span> <span class="s2">"MS_ERRORFILE"</span> <span class="s2">"/ms4w/tmp/ms_error.txt"</span>
</pre></div>
</div>
</section>
<section id="cgi-error-the-specified-cgi-application-misbehaved-by-not-returning-a-complete-set-of-http-headers">
<h4>CGI Error - The specified CGI application misbehaved by not returning a complete set of HTTP headers<a class="headerlink" href="#cgi-error-the-specified-cgi-application-misbehaved-by-not-returning-a-complete-set-of-http-headers" title="Link to this heading">¶</a></h4>
<p>This error is often caused by missing DLL files. You should try to
execute “<em>mapserv -v</em> at the commandline, to make sure that MapServer
loads properly.</p>
</section>
</section>
<section id="step-7-verify-your-application-settings">
<h3><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Step 7: Verify your Application Settings</a><a class="headerlink" href="#step-7-verify-your-application-settings" title="Link to this heading">¶</a></h3>
<p>If you have verified that MapServer creates a valid map image through
<a class="reference internal" href="../utilities/map2img.html#map2img"><span class="std std-ref">map2img</span></a>, you’ve checked your MapServer log files, and there are
no problems noted in your Web server logs, then you should focus your
attention on possible application configuration problems.
“Application” here means how you are displaying your map images on the
Web page, such as with <a class="reference external" href="http://www.openlayers.org">OpenLayers</a>.</p>
</section>
<section id="step-8-use-qgis-to-test-your-ogc-services">
<h3><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Step 8: Use QGIS to test your OGC services</a><a class="headerlink" href="#step-8-use-qgis-to-test-your-ogc-services" title="Link to this heading">¶</a></h3>
<p>When configuring MapServer for OGC services (WMS, WFS, etc.) it sometimes
happens that users of your services report map issues in a desktop GIS or
online application, even though no errors, logs, or local map2img tests
give any hints; this is where the <a class="reference external" href="https://qgis.org">QGIS</a>
<em>Network Logger</em> can really help to get the exact problem request. For
steps on how to implement the network logger see
<a class="reference external" href="https://github.com/MapServer/MapServer/wiki/Get-the-Raw-WMS-Request-Generated-by-QGIS">here</a>.</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>To get the exact problem request, add your MapServer service as a QGIS layer,
then right-click on the request in the Network Logger and select
“Open URL” to see the full request and resulting map image in your browser.</p>
</div>
<img alt="../_images/qgis-network-logger2.png" class="no-scaled-link" height="443" src="../_images/qgis-network-logger2.png" width="800" />
<section id="php-mapscript">
<span id="index-9"></span><h4>PHP MapScript<a class="headerlink" href="#php-mapscript" title="Link to this heading">¶</a></h4>
<p>If you are using PHP MapScript in your application, here are some
important notes for debugging:</p>
<p>1. Make sure your <em>php.ini</em> file is configured to show all errors, by
setting:</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">display_errors</span> <span class="o">=</span> <span class="n">On</span>
</pre></div>
</div>
</div></blockquote>
<ol class="arabic" start="2">
<li><p>To enable debugging in PHP MapScript, if you are using MapServer
5.6.0 or more recent, make sure to define <em>ZEND_DEBUG</em> in the PHP
source.</p>
<p>If you are using MapServer < 5.6.0, then:</p>
<ul>
<li><p>open the file <em>/mapscript/php3/php_mapscript.c</em></p></li>
<li><p>change the following:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#define ZEND_DEBUG 0</span>
<span class="n">to</span>
<span class="c1">#define ZEND_DEBUG 1</span>
</pre></div>
</div>
</li>
</ul>
</li>
</ol>
</section>
</section>
</section>
<section id="debugging-mapserver-using-compiler-debugging-tools">
<h2><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Debugging MapServer using Compiler Debugging Tools</a><a class="headerlink" href="#debugging-mapserver-using-compiler-debugging-tools" title="Link to this heading">¶</a></h2>
<section id="running-mapserver-in-gdb-linux-unix">
<span id="index-10"></span><h3><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Running MapServer in GDB (Linux/Unix)</a><a class="headerlink" href="#running-mapserver-in-gdb-linux-unix" title="Link to this heading">¶</a></h3>
<p><em>Section author: Frank Warmerdam</em></p>
<section id="building-with-symbolic-debug-info">
<h4>Building with Symbolic Debug Info<a class="headerlink" href="#building-with-symbolic-debug-info" title="Link to this heading">¶</a></h4>
<p>It is not strictly necessary to build MapServer with debugging enabled
in order to use <a class="reference external" href="http://www.gnu.org/software/gdb/">GDB</a> on linux,
but it does ensure that more meaningful information is reported within
GDB. To enable full symbolic information use the <em>–enable-debug</em>
configure switch. Note that use of this switch disables optimization
and so it should not normally be used for production builds where
performance is important.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">configure</span> <span class="o">--</span><span class="n">enable</span><span class="o">-</span><span class="n">debug</span> <span class="o"><</span><span class="n">other</span> <span class="n">switches</span><span class="o">></span>
<span class="n">make</span> <span class="n">clean</span>
<span class="n">make</span>
</pre></div>
</div>
</section>
<section id="running-in-the-debugger">
<h4>Running in the Debugger<a class="headerlink" href="#running-in-the-debugger" title="Link to this heading">¶</a></h4>
<p>To run either mapserv or map2img, give the name of the executable as an
argument to the “gdb” command. If it is not in the path, you will need
to provide the full path to the executable.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">gdb</span> <span class="n">map2img</span>
<span class="n">GNU</span> <span class="n">gdb</span> <span class="p">(</span><span class="n">GDB</span><span class="p">)</span> <span class="mf">7.0</span><span class="o">-</span><span class="n">ubuntu</span>
<span class="n">Copyright</span> <span class="p">(</span><span class="n">C</span><span class="p">)</span> <span class="mi">2009</span> <span class="n">Free</span> <span class="n">Software</span> <span class="n">Foundation</span><span class="p">,</span> <span class="n">Inc</span><span class="o">.</span>
<span class="n">License</span> <span class="n">GPLv3</span><span class="o">+</span><span class="p">:</span> <span class="n">GNU</span> <span class="n">GPL</span> <span class="n">version</span> <span class="mi">3</span> <span class="ow">or</span> <span class="n">later</span> <span class="o"><</span><span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">gnu</span><span class="o">.</span><span class="n">org</span><span class="o">/</span><span class="n">licenses</span><span class="o">/</span><span class="n">gpl</span><span class="o">.</span><span class="n">html</span><span class="o">></span>
<span class="n">This</span> <span class="ow">is</span> <span class="n">free</span> <span class="n">software</span><span class="p">:</span> <span class="n">you</span> <span class="n">are</span> <span class="n">free</span> <span class="n">to</span> <span class="n">change</span> <span class="ow">and</span> <span class="n">redistribute</span> <span class="n">it</span><span class="o">.</span>
<span class="n">There</span> <span class="ow">is</span> <span class="n">NO</span> <span class="n">WARRANTY</span><span class="p">,</span> <span class="n">to</span> <span class="n">the</span> <span class="n">extent</span> <span class="n">permitted</span> <span class="n">by</span> <span class="n">law</span><span class="o">.</span> <span class="n">Type</span> <span class="s2">"show copying"</span>
<span class="ow">and</span> <span class="s2">"show warranty"</span> <span class="k">for</span> <span class="n">details</span><span class="o">.</span>
<span class="n">This</span> <span class="n">GDB</span> <span class="n">was</span> <span class="n">configured</span> <span class="k">as</span> <span class="s2">"x86_64-linux-gnu"</span><span class="o">.</span>
<span class="n">For</span> <span class="n">bug</span> <span class="n">reporting</span> <span class="n">instructions</span><span class="p">,</span> <span class="n">please</span> <span class="n">see</span><span class="p">:</span>
<span class="o"><</span><span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">www</span><span class="o">.</span><span class="n">gnu</span><span class="o">.</span><span class="n">org</span><span class="o">/</span><span class="n">software</span><span class="o">/</span><span class="n">gdb</span><span class="o">/</span><span class="n">bugs</span><span class="o">/>...</span>
<span class="n">Reading</span> <span class="n">symbols</span> <span class="kn">from</span><span class="w"> </span><span class="o">/</span><span class="n">wrk</span><span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">warmerda</span><span class="o">/</span><span class="n">mapserver</span><span class="o">/</span><span class="n">map2img</span><span class="o">...</span><span class="n">done</span><span class="o">.</span>
<span class="p">(</span><span class="n">gdb</span><span class="p">)</span>
</pre></div>
</div>
<p>Once you are at the “(gdb)” prompt you can use the run command with the
arguments you would normally have passed to the mapserv or map2img
executable.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">gdb</span><span class="p">)</span> <span class="n">run</span> <span class="o">-</span><span class="n">m</span> <span class="n">test</span><span class="o">.</span><span class="n">map</span> <span class="o">-</span><span class="n">o</span> <span class="n">out</span><span class="o">.</span><span class="n">png</span>
<span class="n">Starting</span> <span class="n">program</span><span class="p">:</span> <span class="o">/</span><span class="n">wrk</span><span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">warmerda</span><span class="o">/</span><span class="n">mapserver</span><span class="o">/</span><span class="n">map2img</span> <span class="o">-</span><span class="n">m</span> <span class="n">test</span><span class="o">.</span><span class="n">map</span> <span class="o">-</span><span class="n">o</span> <span class="n">out</span><span class="o">.</span><span class="n">png</span>
<span class="p">[</span><span class="n">Thread</span> <span class="n">debugging</span> <span class="n">using</span> <span class="n">libthread_db</span> <span class="n">enabled</span><span class="p">]</span>
<span class="n">Program</span> <span class="n">received</span> <span class="n">signal</span> <span class="n">SIGSEGV</span><span class="p">,</span> <span class="n">Segmentation</span> <span class="n">fault</span><span class="o">.</span>
<span class="mh">0x00007ffff67594a2</span> <span class="ow">in</span> <span class="n">JP2KAKDataset</span><span class="p">::</span><span class="n">Identify</span> <span class="p">(</span><span class="n">poOpenInfo</span><span class="o">=</span><span class="mh">0x0</span><span class="p">)</span>
<span class="n">at</span> <span class="n">jp2kakdataset</span><span class="o">.</span><span class="n">cpp</span><span class="p">:</span><span class="mi">962</span>
<span class="mi">962</span> <span class="k">if</span><span class="p">(</span> <span class="n">poOpenInfo</span><span class="o">-></span><span class="n">nHeaderBytes</span> <span class="o"><</span> <span class="p">(</span><span class="nb">int</span><span class="p">)</span> <span class="n">sizeof</span><span class="p">(</span><span class="n">jp2_header</span><span class="p">)</span> <span class="p">)</span>
<span class="n">Current</span> <span class="n">language</span><span class="p">:</span> <span class="n">auto</span>
<span class="n">The</span> <span class="n">current</span> <span class="n">source</span> <span class="n">language</span> <span class="ow">is</span> <span class="s2">"auto; currently c++"</span><span class="o">.</span>
<span class="p">(</span><span class="n">gdb</span><span class="p">)</span>
</pre></div>
</div>
<p>If the program is crashing, you will generally get a report like the above
indicating the function the crash occurred in, and some minimal
information on why. It is often useful to request a traceback to see
what functions led to the function that crashed. For this use the “where”
command.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">gdb</span><span class="p">)</span> <span class="n">where</span>
<span class="c1">#0 0x00007ffff67594a2 in JP2KAKDataset::Identify (poOpenInfo=0x0)</span>
<span class="n">at</span> <span class="n">jp2kakdataset</span><span class="o">.</span><span class="n">cpp</span><span class="p">:</span><span class="mi">962</span>
<span class="c1">#1 0x00007ffff67596d2 in JP2KAKDataset::Open (poOpenInfo=0x7fffffffb6f0)</span>
<span class="n">at</span> <span class="n">jp2kakdataset</span><span class="o">.</span><span class="n">cpp</span><span class="p">:</span><span class="mi">1025</span>
<span class="c1">#2 0x00007ffff6913339 in GDALOpen (</span>
<span class="n">pszFilename</span><span class="o">=</span><span class="mh">0x83aa60</span> <span class="s2">"/home/warmerda/data/jpeg2000/spaceimaging_16bit_rgb.jp</span>
<span class="mi">2</span><span class="s2">", eAccess=GA_ReadOnly) at gdaldataset.cpp:2170</span>
<span class="c1">#3 0x00007ffff69136bf in GDALOpenShared (</span>
<span class="n">pszFilename</span><span class="o">=</span><span class="mh">0x83aa60</span> <span class="s2">"/home/warmerda/data/jpeg2000/spaceimaging_16bit_rgb.jp</span>
<span class="mi">2</span><span class="s2">", eAccess=GA_ReadOnly) at gdaldataset.cpp:2282</span>
<span class="c1">#4 0x0000000000563c2d in msDrawRasterLayerLow (map=0x81e450, layer=0x839140,</span>
<span class="n">image</span><span class="o">=</span><span class="mh">0x83af90</span><span class="p">,</span> <span class="n">rb</span><span class="o">=</span><span class="mh">0x0</span><span class="p">)</span> <span class="n">at</span> <span class="n">mapraster</span><span class="o">.</span><span class="n">c</span><span class="p">:</span><span class="mi">566</span>
<span class="c1">#5 0x000000000048928f in msDrawRasterLayer (map=0x81e450, layer=0x839140,</span>
<span class="n">image</span><span class="o">=</span><span class="mh">0x83af90</span><span class="p">)</span> <span class="n">at</span> <span class="n">mapdraw</span><span class="o">.</span><span class="n">c</span><span class="p">:</span><span class="mi">1390</span>
<span class="c1">#6 0x0000000000486a48 in msDrawLayer (map=0x81e450, layer=0x839140,</span>
<span class="n">image</span><span class="o">=</span><span class="mh">0x83af90</span><span class="p">)</span> <span class="n">at</span> <span class="n">mapdraw</span><span class="o">.</span><span class="n">c</span><span class="p">:</span><span class="mi">806</span>
<span class="c1">#7 0x00000000004858fd in msDrawMap (map=0x81e450, querymap=0) at mapdraw.c:459</span>
<span class="c1">#8 0x0000000000446410 in main (argc=5, argv=0x7fffffffd918) at map2img.c:300</span>
<span class="p">(</span><span class="n">gdb</span><span class="p">)</span>
</pre></div>
</div>
<p>It may also be helpful to examine variables used in the line where the
crash occurred. Use the print command for this.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>(gdb) print poOpenInfo
$1 = (GDALOpenInfo *) 0x0
</pre></div>
</div>
<p>In this case we see that the program crashed because poOpenInfo was
NULL (zero). Including a traceback like the above in bug report can
help the developers narrow down a problem more quickly, especially if
it is one that is difficult for the developers to reproduce
themselves.</p>
</section>
</section>
</section>
<section id="debugging-older-versions-of-mapserver-before-5-0">
<h2><a class="toc-backref" href="#table-of-contents" role="doc-backlink">Debugging Older Versions of MapServer (before 5.0)</a><a class="headerlink" href="#debugging-older-versions-of-mapserver-before-5-0" title="Link to this heading">¶</a></h2>
<ol class="arabic">
<li><p>Make sure that MapServer is compiled in debug mode (on unix this is
enabled through <em>./configure –enable-debug</em>).</p>
<p>You can verify that your build was compiled in debug mode, by
executing the following at the commandline (look for
“DEBUG=MSDEBUG”):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">mapserv</span> <span class="o">-</span><span class="n">v</span>
<span class="n">MapServer</span> <span class="n">version</span> <span class="mf">4.10.2</span> <span class="n">OUTPUT</span><span class="o">=</span><span class="n">GIF</span> <span class="n">OUTPUT</span><span class="o">=</span><span class="n">PNG</span> <span class="n">OUTPUT</span><span class="o">=</span><span class="n">WBMP</span>
<span class="n">OUTPUT</span><span class="o">=</span><span class="n">SVG</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">PROJ</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">FREETYPE</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">WMS_SERVER</span>
<span class="n">SUPPORTS</span><span class="o">=</span><span class="n">WMS_CLIENT</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">WCS_SERVER</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">THREADS</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">GEOS</span>
<span class="n">INPUT</span><span class="o">=</span><span class="n">EPPL7</span> <span class="n">INPUT</span><span class="o">=</span><span class="n">POSTGIS</span> <span class="n">INPUT</span><span class="o">=</span><span class="n">OGR</span> <span class="n">INPUT</span><span class="o">=</span><span class="n">GDAL</span> <span class="n">INPUT</span><span class="o">=</span><span class="n">SHAPEFILE</span>
<span class="n">DEBUG</span><span class="o">=</span><span class="n">MSDEBUG</span>
</pre></div>
</div>
</li>
<li><p>Set the <em>MS_ERRORFILE</em> variable is in your mapfile, within the
<a class="reference internal" href="../mapfile/map.html#map"><span class="std std-ref">MAP</span></a> object, such as:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">MAP</span>
<span class="p">...</span>
<span class="k">CONFIG</span> <span class="s">"MS_ERRORFILE"</span> <span class="s">"/ms4w/tmp/ms_error.txt"</span>
<span class="p">...</span>
<span class="k">LAYER</span>
<span class="p">...</span>
<span class="k">END</span>
<span class="k">END</span>
</pre></div>
</div>
</li>
<li><p>If you don’t use the <em>MS_ERRORFILE</em> variable, you can use the LOG
parameter in your <a class="reference internal" href="../mapfile/web.html#web"><span class="std std-ref">WEB</span></a> object of the mapfile, such as:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span> <span class="k">MAP</span>
<span class="p">...</span>
<span class="k">WEB</span>
<span class="k">LOG</span> <span class="s">"mapserver.log"</span>
<span class="k">END</span>
<span class="p">...</span>
<span class="k">LAYER</span>
<span class="p">...</span>
<span class="k">END</span>
<span class="k">END</span>
</pre></div>
</div>
</li>
<li><p>Specify <em>DEBUG ON</em> in your MAP object, or in your LAYER objects,
such as:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span> <span class="k">MAP</span>
<span class="p">...</span>
<span class="k">WEB</span>
<span class="k">LOG</span> <span class="s">"mapserver.log"</span>
<span class="k">END</span>
<span class="k">DEBUG</span> <span class="nb">ON</span>
<span class="p">...</span>
<span class="k">LAYER</span>
<span class="p">...</span>
<span class="k">END</span>
<span class="k">END</span>
</pre></div>
</div>
</li>
<li><p>Note that only errors will be written to the log file; all DEBUG
output goes to stderr, in the case of Apache that is Apache’s
<em>error_log</em> file. If you are using Microsoft IIS, debug output is
routed to <em>stdout</em> (i.e. the browser), so be sure to remove <em>DEBUG
ON</em> statements if using IIS on a production server.</p></li>
</ol>
<p>.</p>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script><h3>Navigation</h3>
<p>
<a href="../about.html" title="About">About</a><br>
<a href="../products.html" title="Products">Products</a><br>
<a href="../community/index.html" title="Community">Community</a><br>
<a href="../development/index.html" title="Development">Development</a><br>
<a href="../download.html" title="Downloads">Downloads</a><br>
<a href="../documentation.html" title="Documentation">Documentation</a><br>
<a href="../faq.html" title="FAQ">FAQ</a><br>
<a href="../psc.html" title="PSC">PSC</a><br>
<a href="https://fosstodon.org/@mapserver" title="Mastodon">Mastodon</a>
</p>
<h3>Current Table Of Contents</h3>
<ul>
<li><a class="reference internal" href="#">Debugging MapServer</a><ul>
<li><a class="reference internal" href="#introduction">Introduction</a><ul>
<li><a class="reference internal" href="#links-to-related-information">Links to Related Information</a></li>
</ul>
</li>
<li><a class="reference internal" href="#steps-to-enable-mapserver-debugging">Steps to Enable MapServer Debugging</a><ul>
<li><a class="reference internal" href="#step-1-set-the-ms-errorfile-variable">Step 1: Set the MS_ERRORFILE Variable</a><ul>
<li><a class="reference internal" href="#through-the-mapfile">Through the Mapfile</a></li>
<li><a class="reference internal" href="#through-an-environment-variable">Through an Environment Variable</a></li>
</ul>
</li>
<li><a class="reference internal" href="#step-2-set-the-debug-level">Step 2: Set the DEBUG Level</a><ul>
<li><a class="reference internal" href="#debug-levels">DEBUG Levels</a></li>
<li><a class="reference internal" href="#mapfile-example-map-level-debug">Mapfile Example: Map-Level Debug</a></li>
<li><a class="reference internal" href="#mapfile-example-layer-level-debug">Mapfile Example: Layer-Level Debug</a></li>
<li><a class="reference internal" href="#the-ms-debuglevel-environment-variable">The MS_DEBUGLEVEL Environment Variable</a></li>
</ul>
</li>
<li><a class="reference internal" href="#step-3-turn-on-cpl-debug-optional">Step 3: Turn on CPL_DEBUG (optional)</a></li>
<li><a class="reference internal" href="#step-4-turn-on-proj-debug-optional">Step 4: Turn on PROJ_DEBUG (optional)</a></li>
<li><a class="reference internal" href="#step-5-test-your-mapfile">Step 5: Test your Mapfile</a><ul>
<li><a class="reference internal" href="#using-map2img">Using map2img</a><ul>
<li><a class="reference internal" href="#all-debug">-all_debug</a></li>
<li><a class="reference internal" href="#map-debug">-map_debug</a></li>
<li><a class="reference internal" href="#layer-debug">-layer_debug</a></li>
<li><a class="reference internal" href="#set-cpl-debug">Set CPL_DEBUG</a></li>
<li><a class="reference internal" href="#reading-errors-returned-by-map2img">Reading Errors Returned by map2img</a></li>
</ul>
</li>
<li><a class="reference internal" href="#using-mapserv-cgi">Using mapserv CGI</a></li>
<li><a class="reference internal" href="#on-missing-data">ON_MISSING_DATA</a></li>
</ul>
</li>
<li><a class="reference internal" href="#step-6-check-your-web-server-logs">Step 6: Check your Web Server Logs</a><ul>
<li><a class="reference internal" href="#apache">Apache</a></li>
<li><a class="reference internal" href="#microsoft-iis">Microsoft IIS</a></li>
<li><a class="reference internal" href="#cgi-error-the-specified-cgi-application-misbehaved-by-not-returning-a-complete-set-of-http-headers">CGI Error - The specified CGI application misbehaved by not returning a complete set of HTTP headers</a></li>
</ul>
</li>
<li><a class="reference internal" href="#step-7-verify-your-application-settings">Step 7: Verify your Application Settings</a></li>
<li><a class="reference internal" href="#step-8-use-qgis-to-test-your-ogc-services">Step 8: Use QGIS to test your OGC services</a><ul>
<li><a class="reference internal" href="#php-mapscript">PHP MapScript</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#debugging-mapserver-using-compiler-debugging-tools">Debugging MapServer using Compiler Debugging Tools</a><ul>
<li><a class="reference internal" href="#running-mapserver-in-gdb-linux-unix">Running MapServer in GDB (Linux/Unix)</a><ul>
<li><a class="reference internal" href="#building-with-symbolic-debug-info">Building with Symbolic Debug Info</a></li>
<li><a class="reference internal" href="#running-in-the-debugger">Running in the Debugger</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#debugging-older-versions-of-mapserver-before-5-0">Debugging Older Versions of MapServer (before 5.0)</a></li>