import logging
import traceback

# Configure logging
logging.basicConfig(
    filename="/var/www/html/Python_Scripts/test_script.log",
    level=logging.DEBUG,
    format="%(asctime)s - %(levelname)s - %(message)s"
)

try:
    logging.info("Starting the script...")
    # Simulate some code execution
    print("Running script...")
    raise ValueError("Test error for logging!")  # Example error
except Exception as e:
    logging.error(f"An error occurred: {e}")
    logging.debug(traceback.format_exc())
