I am logging errors in django app. In logging settings I have below configuration -
'handlers':{
'errors_file':{
'level':'ERROR',
'class':'logging.handlers.TimedRotatingFileHandler',
'when':'midnight',
'interval':1,
'filename':'logs/ErrorLoggers.log',
'formatter':'large',
}
}
So whenever there is any error in views, error is logged in /home/username/projectFolder/log/ErrorLoggers.log
file.
On web tab working directory is set to /home/username/projectFolder
. Source code is also in same directory.
I have also scheduled a task on schedule tab as given below
/home/username/virtual_env/bin/python3.4 /home/username/projectFolder/manage.py command_name
Inside command also I am using logging to log errors. However command is complaining that it could not find file log/ErrorLogger.log
. So I created directory (hit and try) /home/username/log
i.e. outside project folder. And this time scheduled task executed perfectly and errors were logged in newly created directory.
So why is this happening? Why errors are being logged in different directories in these case.