@Денисов Степан Дмитриевич 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.