Django Apache2 Logging and REST Problems
NickName:Spinnaay Ask DateTime:2017-07-18T18:00:43

Django Apache2 Logging and REST Problems

I have deployed a Django app using Apache2 and it works fine.

However when I add either REST framework or logging the app doesn't respond properly.

To note is that all works fine using 'manage.py runserver'. I just fails running under Apache2.

The problems are

REST The service doesn't recognize JSON input and accepts anything typed in the web interface input box despite having JSON selected as the input. Whatever is typed just gives back a 201 response despite having a working serialiser in place.

Logging The whole application doesn't boot when logging is in the settings.py file. If I comment it out it boots fine. Again it works in the demo server setup.

Apache2 Config

<VirtualHost *:80>

WSGIScriptAlias / /home/user/portal_interface/portal/wsgi.py

    Alias /static /home/user/portal_interface/interface/static

    <Directory /home/user/portal_interface/interface/static>
            Require all granted
    </Directory>

    <Directory /home/user/portal_interface/portal>
            <Files wsgi.py>
                    Require all granted
            </Files>
    </Directory>

    WSGIDaemonProcess portal python-path=/home/user/portal_interface:/var/www/sampleapp/env/lib/python2.7/site-packages
    WSGIProcessGroup portal

</VirtualHost>

Logging

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
    'file': {
        'level': 'DEBUG',
        'class': 'logging.FileHandler',
        'filename': os.path.join(BASE_DIR, 'debug.log'),
    }
},
'loggers': {
    'django': {
        'handlers': ['file'],
        'level': 'DEBUG',
        'propagate': True,
    }
  }
}

Copyright Notice:Content Author:「Spinnaay」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/45163464/django-apache2-logging-and-rest-problems

More about “Django Apache2 Logging and REST Problems” related questions

Django Apache2 Logging and REST Problems

I have deployed a Django app using Apache2 and it works fine. However when I add either REST framework or logging the app doesn't respond properly. To note is that all works fine using 'manage.py

Show Detail

Logging requests to django-rest-framework

For debugging purposes, I would like to use Django's logging mechanism to log each and every incoming request when it "arrives" at django-rest-framework's doorstep. Djagno offers logging of its re...

Show Detail

Django logging do not log with Apache

My django logging works perfectly on localhost. When I pushed it to the server (with Apache), it stops working. In tail /var/log/apache2/error.log was reported problem with permission, so I add the

Show Detail

How to configure apache2 on ubuntu for django restful services

I have django restful services on my ubuntu server which are running on port 84. When the request is send, it come through the apache2 server which is running on port 80. Now let say my server ...

Show Detail

django rest framework - understanding authentication and logging in

I am a beginner to django rest framework (and to REST in general) and I have a server side which (for now) has a UserViewSet which allows to register new users and I can POST to the url from my and...

Show Detail

apache2 with django - can't write to log file

I have django running on apache2 server. my settings.py looks like this: WSGI_APPLICATION = 'my_app.wsgi.application' ... LOGGING = { 'version': 1, 'disable_existing_loggers': False,

Show Detail

What permission/user does apache2 use to write django logs

I have very good question which I would like an expert to comment on that for me please. (perhaps Graham Dumpleton) So I have a Django web application (developed on ubuntu 16.04) which loges some

Show Detail

Deploy django with apache2

(I am in way over my head) I am trying to deploy my django server on apache2. I have already buildt a quite large front-end application (that is currently deployed with apache2) and do not want to ...

Show Detail

Logging with django rest framework with WSGI

I am fairly new in backend development. I was trying to write some log with Django rest framework. I set up the WSGI mode and the 000-default.conf file is &lt;VirtualHost *:80&gt; ServerAdmin user@...

Show Detail

Django rest framework logging different levels on different files

I am working on Django REST framework and I want to have separate files for logging data. I want to have a file for the simple transactions e.g. GET, PUT, POST etc. and one file with the errors th...

Show Detail