Logging in Django Application || Django tutorial 2020 ||

  Рет қаралды 28,167

Technology for Noobs

Technology for Noobs

Күн бұрын

Пікірлер: 96
@jakebarker6962
@jakebarker6962 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!
@technologyfornoobs
@technologyfornoobs 2 жыл бұрын
Great to hear!
@yashpatel9550
@yashpatel9550 4 жыл бұрын
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
@technologyfornoobs
@technologyfornoobs 4 жыл бұрын
You're very welcome!
@AyazAmlani
@AyazAmlani 2 жыл бұрын
11:57 had me cracking up! "I'm in the logger, if you care...." bahahaha
@manishshetake1555
@manishshetake1555 3 жыл бұрын
Thank you for your unique explaination, I came for this video by accident.😍
@technologyfornoobs
@technologyfornoobs 3 жыл бұрын
You're welcome 😊
@manishshetake1555
@manishshetake1555 3 жыл бұрын
@@technologyfornoobs Keep doing such stuff and motivate us to learn & grow with you🤞
@geoafrikana
@geoafrikana Жыл бұрын
Great teacher. Thanks bro.
@technologyfornoobs
@technologyfornoobs Жыл бұрын
Welcome
@kamleshmahadule8238
@kamleshmahadule8238 3 жыл бұрын
What a explationation, never seen ever. 👌👌
@technologyfornoobs
@technologyfornoobs 3 жыл бұрын
Thanks!
@vijayrajput3297
@vijayrajput3297 3 жыл бұрын
Thank you for such a wonderful explanation about Django logging module.👏
@technologyfornoobs
@technologyfornoobs 3 жыл бұрын
You are welcome!
@pavanjain2178
@pavanjain2178 Жыл бұрын
Really helpful brother❤
@technologyfornoobs
@technologyfornoobs Жыл бұрын
Glad to hear that
@rood486
@rood486 3 жыл бұрын
This is a great video. Thanks for your example and your explanation.
@technologyfornoobs
@technologyfornoobs 3 жыл бұрын
You're very welcome!
@asztro
@asztro 2 жыл бұрын
Nice
@technologyfornoobs
@technologyfornoobs Жыл бұрын
Thanks
@LuadoO
@LuadoO 2 жыл бұрын
Best out there sir, good job
@technologyfornoobs
@technologyfornoobs 2 жыл бұрын
Thanks!
@diPpYzPIANO
@diPpYzPIANO 2 жыл бұрын
Bravo !!! It was an awesome explanation... thanks
@technologyfornoobs
@technologyfornoobs 2 жыл бұрын
Glad it was helpful!
@EdgarSkipper
@EdgarSkipper Жыл бұрын
why is this not working when I run the server with >> mod_wsgi-express start ??
@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
@sujithsuji6170
@sujithsuji6170 3 жыл бұрын
Superb bro great work help me a lot..🥰🥰🥰💝💝
@technologyfornoobs
@technologyfornoobs 3 жыл бұрын
Welcome 😊
@azeyn2050
@azeyn2050 4 жыл бұрын
Great explanation! Thanks a heap!
@technologyfornoobs
@technologyfornoobs 4 жыл бұрын
You're welcome!
@paulcurious2324
@paulcurious2324 3 жыл бұрын
Not a stack?
@joy_sam_raj
@joy_sam_raj 2 жыл бұрын
Thanks sir
@technologyfornoobs
@technologyfornoobs 2 жыл бұрын
All the best
@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 Жыл бұрын
@@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
@gops3843
@gops3843 4 жыл бұрын
tysm sir for this video and make video on emaillogger
@technologyfornoobs
@technologyfornoobs 4 жыл бұрын
Will check about it.
@tarannumx
@tarannumx 5 ай бұрын
Good explanation sir 🎉🎉❤
@technologyfornoobs
@technologyfornoobs 11 күн бұрын
Thanks and welcome
@techienomadiso8970
@techienomadiso8970 2 жыл бұрын
Superb !!! 🔥🔥🔥👌
@technologyfornoobs
@technologyfornoobs 2 жыл бұрын
Thank you so much 😀
@sunny-lz6uy
@sunny-lz6uy 3 жыл бұрын
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 жыл бұрын
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 жыл бұрын
techfornoobs01@gmail.com
@sunny-lz6uy
@sunny-lz6uy 3 жыл бұрын
@@technologyfornoobs Sir, I have mailed you
@saonidas4140
@saonidas4140 3 жыл бұрын
is there any video to call a python script from html page with input parameters using django?
@technologyfornoobs
@technologyfornoobs 3 жыл бұрын
Not exactly, but it's possible u need to use "exec" and eval
@mannshah6808
@mannshah6808 4 жыл бұрын
Good explanation
@technologyfornoobs
@technologyfornoobs 4 жыл бұрын
Thanks and welcome
@shivamrohilla208
@shivamrohilla208 3 жыл бұрын
can we store loggers and print them in some file
@technologyfornoobs
@technologyfornoobs 3 жыл бұрын
yes, that's what is in the video, or I am missing something.
@revanthkumar3406
@revanthkumar3406 4 жыл бұрын
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.
@balajibalaji9706
@balajibalaji9706 3 жыл бұрын
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 3 жыл бұрын
That's the video is about follow from 11:20
@balajibalaji9706
@balajibalaji9706 3 жыл бұрын
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 3 жыл бұрын
Pull from github and check of the code works in yours and then check the diff what you are missing
@asaadqudsieh8108
@asaadqudsieh8108 3 жыл бұрын
how can i get user name in log?
@technologyfornoobs
@technologyfornoobs 3 жыл бұрын
logger.info('add user')
@hacninetushar
@hacninetushar 3 жыл бұрын
Great!
@technologyfornoobs
@technologyfornoobs 3 жыл бұрын
Yo!
@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 жыл бұрын
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 жыл бұрын
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': '{', } } }
@harshalizode3140
@harshalizode3140 Жыл бұрын
You didn't explain the filter concept
@technologyfornoobs
@technologyfornoobs Жыл бұрын
I think I forgot, I will see when can I include it.
@mohamedferhi3332
@mohamedferhi3332 4 жыл бұрын
how you can pass variables from django views.py to jupyter notebook ???
@technologyfornoobs
@technologyfornoobs 4 жыл бұрын
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
@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 жыл бұрын
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
@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
@hacninetushar
@hacninetushar 3 жыл бұрын
If you make more videos like this!
@technologyfornoobs
@technologyfornoobs 3 жыл бұрын
Sure!
@hacninetushar
@hacninetushar 3 жыл бұрын
@@technologyfornoobs thanks.
@hacninetushar
@hacninetushar 3 жыл бұрын
waiting for that..
@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..
@konchadasrinivas5310
@konchadasrinivas5310 4 жыл бұрын
How can we contact you sir.
@technologyfornoobs
@technologyfornoobs 4 жыл бұрын
Email me @ techfornoobs01@gmail.com
@usamashabirVlog
@usamashabirVlog 2 жыл бұрын
logger.info('some message') i am not seeing this in debug3.log file
@technologyfornoobs
@technologyfornoobs Жыл бұрын
check the settings.
Django Channels Tutorial || Real-time Tables using WebSockets in Django | 2020
48:47
小天使和小丑太会演了!#小丑#天使#家庭#搞笑
00:25
家庭搞笑日记
Рет қаралды 42 МЛН
ЭТО НАСТОЯЩАЯ МАГИЯ😬😬😬
00:19
Chapitosiki
Рет қаралды 3,4 МЛН
The Basics of Django Models
37:32
Pretty Printed
Рет қаралды 99 М.
Build Rest APIs in Django || CRUD Operation || GET || POST || PUT || DELETE
44:45
Tide is perhaps my favorite Rust web app framework.
9:14
Dreams of Code
Рет қаралды 96 М.
Pro Django - Tutorial 3 - Logging
16:28
thenewboston
Рет қаралды 17 М.
Django and Stripe Payments Tutorial
1:10:27
Matt Freire
Рет қаралды 96 М.
小天使和小丑太会演了!#小丑#天使#家庭#搞笑
00:25
家庭搞笑日记
Рет қаралды 42 МЛН