Questions tagged [django-logging]

Django uses Python's builtin logging module. For questions related to logging tasks in Django.

96 questions
3
votes
1 answer

Distinguishing Production logs and staging logs

I have logging enabled in my django app, I receive all ERRORS related logs on my configured emails. But I am unable to distinguish whether an error has occurred on PRODUCTION or STAGING system. Should I change some logging setting, or is there any…
Lavish
  • 461
  • 1
  • 4
  • 12
2
votes
1 answer

Log messages from Django application not uploaded in AWS CloudWatch

I have added log messages in my Django application and it was successfully logging log messages to the log file. Now, I tried to add log messages to AWS CloudWatch. When I run the application it creates log group in AWS CloudWatch but log stream is…
2
votes
2 answers

Django not logging anything levels less than WARNING

I am not sure why django is not logging anything less than "WARNING" level. I have this code in the view: logger = logging.getLogger(__name__) def profile_data(request): logging.info("INFO PROFILE DATA!!") logging.debug("DEBUG PROFILE…
Alejandro Veintimilla
  • 10,743
  • 23
  • 91
  • 180
2
votes
1 answer

Custom Django Logging Filter for a Particular API

In my app, there is this API named 'UserChangeWorkScheduleViewSet' where its uri is 'host/api/v1/workSchedule' I have been trying to make a custom logging filter that would send me an error log whenever a user causes 400 status code. Below is the…
W.H.N.A.
  • 327
  • 2
  • 7
2
votes
1 answer

How to log using django background tasks?

I can easily create logs throughout the application using the logging module, but inside a django background task it does not work. import logging from background_task import background log = logging.getLogger("django") @background(schedule=1) def…
Akira Kotsugai
  • 1,099
  • 3
  • 12
  • 19
2
votes
1 answer

How to log request and response for 4XX Http status in Django Rest Framework?

The default behaviour of DRF is to throw exception for 5XX, but return valid response with error details for 4XX. I want to log request and response of any API call which fails with 4XX. Currently the log only shows Bad Request : /path/api/ Answer:…
2
votes
1 answer

Django Logging all the GET requests

I'm trying to put all the GET requests that appear in console into the database from django. For example: console log: [23/May/2019 13:58:44] "GET /testapp/ HTTP/1.1" 200 409 [23/May/2019 13:58:45] "GET /testapp/page2/ HTTP/1.1" 200 172 I'm trying…
Naeem Khan
  • 950
  • 4
  • 13
  • 34
2
votes
2 answers

Django logger.error does not save logging entry into the debug.log file

I followed the django documentation and tried to use the logger.error to save the error into the debug.log file. LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'file': { 'level': 'DEBUG', 'class':…
Stephan
  • 365
  • 1
  • 5
  • 18
2
votes
1 answer

Logging in django usig a custom formatter

I'm using the following logging configurations in my code. LOGGING = { 'version': 1, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'stream': sys.stdout, } }, 'formatters': { …
Melissa Stewart
  • 3,483
  • 11
  • 49
  • 88
2
votes
1 answer

Different django processes same log

This is an open ended question about logging when you have different django processes. How can I get the output of different django processes in the same log file? How would you approach this issue? Now to my current setup. I have a django webapp…
Martin Massera
  • 1,718
  • 1
  • 21
  • 47
2
votes
1 answer

Django logging, log to file in development without needing to create the file in production

I'm implementing Django logging in a project. I've got it working such that log entries are inserted into a file in our dev environment, and into a database in our production environment. The problem I'm having is that Django needs to create the log…
Ryan Fisher
  • 1,485
  • 1
  • 19
  • 32
2
votes
1 answer

How to debug Django 1.8 AppConfig?

I'm using Django 1.8. I'm trying to wire up the django-registration user_registration signal. To wire up a signal, this post is pretty explicit: use AppConfig.ready(). I think I have it wired up correctly, but clearly I don't, because it's not…
dfrankow
  • 20,191
  • 41
  • 152
  • 214
1
vote
0 answers

Django LogEntry without user

In my app there's a Project model which users can create, request to join, invite others to join, accept/reject requests/invites to join, leave, etc. I'm using the Django LogEntry to help the application admins keep track of all changes to each…
Marco Castanho
  • 395
  • 1
  • 7
  • 24
1
vote
1 answer

How to log INFO logs in settings.py

I'm trying to log some info messages specifically in django settings.py. I'm following the first example in the django documentation that shows a simple configuration. The only thing I changed was having the log show INFO level messages. When I run…
Frantz Paul
  • 127
  • 2
  • 11
1
vote
0 answers

Db logger auto delete data after a time interval

Trying to implement a DB logger in my Django project but I am facing a problem in managing the logs in my DB so how can I automatically delete the old records from DB settings.py INSTALLED_APPS = ['django_db_logger',] LOGGING = { 'version':…