Since your handler is used for the "myproject" logger, to use that handler all your apps would have to use loggers descended from that logger, that is, all your apps would have to use something like:
logging.getLogger('myproject')Also uncomfortable is that if you want apps that you have pip installed (as opposed to having copied into your project's directory) have to be modified to use this scheme.
On Fri, Jul 26, 2013 at 10:01 PM, David Kumar <dathku@gmail.com> wrote:
I have a standard logger that I would like to use for all of my applications, the only thing I want to change is the name of the file. Is there a way to do that with out having to create a logger and handler for each of my apps.
Here is the logging settings that I am using.
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
'format' : "[%(asctime)s] %(levelname)s [%(module)s:%(lineno)s] %(message)s",
'datefmt' : "%d/%b/%Y %H:%M:%S"
},
},
'handlers': {
'app_logger': {
'level':'DEBUG',
'class':'logging.handlers.TimedRotatingFileHandler',
'filename': '/var/log/django/app.log',
'backupCount': 5,
'when' : 'midnight',
'formatter': 'standard',
},
},
'loggers': {
'myproject': {
'handlers': ['app_logger'],
'level': 'INFO',
}
}
}
In my app I would like to be able to override the 'filename': '/var/log/django/another_app.log',
import logging<change log file to '/var/log/django/another_app.log'>
log = logging.getLogger('myproject')
log.info("Something here")
Any ideas?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment