views:

157

answers:

1

I've the following file to config logging:

[loggers]
keys=root

[handlers]
keys = root

[formatters]
keys = generic

# Loggers
[logger_root]
level = DEBUG
handlers = root

# Handlers
[handler_root]
class = handlers.RotatingFileHandler
args = ("test.log", "maxBytes=1*1024*1024", "backupCount=10")
level = NOTSET
formatter = generic

# Formatters
[formatter_generic]
format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %Y-%m-%d %H:%M:%S

In Development this works great, but when I deploy the application test.log is trying to be written in a path in which I don't have the necessary permission.

So my question is, How can I do to specify a relative path in this configuration file.

+2  A: 

Mark is right, your path in the config file is relative to whatever directory is current when the logging.config.fileConfig call is made. This depends on the details of your deployment method.

You may need to specify an absolute path to your file, by prefixing 'test.log' with a directory you know to be writable by the process running your code.

Another problem might just be a permissions issue with the user your Django process runs under: typically when running the development server it runs under your account and you will typically not encounter permissions issues. When deploying (with Apache and mod_wsgi, say) the Apache process and/or mod_wsgi daemon process run under different accounts which may need to be given permission to the relevant folder.

If you need more help, please give more details about your deployment with respect to the method, location of log file directory etc.

Vinay Sajip
Ok, no problem I'll add the absolute path to test.log and keep going :) I just thought that there was a change to specify a relative path to the conf file :)
ClaudioA