0

I'm trying to deploy a Django app from the first time using Heroku. But my app is always returning an application error.

When I check heroku logs --tail I get:

FileNotFoundError: [Errno 2] No such file or directory: '/app/CandiBot/logs/08/16.log'

The tree structure of my project looks like this, I think I missed a folder called myproject/ but I guess the issue is not related to that.

CandiEnv/ (venv)
├── Candiapp/ (app)
│   ├── models.py
│   ├── urls.py
│   ├── views.py
│   ├── ...
│   ├── static/
│   │    └──(empty)
│   └── logs/
│        └── 08/16.log  <-- Here is the log file
├── myproject/ (I don't know why I've named it differently)
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├──...
├── manage.py
└── Procfile

Maybe it has to do with my settings.py. The static part looks like this:

STATIC_URL = '/static/'
BASE_DIR= os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = ( #Not sure it's useful
    os.path.join(BASE_DIR, 'static'),
    )

What am I missing here?

0

2 Answers 2

1

This has nothing to do with your static files.

It looks like you're trying to log to a file. That won't work on Heroku due to its ephemeral filesystem: your logs will be lost whenever your dyno restarts. This happens frequently (at least once per day).

Instead, simply write to stdout or stderr. Heroku's logger will collect that output and merge it with logs from other sources. On Django that means setting up a StreamHandler instead of a FileHandler.

Note that Heroku doesn't keep logs very long. Given that you were trying to write to a file named after the current date I suspect that you might want to hang onto more than the most recent 1,500 messages / last seven days of messages. In that case, a logging addon is the simplest solution and a log drain is the most powerful.

Sign up to request clarification or add additional context in comments.

Comments

0

Git does not handle empty folder well.

Try deleting the empty folder at CandiEnv/Candispo/static/ and 08/16.log. Even though this has a file extension I am guessing it is a folder with a . in the name.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.