On 27 jan, 11:31, Rama <ramaakrish...@gmail.com> wrote: > please look at the below logging.conf file.http://dpaste.com/hold/113443/ > > For RotatingFileHandler [handler_rfileHandler] i have hard coded the log > file path as "/home/rama/djangoprojects/doloto/logs/logs.txt" > how to avoid such hard coding of log file path in the logging.conf file.
1/ in your settings.py file: LOG_PATH = "/whatever/you/want.log" 2/ in the code calling logging.config.fileConfig: from django.core.exceptions import ImproperlyConfigured from django.conf import settings try: LOG_PATH = settings.LOG_PATH except AttributeError: raise ImproperlyConfigured("missing configuration : LOG_PATH") import logging logging.config.fileConfig(LOG_PATH, defaults=dict(log_path=LOG_PATH)) 3/ in your logging.conf [handler_rfileHandler] class=handlers.RotatingFileHandler level=DEBUG formatter=simpleFormatter args=(%(log_path)s,'a',5000000,5) Not tested, but this should do the trick. If it doesn't, you may have to provide the whole value for 'args', ie: in 2/ log_args = (LOG_PATH, 'a', 5000000, 5) logging.config.fileConfig(LOG_PATH, defaults=dict(log_args=log_args)) in 3/ args=%(log_args)s HTH --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---