X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=sfa%2Futil%2Fsfalogging.py;h=0e17ccbaff46ef61e1b5fc3a9dc07d7f315c4732;hb=952322d76247f8991f3c2688ed7e1f5a22ca4572;hp=ff08c0826bf3ab036530e123b8737f7986d3e4b9;hpb=43b44e012032d6a63d38bdf98caa25988fc27933;p=sfa.git diff --git a/sfa/util/sfalogging.py b/sfa/util/sfalogging.py index ff08c082..0e17ccba 100644 --- a/sfa/util/sfalogging.py +++ b/sfa/util/sfalogging.py @@ -1,17 +1,20 @@ import logging +import os #SFA access log initialization - +TMPDIR = os.getenv("TMPDIR", "/tmp") +SFA_HTTPD_ACCESS_LOGFILE = TMPDIR + "/" + 'sfa_httpd_access.log' SFA_ACCESS_LOGFILE='/var/log/sfa_access.log' -SFA_HTTPD_ACCESS_LOGFILE='/tmp/sfa_httpd_access.log' logger=logging.getLogger() logger.setLevel(logging.INFO) + try: - logfile=logging.FileHandler(SFA_ACCESS_LOGFILE) + logfile=logging.FileHandler(SFA_ACCESS_LOGFILE) except IOError: - # This is usually a permissions error becaue the file is - # owned by root, but httpd is trying to access it. - logfile=logging.FileHandler(SFA_HTTPD_ACCESS_LOGFILE) + # This is usually a permissions error becaue the file is + # owned by root, but httpd is trying to access it. + logfile=logging.FileHandler(SFA_HTTPD_ACCESS_LOGFILE) + formatter = logging.Formatter("%(asctime)s - %(message)s") logfile.setFormatter(formatter) logger.addHandler(logfile)