def log_file_console():
    """Create a console that logs to a file.

    Returns:
        A Console object that logs to a file.
    """
    from reflex.environment import environment

    if not (env_log_file := environment.REFLEX_LOG_FILE.get()):
        subseconds = int((time.time() % 1) * 1000)
        timestamp = time.strftime("%Y-%m-%d_%H-%M-%S") + f"_{subseconds:03d}"
        log_file = Reflex.DIR / "logs" / (timestamp + ".log")
        log_file.parent.mkdir(parents=True, exist_ok=True)
    else:
        log_file = env_log_file
    if log_file.exists():
        log_file.unlink()
    log_file.touch()
    return Console(file=log_file.open("a", encoding="utf-8"))
Create a console that logs to a file.

    Returns:
        A Console object that logs to a file.
    
reflex/utils/console.py