Код: Выделить всё
import os
def lambda_handler(event, context):
log_file = "/tmp/application.log"
if os.path.exists(log_file):
with open(log_file, "r") as f:
file = f.read()
else:
file = "File does not exist"
return {
"statusCode": 200,
"body": file
}
Код: Выделить всё
import logging
LOG_FILE = "/tmp/application.log"
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s",
handlers=[
logging.FileHandler(LOG_FILE),
logging.StreamHandler(),
]
)
logger = logging.getLogger("my-logger")
Код: Выделить всё
{
"statusCode": 200,
"body": ""
}
Чего мне не хватает? Спасибо.
Я попробовал решение, описанное выше, но журналы не были перенаправлены в файл журнала.
Подробнее здесь: https://stackoverflow.com/questions/793 ... ith-python
Мобильная версия