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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With