Skip to content

Commit 0220388

Browse files
committed
Added Django docs to README.md.
1 parent 3c0de18 commit 0220388

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,59 @@ Start your app and look at /var/log/loghogd/my-first-app/ to see your applicatio
7979

8080
For more extensive configuration, see the examples directory.
8181

82+
**Step 4: Django**: If you want to use LogHog with your Django application, add
83+
the following code to your settings.py:
84+
85+
LOGHOG_APP_NAME = 'my-first-app'
86+
87+
LOGGING = {
88+
'version': 1,
89+
'disable_existing_loggers': True,
90+
'formatters': {
91+
'simple': {
92+
'format': '%(levelname)s - %(message)s'
93+
},
94+
},
95+
'handlers': {
96+
'root':{
97+
'level':'DEBUG',
98+
'class':'loghog.LoghogHandler',
99+
'app_name': LOGHOG_APP_NAME,
100+
'formatter': 'simple',
101+
},
102+
},
103+
'loggers': {
104+
'root': {
105+
'handlers':['root', ],
106+
'propagate': False,
107+
'level': 'INFO',
108+
},
109+
'django': {
110+
'handlers':['root', ],
111+
'propagate': False,
112+
'level': 'INFO',
113+
},
114+
'django.request': {
115+
'handlers': ['root', ],
116+
'level': 'INFO',
117+
'propagate': False,
118+
},
119+
}
120+
}
121+
122+
Now, all default logging from within Django will be sent to the LogHog server.
123+
If you want to send log messages from within your code, you can:
124+
125+
import logging
126+
logger = logging.getLogger('django')
127+
128+
def view(request):
129+
# ...
130+
logger.info('Hello world')
131+
# ...
132+
return response
133+
134+
82135
## Configuration
83136

84137
LogHog can do a lot of things for you. It can rotate files based on a schedule or file size,

0 commit comments

Comments
 (0)