On 09/05/2011 12:58 AM, Gelonida N wrote:
> Hi,
>
> Im am debugging a django application.
>
> If I set DEBUG=True
> then I can see error messages on the browser.
>
> Is there any way to see the same error messages in the server log file?
> Occasionally (especially for rpc client or Ajax requests I would prefer
> looking at the log file instead of looking at the browser error messages)
>
> Thanks for any suggestions.
>
>
I am using Django 1.3
I configured logging and set up a root logger with log level 'DEBUG'
I added one log command and one explicit error in the urls.py file.
I can see the error report in the browser but not in my log files.
For me it would be very helpful if I can log ALL errors on the server
side if I wish to.
Is there any trick?
How to reproduce my problem:
# create a new django project
#----------------------------
django-admin.py startproject logproblem
# enter your project directory
# -----------------------------
cd logproblem
# create a urls.py which prints a log message
# and which causes an error afterwards
# file contents as in the next four lines
#------------------------------------------
# faulty urls.py file
import logging
logging.debug("hello")
1/0 # this will raise a ZeroDivisionError
# Now edit settings.py and change the LOGGING section to:
---------------------------------------------------------
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler'
}
},
'loggers': {
'': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True,
},
}
}
# Now run the server
# ----------------------
./manage.py runserver
The result on the console will only be:
> Quit the server with CONTROL-C.
> hello
> [19/Nov/2011 15:18:32] "GET / HTTP/1.1" 500 79664
On the browser however I see the division by 0 error and the back trace.
For debugging of errors which are caused by a remote host I would really
like to see such kind of errors in the server logs or an any other log.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.