Skip to content

Commit 927bcc3

Browse files
committed
logging
1 parent 151e2c7 commit 927bcc3

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ py310.yml
1010
ssulocker/ssulocker/__pycache__/
1111
ssulocker/locker/__pycache__/
1212
ssulocker/locker/views/__pycache__/
13+
logs

ssulocker/ssulocker/settings.py

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# SECURITY WARNING: don't run with debug turned on in production!
2424
DEBUG = True
2525

26-
ALLOWED_HOSTS = ["ec2-13-209-167-172.ap-northeast-2.compute.amazonaws.com","localhost","13.209.167.172","ssuitlocker.kro.kr"]
26+
ALLOWED_HOSTS = ["ssuitlocker.kro.kr","localhost"]
2727
#cookie(login) duration
2828
SESSION_COOKIE_AGE=600
2929
SESSION_SAVE_EVERY_REQUEST=True
@@ -138,4 +138,59 @@
138138

139139
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
140140
LOGIN_URL='/locker/login'
141-
LOGIN_REDIRECT_URL='/locker/lockerlist'
141+
LOGIN_REDIRECT_URL='/locker/lockerlist'
142+
143+
LOGGING = {
144+
'version': 1,
145+
'disable_existing_loggers': False,
146+
'filters': {
147+
'require_debug_false': {
148+
'()': 'django.utils.log.RequireDebugFalse',
149+
},
150+
'require_debug_true': {
151+
'()': 'django.utils.log.RequireDebugTrue',
152+
},
153+
},
154+
'formatters': {
155+
'django.server': {
156+
'()': 'django.utils.log.ServerFormatter',
157+
'format': '[{server_time}] {message}',
158+
'style': '{',
159+
},
160+
'standard':{
161+
'format': '%(asctime)s [%(levelname)s] %(name)s : %(message)s'
162+
},
163+
},
164+
'handlers': {
165+
'console': {
166+
'level': 'INFO',
167+
'filters': ['require_debug_true'],
168+
'class': 'logging.StreamHandler',
169+
},
170+
'django.server': {
171+
'level': 'INFO',
172+
'class': 'logging.StreamHandler',
173+
'formatter': 'django.server',
174+
},
175+
'file':{
176+
'level': 'INFO',
177+
'filters': ['require_debug_false'],
178+
'class': 'logging.handlers.RotatingFileHandler',
179+
'filename': BASE_DIR / 'logs/ssulocker.log',
180+
'maxBytes': 1024*1024*50,
181+
'backupCount': 5,
182+
'formatter': 'standard',
183+
},
184+
},
185+
'loggers': {
186+
'django': {
187+
'handlers': ['console','file'],
188+
'level': 'INFO',
189+
},
190+
'django.server': {
191+
'handlers': ['django.server'],
192+
'level': 'INFO',
193+
'propagate': False,
194+
},
195+
}
196+
}

0 commit comments

Comments
 (0)