Django uses Python's builtin logging module. For questions related to logging tasks in Django.
Questions tagged [django-logging]
96 questions
1
vote
1 answer
Django Logger creates file but doesn't write in it
I am trying to get a Logger working for my Django App. I call the logger with:
logger = logging.getLogger(__name__)
logger.info("some stuff")
inside a function in my views.py.
But it doesn't work, the file which is supposed to contain the log…

Nicolas
- 11
- 3
1
vote
1 answer
Django - logging configuration
my logging is not working on the dev server, instead locally is working. here is the configuration:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)s…

Luke
- 1,794
- 10
- 43
- 70
1
vote
0 answers
Common loggers for all views in django
Here is my loggers configuration of settings.py on my Django sever.
'loggers': {
'tutorial.view_test': {
'handlers': ['logfile','console','mail_admins'],
'level': 'DEBUG',
'propagate': True,
},
…

Vinay
- 705
- 2
- 7
- 22
1
vote
1 answer
Django Logging Works Intermittently
I'd really like to use Logging to make sure my application is working correctly, but I can't get it to work reliably.
I've only noticed the issue after I delete all the existing lines from the log file and I'm not sure if it happens at other times…

Adam Starrh
- 6,428
- 8
- 50
- 89
1
vote
1 answer
django.request logger not working for get_object_or_404
I have this code for UserDetailsView in Django Rest Framework. I am using django 1.9 and DRF 3.
class UserDetailsView(RetrieveUpdateAPIView):
"""
API endpoint that allows a user to be viewed or edited.
"""
serializer_class =…

Ashish Saini
- 68
- 9
0
votes
0 answers
How to make django not duplicate custom class logs
I wrote MyClass which i'm using inside of DRF ViewSet "create" method. In this class i declared new logger with _set_logger method. The problem is that django duplicates MyClass logs, which I don't want:
MyClass _set_logger method:
import…

lengthylyova
- 34
- 6
0
votes
0 answers
Setting log factory logic from outside settings.py
I have a Django application where I want to update the standard logging to structured JSON format. I can get this working fine by adding my logging config and some business logic into settings.py, but I want to keep the business logic separate.
Is…

MeanwhileInHell
- 6,780
- 17
- 57
- 106
0
votes
0 answers
Django Loglevel is undefined in project app views.py
I try to log something with INFO level in the views.py in a created app in my Django project. When I initialize the logger with: logger = logging.getLogger(__name__) the loglevel is set to 0 which means undefined. Why does it not read the log level…

Kodama
- 21
- 6
0
votes
0 answers
Django logs are working fine in my Windows local Environment but not getting logs in live ubuntu server. I am using Nginx with Gunicorn
import logging
logging.basicConfig(filename=os.path.join(BASE_DIR, 'django.log'), level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s')
##################### Here is the Middleware #######################
class…
0
votes
1 answer
In Django, is it possible to see which method is generating a SQL query?
When creating a custom User (inherits from AbstractUser) we have a signal which creates a randomized password (from Django's get_random_string) and send it out in an email in a celery task to the user.
# accounts/models.py
class User(AbstractUser):
…

kunambi
- 756
- 1
- 10
- 25
0
votes
1 answer
How to redirect print statement to log file and change print statement to logger in django python
I want to replace print statements to logger but without change print statement in application. And how can I redirect print statement to log file???
Below is my code.
settings.py
LOGGING = {
"version": 1,
"disable_existing_loggers":…

Karan Chaudhari
- 1
- 1
0
votes
0 answers
Django send json formatted logs to logstash
I am trying to send logs to logstash with python-logstash package and i need logs to be in json format. I wrote custom json formatter for my logstash handler.
My settings logging configuration:
LOGGING = {
'version': 1,
…

I.Jokhadze
- 456
- 2
- 8
- 27
0
votes
1 answer
How to create a new log file every time the application runs using logger.config?
how i can create new info.log file each time app runs. Let me know the cahnges i need to make in this config. I know we have to use doRollover or rotate but how to implement in this config not getting any idea. Any help will be appreciated and…

SAGY
- 67
- 7
0
votes
2 answers
Add custom formatter tags in papertrail Logger in django
settings Page:
"formatters": {
"simple": {
"format": "%(name)s %(asctime)s %(message)s",
"datefmt": "%Y-%m-%dT%H:%M:%S",
},
},
If I write here code like this:
"formatters": {
"simple": {
…

Sagar Nakade
- 147
- 1
- 1
- 8
0
votes
1 answer
Django verbose logging for bad request
I am relatively new to django. I recently deployed my application on a web server, and I find it very hard to debug issues. I am getting a 400 Http status code for some of my requests and not sure why. I am trying to increase the level of logs in…

michael
- 530
- 4
- 16