Skip to content

flask logging to file #446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/server/api/admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ def upload_csv():
try:
validate_and_arrange_upload(file)
except Exception as e:
current_app.logger.exception(e)
current_app.logger.error(e)
finally:
file.close()
else:
current_app.logger.error("File of bad format")

return redirect(request.origin)

Expand Down
8 changes: 6 additions & 2 deletions src/server/app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import logging

from flask import Flask

from flask_jwt_extended import JWTManager


try:
from secrets_dict import JWT_SECRET, APP_SECRET_KEY
except ImportError:
Expand Down Expand Up @@ -46,12 +47,15 @@
app.register_blueprint(user_api)
app.register_blueprint(internal_api)

app.logger.setLevel('INFO') # By default, Docker appears to set at INFO but VSCode at WARNING
logging.basicConfig(filename='error.log', level=logging.ERROR, format=f'%(asctime)s %(levelname)s %(name)s : %(message)s')

# init_db_schema.start(connection)


if __name__ == "__main__":
import logging


FLASK_PORT = os.getenv("FLASK_PORT", None)

# create_app()
Expand Down