Configure logging permissions for Supervisord with Apache2 mod-WSGI + Tornado

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm running Tornado Python application behind apache2 mod-wsgi served by supervisord.



My supervisord config looks like



[supervisord]
nodaemon=true
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
user=root
group=root

[program:apache2]
command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"
redirect_stderr=true
stdout_events_enabled=true
stderr_events_enabled=true
user=root
group=root


and my virtual host is



<VirtualHost *:$PORT>
ServerAdmin webmaster@localhost
ServerName localhost
DocumentRoot /var/www

<Directory />
Options FollowSymLinks
Order allow,deny
Allow from all
</Directory>

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

<Directory /tornado_api>
Order deny,allow
Allow from all
Require all granted
</Directory>

WSGIScriptAlias / /tornado/config.py
WSGIApplicationGroup %GLOBAL

</VirtualHost>


so I'm starting tornado from config.py like



PORT = os.getenv('PORT', 8888)
DIST = os.getenv('DIST', 'prod')

logger = configure_logger('default')
logger.info('Tornado starter on PORT %s ' % PORT)

http_server = HTTPServer( WSGIContainer(app) )
http_server.listen(int(PORT))

ioloop.IOLoop.instance().start()


where the logger takes a default configuration for logging like



def configure_logger(name='default'):
#"%Y%m%d-%H%M%S"
log_path = "/var/log/apache2/tornado_" + time.strftime("%Y%m%d") + ".log"
dictConfig(
'version': 1,
'formatters':
'default': 'format': '%(asctime)s - %(levelname)s - %(message)s', 'datefmt': '%Y-%m-%d %H:%M:%S'
,
'handlers':
'console':
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'default',
'stream': 'ext://sys.stdout'
,
'file':
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'default',
'filename': log_path,
'maxBytes': 1024,
'backupCount': 3

,
'loggers':
'default':
'level': 'DEBUG',
'handlers': ['console', 'file']

,
'disable_existing_loggers': False
)
return logging.getLogger(name)


The problem is that I cannot write to the specified logging folder under /var/log/apache2 even if I'm starting my service with mod-WSGI.



Any idea what is misconfigured?









