Spaces:
Sleeping
Sleeping
| 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!") | |