Hello All,

Firstly let me say that I have done my best over the past couple weeks to 
find a solution to this problem, but have come up with no concrete 
solutions, mostly because of limitations in my corporate environment. I've 
found many helpful resources such as this 
one https://www.youtube.com/watch?v=H6Q3l11fjU0, but am coming straight to 
the source for this question. 

*How can I change the log location of mod_wsgi output (the app output) 
without defining my app under a separate virtual host?*

I am hosting a Django Application using Python 3.7.10 on a RHEL7 server 
using Apache version 2.4 and mod_wsgi version 4.8.0. This server uses only 
a single virtual host to host multiple corporate applications (java, perl, 
python etc), and this server hosts them typically using proxies and 
locations under the single virtual host server01.corp.com:443. Because 
domain name is important and cannot be changed due to "its the way we have 
always done things", my django app must be hosted at server01.corp.com and 
aliased to a script path /apps/djangosite. Therefore, a conf.d for the site 
looks like this:
-----------------------------------------------------------------
<Location "/apps/djangosite ">
    #How all other apps are hosted on server01.corp.com using a proxy
    #ProxyPass "http://127.0.0.1:9889"; retry=0
    #ProxyPassReverse "http://127.0.0.1:9889";
   <IF "req('Authorization') =~ /^Bearer/">
       #stuff
   </IF>
   <ELSE>
        #stuff but with ldap
   </ELSE>

    Require valid-user
    # Forward the REMOTE_USER env var as a request header
    RequestHeader set X-Remote-User %{REMOTE_USER}s
    RequestHeader set X-Remote-Host %{REMOTE_HOST}s

    #Add some variables for Django
    #RequestHeader set X-Script-Name /apps/djangosite/
    #RequestHeader set X-Forwarded-Script-Name /apps/djangosite/
</Location>

#mod_wsgi Specific Entries
<Directory /fullpath/mysite/static>
    Options FollowSymLinks Includes
    Require all granted
</Directory>

Alias /apps/djangosite/static/ /fullpath/mysite/static/

<Directory /fullpath/mysite>
    <Files wsgi.py>
         Require all granted
    </Files>
</Directory>

WSGIDaemonProcess djangosite-api processes=2 threads=15 
python-home=/fullpath/envs/djangosite_api/ user=corpuser 
home=/fullpath/djangosite python-path=/fullpath:/fullpath:/fullpath
WSGIProcessGroup djangosite-api
WSGIScriptAlias /apps/djangosite /fullpath/mysite/wsgi.py 
process-group=compute-api
WSGIRestrictEmbedded On
WSGIApplicationGroup %{GLOBAL}

#pull mod_wsgi out of ssl_error_log
SetEnvIf Request_URI ^/apps/djangosite(/.*|$) djangosite-api
CustomLog /fullpath/logs/djangosite.debug.log combined env=djangosite-api
LogLevel debug wsgi:Trace8
-----------------------------------------------------------------

 Logging Directives in settings.py
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '{levelname} {asctime} {module} {process:d} 
{thread:d} {message}',
            'style': '{',
        },
    },
    'handlers': {
        'file': {
            'level': 'DEBUG',
            #'class':'logging.StreamHandler'
            'class': 'logging.FileHandler',
            'filename': ' /fullpath/logs/djangosite.debug.log  '
        }
    },
    'root': {
        'handlers': ['file'],
        'level': 'DEBUG',
    },
    'loggers': {
        'django': {
            'handlers': ['file'],
            'level': 'INFO',
            'propagate': True,
        }
    }
}

And so here is the problem: With over 10 other deployed apps on 
server01.corp.com, the ssl_error_log of this one virtual host is pretty 
quick to bury messages, and I want to be able to get my apps log in a 
specific location, rather then sifting through the hosts log. If I was able 
to create another host, this wouldnt be an issue obviously. I can get 
django debug info from the logging directive, and some very slight request 
logging from setting the custom log above, but I will never be able to get 
stack traces or wsgi startup info unless I go to the ssl_error_log. I have 
read the warnings on a portable application using stderr/stdout, and have 
tried to make the application as portable as the development environment 
will allow. I cannot find a way to change the log location of a specific 
module in apache. I tried gunicorn as a alternative to mod_wsgi, but 
mod_wsgi has a cleaner setup for us and apache/gunicorn struggled to host 
djangosite on anything other than the root /. 

Is there any way to circumvent this inability to create another virtualhost 
while still having full control of logging?

Thank you for your time,
Matt J

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/modwsgi/fc14abce-0f43-4e35-a91e-05310847947an%40googlegroups.com.

Reply via email to