Spaces:
Sleeping
Sleeping
File size: 588 Bytes
ef6fa9a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import logging
import os
# Define absolute path for logs
LOG_DIR = "/app/logs"
LOG_FILE = os.path.join(LOG_DIR, "backend.log")
# Ensure the logs directory exists
os.makedirs(LOG_DIR, exist_ok=True)
# Configure logging settings
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(message)s",
level=logging.INFO,
handlers=[
logging.FileHandler(LOG_FILE), # Use absolute path
logging.StreamHandler() # Print logs to the console
]
)
logger = logging.getLogger(__name__)
if __name__ == "__main__":
logger.info("Logger is set up correctly!")
|