Logging in Django Application || Django tutorial 2020 ||

Поділитися
Вставка
  • Опубліковано 11 січ 2025

КОМЕНТАРІ • 96

  • @jakebarker6962
    @jakebarker6962 2 роки тому +2

    I've been reading the docs and blogs all day trying to make sure I understand how to correctly log in django and I believe you were the one to bring it all together for me. Great examples, thank you so much!

  • @AyazAmlani
    @AyazAmlani 3 роки тому +1

    11:57 had me cracking up! "I'm in the logger, if you care...." bahahaha

  • @yashpatel9550
    @yashpatel9550 4 роки тому +3

    Best explaination i found on youtube till now, you know how to teach things, you got teaching skills, never stop this...Thanks for amazing video

  • @manishshetake1555
    @manishshetake1555 3 роки тому +1

    Thank you for your unique explaination, I came for this video by accident.😍

    • @technologyfornoobs
      @technologyfornoobs  3 роки тому +1

      You're welcome 😊

    • @manishshetake1555
      @manishshetake1555 3 роки тому

      @@technologyfornoobs Keep doing such stuff and motivate us to learn & grow with you🤞

  • @pavanjain2178
    @pavanjain2178 Рік тому

    Really helpful brother❤

  • @kamleshmahadule8238
    @kamleshmahadule8238 3 роки тому

    What a explationation, never seen ever. 👌👌

  • @LuadoO
    @LuadoO 2 роки тому

    Best out there sir, good job

  • @spatialnasir
    @spatialnasir 2 роки тому

    Great teacher. Thanks bro.

  • @diPpYzPIANO
    @diPpYzPIANO 3 роки тому

    Bravo !!! It was an awesome explanation... thanks

  • @rood486
    @rood486 4 роки тому

    This is a great video. Thanks for your example and your explanation.

  • @vijayrajput3297
    @vijayrajput3297 4 роки тому

    Thank you for such a wonderful explanation about Django logging module.👏

  • @tarannumx
    @tarannumx 8 місяців тому

    Good explanation sir 🎉🎉❤

  • @sujithsuji6170
    @sujithsuji6170 4 роки тому

    Superb bro great work help me a lot..🥰🥰🥰💝💝

  • @techienomadiso8970
    @techienomadiso8970 3 роки тому

    Superb !!! 🔥🔥🔥👌

  • @azeyn2050
    @azeyn2050 4 роки тому +1

    Great explanation! Thanks a heap!

  • @ShailajaKaustav
    @ShailajaKaustav Рік тому

    Thanks... very informative. One question - there is a specific requirement in one of my project to implement dynamic log level change without restarting Django app. Can you please share information around that as well?

    • @technologyfornoobs
      @technologyfornoobs  Рік тому

      You would just use if else statements

    • @ShailajaKaustav
      @ShailajaKaustav Рік тому

      @@technologyfornoobs can we do that in a production deployed app? or should we use some file like file.conf where we will update at runtime? explored a lot but did not find any concrete answers... could you please guide? the ask is supoose an app is running at INFO level, due to some issues there needs to be a change to type DEBUG but app should not be restarted.

    • @technologyfornoobs
      @technologyfornoobs  Рік тому +1

      @@ShailajaKaustav Now I understand, I believe you are thinking of this to be done while launching the django server, I am saying you do not worry about it how to launch the server app, but have your logs accordingly and do it in the logging level rather than server start settings.

    • @ShailajaKaustav
      @ShailajaKaustav Рік тому

      @@technologyfornoobs Thanks a lot

  • @mannshah6808
    @mannshah6808 4 роки тому

    Good explanation

  • @gops3843
    @gops3843 4 роки тому

    tysm sir for this video and make video on emaillogger

  • @asztro
    @asztro 2 роки тому

    Nice

  • @saonidas4140
    @saonidas4140 4 роки тому

    is there any video to call a python script from html page with input parameters using django?

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      Not exactly, but it's possible u need to use "exec" and eval

  • @sunny-lz6uy
    @sunny-lz6uy 3 роки тому +1

    hello sir,
    i am doing a project in Django on E-Banking Log System in my college. I am facing some problem while generating the logs. Could you please help me with it sir.

    • @technologyfornoobs
      @technologyfornoobs  3 роки тому +1

      What I can do here?

    • @sunny-lz6uy
      @sunny-lz6uy 3 роки тому

      @@technologyfornoobs Thank you for your reply sir, Could you please provide me with any means of personal contact with you (like your email info etc.)

    • @technologyfornoobs
      @technologyfornoobs  3 роки тому +1

      techfornoobs01@gmail.com

    • @sunny-lz6uy
      @sunny-lz6uy 3 роки тому

      @@technologyfornoobs Sir, I have mailed you

  • @revanthkumar3406
    @revanthkumar3406 4 роки тому +1

    can you do authentication with otp in django

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      OK, there are so many things which can do that like oauth and oauth2 , will update in a while

    • @revanthkumar3406
      @revanthkumar3406 4 роки тому

      thank u so much...i tried but many errors are occurred.

  • @chillsoftwarengineer
    @chillsoftwarengineer 3 роки тому

    can we store loggers and print them in some file

    • @technologyfornoobs
      @technologyfornoobs  3 роки тому +1

      yes, that's what is in the video, or I am missing something.

  • @hacninetushar
    @hacninetushar 4 роки тому

    Great!

  • @EdgarSkipper
    @EdgarSkipper Рік тому

    why is this not working when I run the server with >> mod_wsgi-express start ??

  • @joy_sam_raj
    @joy_sam_raj 3 роки тому

    Thanks sir

  • @gupta-xh4sk
    @gupta-xh4sk 4 роки тому

    How to rotate log in django. Same as java log4j2 is working. TimedRotation is not working. It truncate file while rotating

  • @balajibalaji9706
    @balajibalaji9706 4 роки тому

    How to add only the django logs in to text file, I tried the same but the logs are not storing in the text file

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому +1

      That's the video is about follow from 11:20

    • @balajibalaji9706
      @balajibalaji9706 4 роки тому

      I followed the same sir, but the logs are not printing in text file, do I need to install any additional module for this?

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      Pull from github and check of the code works in yours and then check the diff what you are missing

  • @mohamedferhi3332
    @mohamedferhi3332 4 роки тому

    how you can pass variables from django views.py to jupyter notebook ???

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому +1

      Not possible!

    • @mohamedferhi3332
      @mohamedferhi3332 4 роки тому

      @@technologyfornoobs can i make code of jupyter notebook in my django project ? and where ? please i need help

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      Code of jupyter notebook in django, you need to write the code of jupyter notebook into views or else but inside the project

  • @asaadqudsieh8108
    @asaadqudsieh8108 3 роки тому

    how can i get user name in log?

  • @hacninetushar
    @hacninetushar 4 роки тому

    If you make more videos like this!

  • @kunalsharma-zc2ho
    @kunalsharma-zc2ho 4 роки тому

    the logger is unable to write on file .although file is created but after re-deploying still it create the file but not writing and 'level':'DEBUG',

    • @kunalsharma-zc2ho
      @kunalsharma-zc2ho 4 роки тому

      can you tell me what can be reasons?

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому +1

      might be you are looking for Level INFO and level DEBUG is filtering it, change it to INFO and you would see all the logs

    • @kunalsharma-zc2ho
      @kunalsharma-zc2ho 4 роки тому

      @@technologyfornoobs Actually I am looking for default generate logs at the development server and writing back to that file.

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      Possible reason, you have missed the handler in logging setup:
      'loggers':{
      'django':{
      'handlers':['file','file2'],
      'level':'DEBUG'
      }
      },

    • @kunalsharma-zc2ho
      @kunalsharma-zc2ho 4 роки тому

      LOGGING = {
      'version': 1 ,
      'disable_existing_loggers': True ,
      'loggers': {
      'Django': {
      'handlers': ['pathd'] ,
      'level': 'DEBUG'
      }
      } ,
      'handlers': {
      'pathd': {
      'level': 'DEBUG' ,
      'class': 'logging.FileHandler',
      'filename': './log/maverick/m.log' ,

      }
      },
      }
      here is my file .Have a look

  • @marbochengye3374
    @marbochengye3374 4 роки тому

    Hi! I am trying to create a history table that records all updates to the Product model.
    For example, if I have a model Product (name, price, description, status) and a history model (user,field,old_value, new_value, timestamp).
    I would like to be able to keep a history of this product's field changes overtime from creation up to now
    My history model would save the following values into history
    On create it saves as follow
    user = currentuser, field=name, old_value=None, new_value='Product', timestamp= 09/20/2020 10:12:02am
    user = currentuser, field=price, old_value=None, new_value=1, timestamp= 09/20/2020 10:12:02am
    user = currentuser, field=description, old_value=None, new_value="Product description", timestamp= 09/20/2020 10:12:02am
    user = currentuser, field=status, old_value=None, new_value='New;, timestamp= 09/20/2020 10:12:02am
    I then decide to update some fields
    fields price changes to 1 to 2 and status changes from new to old
    user = currentuser, field=price, old_value=1, new_value=2, timestamp= 09/21/2020 10:12:02am
    user = currentuser, field=status,old_value=new, new_value=old, timestamp=09/21/2020 10:12:02am
    I did some research and people recommend doing this by modifying the save method and some recommend using signals (pre_save, post_save).
    Do you have any recommendations? Or better yet, can you create a tutorial? I feel like this would be very useful :)
    Thanks!

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      What I understood from your question is that you want to save all the info as soon as any new info comes you still want to save the old value. The biggest problem I see is how you are going to tell which record is most latest, as they are not clubbed together for creating single row info (name, product, price, etc) with the latest info of all the field, You need to get the latest for all the fields and then club them together which is an overkill for the task I guess. My suggestion > just simply have previous and current as a separate column in your model ('previous_name, current_name, previous_price, current_price, previous_descp, current_descp) and just simply update the current with new and previous with old.
      How you will do it?
      user will send the form, you take the filled value and just add the previous in "previous" and latest in the current field column.

    • @sambots22
      @sambots22 4 роки тому

      ​@@technologyfornoobs I think the request is looking for is some kind of audit trail or audit log in Django project. The following links from PHP framework could be useful to adopt to the Python/Django project: www.radicore.org/viewarticle.php?article_id=4 and www.tonymarston.net/php-mysql/auditlog.html
      His recommendation of a separate database to host an audit logging facility at an application level is good but the challenge (disclaimer: I hear other ppl and had not confirmed) due to current Django version not supporting multiple databases.
      Lastly, with a few months with Django, the use of Django Signals (esp. post_save) may come handy here by implementing separately from the Product app.
      In any case, ​ @Technology for Noobs for a great tutorial very clear. In production, I have been wondering how to go around the Server Error (500) in a website especially when DEBUG=False.
      Thanx..

  • @MohsinKhan-ve1hn
    @MohsinKhan-ve1hn 4 роки тому

    Hi,
    I tried your way for logging but i am getting this error
    raise ValueError('Unable to configure handler '
    ValueError: Unable to configure handler 'file'

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому +1

      If you have not created the log folder in your root path, this could create the issue, can you clone the repo and check where you are making mistake.

    • @MohsinKhan-ve1hn
      @MohsinKhan-ve1hn 4 роки тому

      @@technologyfornoobs it is giving formatter error also
      raise ValueError('Unable to set formatter '
      ValueError: Unable to set formatter 'simpleRe'

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому +1

      Hi, I would still suggest cloning the project from github (github.com/sharmasw/DjangoLoggingApp) and run in your system, and you would be able to check the missing pieces in your code.
      If you look at the end of the dictionary below which is in the settings of the project, you will find the 'simpleRe' defined. this is missing in your settings for logging.
      LOGGING ={
      'version':1,
      'loggers':{
      'django':{
      'handlers':['file','file2'],
      'level':'DEBUG'
      }
      },
      'handlers':{
      'file':{
      'level':'INFO',
      'class': 'logging.FileHandler',
      'filename':'./logs/debug5.log',
      'formatter':'simpleRe',
      },
      'file2':{
      'level':'DEBUG',
      'class': 'logging.FileHandler',
      'filename':'./logs/debug6.log',
      'formatter':'simpleRe',
      }
      },
      'formatters':{
      'simpleRe': {
      'format': '{levelname} {asctime} {module} {process:d} {thread:d} {message}',
      'style': '{',
      }
      }
      }

  • @konchadasrinivas5310
    @konchadasrinivas5310 4 роки тому

    How can we contact you sir.

  • @udbhavdave
    @udbhavdave 3 роки тому

    Hi, thanks for this video, though I tried and played around with logging configuration, still not able to log server errors in a file or in admin mails. What could be the reason for this?? I am not getting any errors for this code but whenever server sends 500, it is not logged.
    LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
    'console': {
    'format': '%(name)-12s %(levelname)-8s %(message)s',
    'style': '{'
    },
    'file': {
    'format': '%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
    'style': '{'
    }
    },
    'filters': {
    'require_debug_true': {
    '()': 'django.utils.log.RequireDebugTrue',
    },
    'require_debug_false': {
    '()': 'django.utils.log.RequireDebugFalse',
    }
    },
    'handlers': {
    'console': {
    'class': 'logging.StreamHandler',
    'formatter': 'console'
    },
    'file': {
    'level': 'INFO',
    'class': 'logging.handlers.RotatingFileHandler',
    'formatter': 'file',
    'filename': os.path.join(BASE_DIR, 'server_error.log'),
    },
    'mail_admins': {
    'level': 'INFO',
    'class': 'django.utils.log.AdminEmailHandler',
    'filters': [],
    'include_html': True,
    }
    },
    'loggers': {
    '' :{
    'handlers': ['file','mail_admins'],
    'level': 'INFO',
    'propagate': True,
    },
    'django': {
    'handlers': ['file','mail_admins'],
    'level': 'INFO',
    'propagate': True,
    },
    },
    }

    • @technologyfornoobs
      @technologyfornoobs  3 роки тому

      you need to handle 500 error responses, check for default 500 error in django

  • @harshalizode3140
    @harshalizode3140 2 роки тому

    You didn't explain the filter concept

  • @usamashabirVlog
    @usamashabirVlog 2 роки тому

    logger.info('some message') i am not seeing this in debug3.log file