Skip to content

Commit

Permalink
starter logging configuration
Browse files Browse the repository at this point in the history
Based on the example in
http://ianalexandr.com/blog/getting-started-with-django-logging-in-5-minutes.html
with tweaks inspired by an example from my dayjob.

[#23]
  • Loading branch information
zackmdavis committed Sep 25, 2014
1 parent e8605da commit b29c27e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ static/libs/jquery-2.1.1.min.js
static/libs/underscore-min.js
static/libs/underscore-min.map

# logs
logs/finetooth.log*

# the database
db.sqlite3
32 changes: 32 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,35 @@
STATICFILES_DIRS = ("static",)

STATIC_URL = '/static/'

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'log_format': {
'format' : ("[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] "
"%(message)s")
},
},
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'maxBytes': 1 * (1024)**2, # 1 MiB
'backupCount': 3,
'filename': 'logs/finetooth.log',
'formatter': 'log_format'
},
},
'loggers': {
'django': {
'handlers':['file'],
'propagate': True,
'level':'DEBUG',
},
'core': {
'handlers': ['file'],
'level': 'DEBUG',
},
}
}

0 comments on commit b29c27e

Please sign in to comment.