0

I'm developing Django server on Ubuntu OS. Since there is no browser on that machine, I can only debug the server remotely. So I just configure it with Apache and WSGI, and now I can access it through machine public IP.

Then I want to record logs in some views for debugging, if I output the log to a file, I can see it in the file, but if I want to output it to the console, I just get confused here, where is the console? since I didn't launch it with python manage.py runserver manually, currently running server process was launched by WSGI automatically. Of course, I can just stop the process launched by WSGI, and re-launch it with python manage.py runserver manually. If so, I can't access it through machine public IP.

So how can I see logs in the console in putty

2 Answers 2

3

Firstly, you shouldn't be developing on the server. Do that locally and debug in the usual way there.

If you're debugging production issues, you will indeed need to use the log files. But it's pretty simple to see those in the console; you can do tail -f /var/log/my_log_file.log and the console will show the log as it is being written.

Sign up to request clarification or add additional context in comments.

Comments

0

You cannot output it to the console. Since the process is not called from a console, you cannot see the stdout in a console. You can only redirect the output to a file and read the file.

If at all you want the logs in the console, then you have to call the django server from console. i.e python manage.py runserver, which should only be used for development time, as this server is not good to be used in production

3 Comments

But I can't access it through machine public ip without wsgi
@ybbaigo: Writing it to a file is the best option. Why don't you do that?
Of course you can use Django's runserver with the servers public IP: ./manage.py runserver 0.0.0.0:8000 will let Django listen to port 8000. I use this while developing using a VM locally on my machine (of course with portforwarding).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.