share

























    up vote
    0
    down vote

    favorite












    I'm running Tornado Python application behind apache2 mod-wsgi served by supervisord.



    My supervisord config looks like



    [supervisord]
    nodaemon=true
    logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
    logfile_backups=10 ; (num of main logfile rotation backups;default 10)
    loglevel=info ; (log level;default info; others: debug,warn,trace)
    user=root
    group=root

    [program:apache2]
    command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"
    redirect_stderr=true
    stdout_events_enabled=true
    stderr_events_enabled=true
    user=root
    group=root


    and my virtual host is



    <VirtualHost *:$PORT>
    ServerAdmin webmaster@localhost
    ServerName localhost
    DocumentRoot /var/www

    <Directory />
    Options FollowSymLinks
    Order allow,deny
    Allow from all
    </Directory>

    <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

    <Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
    </Directory>

    <Directory /tornado_api>
    Order deny,allow
    Allow from all
    Require all granted
    </Directory>

    WSGIScriptAlias / /tornado/config.py
    WSGIApplicationGroup %GLOBAL

    </VirtualHost>


    so I'm starting tornado from config.py like



    PORT = os.getenv('PORT', 8888)
    DIST = os.getenv('DIST', 'prod')

    logger = configure_logger('default')
    logger.info('Tornado starter on PORT %s ' % PORT)

    http_server = HTTPServer( WSGIContainer(app) )
    http_server.listen(int(PORT))

    ioloop.IOLoop.instance().start()


    where the logger takes a default configuration for logging like



    def configure_logger(name='default'):
    #"%Y%m%d-%H%M%S"
    log_path = "/var/log/apache2/tornado_" + time.strftime("%Y%m%d") + ".log"
    dictConfig(
    'version': 1,
    'formatters':
    'default': 'format': '%(asctime)s - %(levelname)s - %(message)s', 'datefmt': '%Y-%m-%d %H:%M:%S'
    ,
    'handlers':
    'console':
    'level': 'DEBUG',
    'class': 'logging.StreamHandler',
    'formatter': 'default',
    'stream': 'ext://sys.stdout'
    ,
    'file':
    'level': 'DEBUG',
    'class': 'logging.handlers.RotatingFileHandler',
    'formatter': 'default',
    'filename': log_path,
    'maxBytes': 1024,
    'backupCount': 3

    ,
    'loggers':
    'default':
    'level': 'DEBUG',
    'handlers': ['console', 'file']

    ,
    'disable_existing_loggers': False
    )
    return logging.getLogger(name)


    The problem is that I cannot write to the specified logging folder under /var/log/apache2 even if I'm starting my service with mod-WSGI.



    Any idea what is misconfigured?









    share























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm running Tornado Python application behind apache2 mod-wsgi served by supervisord.



      My supervisord config looks like



      [supervisord]
      nodaemon=true
      logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
      logfile_backups=10 ; (num of main logfile rotation backups;default 10)
      loglevel=info ; (log level;default info; others: debug,warn,trace)
      user=root
      group=root

      [program:apache2]
      command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"
      redirect_stderr=true
      stdout_events_enabled=true
      stderr_events_enabled=true
      user=root
      group=root


      and my virtual host is



      <VirtualHost *:$PORT>
      ServerAdmin webmaster@localhost
      ServerName localhost
      DocumentRoot /var/www

      <Directory />
      Options FollowSymLinks
      Order allow,deny
      Allow from all
      </Directory>

      <Directory /var/www/>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all
      </Directory>

      ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

      <Directory "/usr/lib/cgi-bin">
      AllowOverride None
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
      Order allow,deny
      Allow from all
      </Directory>

      <Directory /tornado_api>
      Order deny,allow
      Allow from all
      Require all granted
      </Directory>

      WSGIScriptAlias / /tornado/config.py
      WSGIApplicationGroup %GLOBAL

      </VirtualHost>


      so I'm starting tornado from config.py like



      PORT = os.getenv('PORT', 8888)
      DIST = os.getenv('DIST', 'prod')

      logger = configure_logger('default')
      logger.info('Tornado starter on PORT %s ' % PORT)

      http_server = HTTPServer( WSGIContainer(app) )
      http_server.listen(int(PORT))

      ioloop.IOLoop.instance().start()


      where the logger takes a default configuration for logging like



      def configure_logger(name='default'):
      #"%Y%m%d-%H%M%S"
      log_path = "/var/log/apache2/tornado_" + time.strftime("%Y%m%d") + ".log"
      dictConfig(
      'version': 1,
      'formatters':
      'default': 'format': '%(asctime)s - %(levelname)s - %(message)s', 'datefmt': '%Y-%m-%d %H:%M:%S'
      ,
      'handlers':
      'console':
      'level': 'DEBUG',
      'class': 'logging.StreamHandler',
      'formatter': 'default',
      'stream': 'ext://sys.stdout'
      ,
      'file':
      'level': 'DEBUG',
      'class': 'logging.handlers.RotatingFileHandler',
      'formatter': 'default',
      'filename': log_path,
      'maxBytes': 1024,
      'backupCount': 3

      ,
      'loggers':
      'default':
      'level': 'DEBUG',
      'handlers': ['console', 'file']

      ,
      'disable_existing_loggers': False
      )
      return logging.getLogger(name)


      The problem is that I cannot write to the specified logging folder under /var/log/apache2 even if I'm starting my service with mod-WSGI.



      Any idea what is misconfigured?









      share













      I'm running Tornado Python application behind apache2 mod-wsgi served by supervisord.



      My supervisord config looks like



      [supervisord]
      nodaemon=true
      logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
      logfile_backups=10 ; (num of main logfile rotation backups;default 10)
      loglevel=info ; (log level;default info; others: debug,warn,trace)
      user=root
      group=root

      [program:apache2]
      command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"
      redirect_stderr=true
      stdout_events_enabled=true
      stderr_events_enabled=true
      user=root
      group=root


      and my virtual host is



      <VirtualHost *:$PORT>
      ServerAdmin webmaster@localhost
      ServerName localhost
      DocumentRoot /var/www

      <Directory />
      Options FollowSymLinks
      Order allow,deny
      Allow from all
      </Directory>

      <Directory /var/www/>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all
      </Directory>

      ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

      <Directory "/usr/lib/cgi-bin">
      AllowOverride None
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
      Order allow,deny
      Allow from all
      </Directory>

      <Directory /tornado_api>
      Order deny,allow
      Allow from all
      Require all granted
      </Directory>

      WSGIScriptAlias / /tornado/config.py
      WSGIApplicationGroup %GLOBAL

      </VirtualHost>


      so I'm starting tornado from config.py like



      PORT = os.getenv('PORT', 8888)
      DIST = os.getenv('DIST', 'prod')

      logger = configure_logger('default')
      logger.info('Tornado starter on PORT %s ' % PORT)

      http_server = HTTPServer( WSGIContainer(app) )
      http_server.listen(int(PORT))

      ioloop.IOLoop.instance().start()


      where the logger takes a default configuration for logging like



      def configure_logger(name='default'):
      #"%Y%m%d-%H%M%S"
      log_path = "/var/log/apache2/tornado_" + time.strftime("%Y%m%d") + ".log"
      dictConfig(
      'version': 1,
      'formatters':
      'default': 'format': '%(asctime)s - %(levelname)s - %(message)s', 'datefmt': '%Y-%m-%d %H:%M:%S'
      ,
      'handlers':
      'console':
      'level': 'DEBUG',
      'class': 'logging.StreamHandler',
      'formatter': 'default',
      'stream': 'ext://sys.stdout'
      ,
      'file':
      'level': 'DEBUG',
      'class': 'logging.handlers.RotatingFileHandler',
      'formatter': 'default',
      'filename': log_path,
      'maxBytes': 1024,
      'backupCount': 3

      ,
      'loggers':
      'default':
      'level': 'DEBUG',
      'handlers': ['console', 'file']

      ,
      'disable_existing_loggers': False
      )
      return logging.getLogger(name)


      The problem is that I cannot write to the specified logging folder under /var/log/apache2 even if I'm starting my service with mod-WSGI.



      Any idea what is misconfigured?







      apache-httpd python





      share












      share










      share



      share










      asked 4 mins ago









      loretoparisi

      17812




      17812

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f474889%2fconfigure-logging-permissions-for-supervisord-with-apache2-mod-wsgi-tornado%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f474889%2fconfigure-logging-permissions-for-supervisord-with-apache2-mod-wsgi-tornado%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)