Skip to content

Instantly share code, notes, and snippets.

@rehbarkhan
Last active May 16, 2023 17:59
Show Gist options
  • Save rehbarkhan/0ae33f589a01ccc8d572a61fb4ae5b92 to your computer and use it in GitHub Desktop.
Save rehbarkhan/0ae33f589a01ccc8d572a61fb4ae5b92 to your computer and use it in GitHub Desktop.
Django Loggin Enable
LOGGING = {
'version':1,
'disable_existing_loggers':False,
'formatters':{
'main_formatter':{
'format':"{asctime} {levelname} {pathname} {module} {lineno} {message}",
"style":"{"
}
},
'handlers':{
# 'console':{
# 'class':'logging.StreamHandler',
# 'formatter':'main_formatter'
# },
'file':{
'class':'logging.FileHandler',
'filename':'info.log',
'formatter':'main_formatter'
}
},
'loggers':{
'main':{
'handlers':['file'],
'propagate':True,
'level':'INFO'
}
}
}
import logging
logger = logging.getLogger('main')
logger.debug("This is debug msg which will be getting printed on the log file")
@rehbarkhan
Copy link
Author

This is the piece of code for the Django logging system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment