Vingtoft Vingtoft - 1 year ago 96
Python Question

Django "./ runserver" log to file instead of console


python runserver
will initiate Django's development server and all logs are printed to the console.

I need to write the logs in a
file instead of console.

Django logging documentation is good, but I cant seem to configure the logging to log the same as
python runserver

Question: How can I log everything from
./ runserver
to a file?

Answer Source

It is a simple linux redirect, so it should look something like this:

python runserver >> log.log 2>&1

Please note that I've set 8080 as the local port, you should change it according your project.

PS: This method (manage runserver) should be used for development only, not for deployment.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download