WebApp crash

2021-09-12T09:36:09.027+00:00

I have a django web app. I used to use Azure Web App without any problems, but for some reason recently it stopped working. The application crashes right after launch. Log stream in the photo. Tell me what to do, please!!

131323-screen-shot-2021-09-11-at-111433-am.png

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,807 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 16,431 Reputation points Microsoft Employee
    2021-09-13T03:34:02.417+00:00

    @Денисов Степан Дмитриевич We apologize for the frustration that you have encountered.

    Is this issue still ongoing? If so, please follow the below steps. If you resolved the matter, please share the answer with the community.

    Firstly, I would suggest redeploying your app if you haven't already. In very rare scenarios, the site files can become corrupt.

    If redeploying does not work, then try the Diagnose and Solve blade within your web app. This powerful tool has many detectors and might shed some light into your crashes. More information on that tool can be found here.

    The third step would be to enable custom logging.

    Step 1
    Add the following code to settings.py file

    import logging.handlers  
       
    LOGGING = {  
                'version': 1,  
                'disable_existing_loggers': False,  
                'formatters': {  
                         'standard': {  
                         'format': '[%(levelname)s] %(asctime)s - %(name)s - %(message)s',  
                         'datefmt' : "%d/%b/%Y %H:%M:%S"  
                     },  
              },  
                'filters':   
                {  
                    'require_debug_false':   
                        {  
                            '()': 'django.utils.log.RequireDebugFalse'  
                        }  
                },  
                'handlers':   
                {  
                    'logfile':   
                        {  
                            'class': 'logging.handlers.WatchedFileHandler',  
                            'filename': '/home/site/wwwroot/app-log-1.log',   
                            'formatter': 'standard'   
                        }  
                },  
                'loggers':   
                {  
                     'django':   
                        {  
                            'handlers': ['logfile'],  
                            'level': 'CRITICAL',  
                            'propagate': True,  
                        }  
                }  
     }  
       
    
    • In case you need your filename to be different, edit filename': '/home/site/wwwroot/app-log-1.log'
    • Make sure to add the below code or modify the existing ‘DEBUG’ parameter to true, otherwise logging won’t work.
    • DEBUG = True

    Step 2

    • Add the following code inside the files serving as "view" of your django application import logging
      logger = logging.getLogger('django')
    • Add below code inside the functions which we are interested to troubleshoot.
    • Make sure to convert Json response to string before modifying it with ‘logger.critical’ logger.critical("More Hello")
    • Re-deploy the application with the above changes and reproduce the issue.
    • Later, we can download the file using FTP from the location mentioned in the filename settings.

    Additional Information

    • In case you want the content from logger statements to be written to default docker logs which we pulled earlier from api/dump endpoint, instantiate the ‘logger’ in the ‘View’ file with the following statement and remove or comment out logger = logging.getLogger('django') code. logger=logging.getLogger(name)

    When done, do not forget to turn off debugging.

    Please let us know the outcome of the above troubleshooting steps. We look forward to your reply.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.