• <i id='Q1sTh'><tr id='Q1sTh'><dt id='Q1sTh'><q id='Q1sTh'><span id='Q1sTh'><b id='Q1sTh'><form id='Q1sTh'><ins id='Q1sTh'></ins><ul id='Q1sTh'></ul><sub id='Q1sTh'></sub></form><legend id='Q1sTh'></legend><bdo id='Q1sTh'><pre id='Q1sTh'><center id='Q1sTh'></center></pre></bdo></b><th id='Q1sTh'></th></span></q></dt></tr></i><div id='Q1sTh'><tfoot id='Q1sTh'></tfoot><dl id='Q1sTh'><fieldset id='Q1sTh'></fieldset></dl></div>

    1. <small id='Q1sTh'></small><noframes id='Q1sTh'>

      <legend id='Q1sTh'><style id='Q1sTh'><dir id='Q1sTh'><q id='Q1sTh'></q></dir></style></legend>
        <bdo id='Q1sTh'></bdo><ul id='Q1sTh'></ul>

        <tfoot id='Q1sTh'></tfoot>

        你如何在 django 网站上记录服务器错误

        How do you log server errors on django sites(你如何在 django 网站上记录服务器错误)

      1. <tfoot id='eKQC7'></tfoot>
            <tbody id='eKQC7'></tbody>
          <legend id='eKQC7'><style id='eKQC7'><dir id='eKQC7'><q id='eKQC7'></q></dir></style></legend>
          • <bdo id='eKQC7'></bdo><ul id='eKQC7'></ul>

              <small id='eKQC7'></small><noframes id='eKQC7'>

            1. <i id='eKQC7'><tr id='eKQC7'><dt id='eKQC7'><q id='eKQC7'><span id='eKQC7'><b id='eKQC7'><form id='eKQC7'><ins id='eKQC7'></ins><ul id='eKQC7'></ul><sub id='eKQC7'></sub></form><legend id='eKQC7'></legend><bdo id='eKQC7'><pre id='eKQC7'><center id='eKQC7'></center></pre></bdo></b><th id='eKQC7'></th></span></q></dt></tr></i><div id='eKQC7'><tfoot id='eKQC7'></tfoot><dl id='eKQC7'><fieldset id='eKQC7'></fieldset></dl></div>
                  本文介绍了你如何在 django 网站上记录服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  So, when playing with the development I can just set settings.DEBUG to True and if an error occures I can see it nicely formatted, with good stack trace and request information.

                  But on kind of production site I'd rather use DEBUG=False and show visitors some standard error 500 page with information that I'm working on fixing this bug at this moment ;)
                  At the same time I'd like to have some way of logging all those information (stack trace and request info) to a file on my server - so I can just output it to my console and watch errors scroll, email the log to me every hour or something like this.

                  What logging solutions would you recomend for a django-site, that would meet those simple requirements? I have the application running as fcgi server and I'm using apache web server as frontend (although thinking of going to lighttpd).

                  解决方案

                  Well, when DEBUG = False, Django will automatically mail a full traceback of any error to each person listed in the ADMINS setting, which gets you notifications pretty much for free. If you'd like more fine-grained control, you can write and add to your settings a middleware class which defines a method named process_exception(), which will have access to the exception that was raised:

                  http://docs.djangoproject.com/en/dev/topics/http/middleware/#process-exception

                  Your process_exception() method can then perform whatever type of logging you'd like: writing to console, writing to a file, etc., etc.

                  Edit: though it's a bit less useful, you can also listen for the got_request_exception signal, which will be sent whenever an exception is encountered during request processing:

                  http://docs.djangoproject.com/en/dev/ref/signals/#got-request-exception

                  This does not give you access to the exception object, however, so the middleware method is much easier to work with.

                  这篇关于你如何在 django 网站上记录服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)
                  <tfoot id='eIdsK'></tfoot>
                  <legend id='eIdsK'><style id='eIdsK'><dir id='eIdsK'><q id='eIdsK'></q></dir></style></legend>
                      <bdo id='eIdsK'></bdo><ul id='eIdsK'></ul>
                      • <small id='eIdsK'></small><noframes id='eIdsK'>

                          <tbody id='eIdsK'></tbody>

                        1. <i id='eIdsK'><tr id='eIdsK'><dt id='eIdsK'><q id='eIdsK'><span id='eIdsK'><b id='eIdsK'><form id='eIdsK'><ins id='eIdsK'></ins><ul id='eIdsK'></ul><sub id='eIdsK'></sub></form><legend id='eIdsK'></legend><bdo id='eIdsK'><pre id='eIdsK'><center id='eIdsK'></center></pre></bdo></b><th id='eIdsK'></th></span></q></dt></tr></i><div id='eIdsK'><tfoot id='eIdsK'></tfoot><dl id='eIdsK'><fieldset id='eIdsK'></fieldset></dl></div>