Skip to content

Conversation

@longcw
Copy link
Contributor

@longcw longcw commented Dec 24, 2025

close #4339

for example

def log_setup(logger: logging.Logger, log_level: int | str):
    logger.setLevel(log_level)
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
    logger.addHandler(handler)


if __name__ == "__main__":
    cli.run_app(server, log_setup_fnc=log_setup)

@chenghao-mou chenghao-mou requested a review from a team December 24, 2025 11:57
Copy link
Member

@davidzhao davidzhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally this isn't a CLI parameter, but something they could configure inside their agent? should there be a setup_logger_fnc on the cli itself? so they could make all sorts of customizations as needed.

also I'm not sure if the request is for colored logging.. but rather production systems prefer to parse text instead of JSON

@longcw
Copy link
Contributor Author

longcw commented Dec 25, 2025

ideally this isn't a CLI parameter, but something they could configure inside their agent?

users can remove the json handler in entrypoint but the original issue mentioned that

the JSON handler is only attached when cli.run_app is called. This means it cannot be removed except from within the entrypoint function, in which case there will be a period during which logs are emitted in JSON format.

maybe we can make it a callback of AgentServer or cli.run_app for user to customize rather than adding a CLI parameter.

@davidzhao
Copy link
Member

the JSON handler is only attached when cli.run_app is called. This means it cannot be removed except from within the entrypoint function, in which case there will be a period during which logs are emitted in JSON format.

maybe we can make it a callback of AgentServer or cli.run_app for user to customize rather than adding a CLI parameter.

exactly, entrypoint is a bit too late, the framework logger has already been used by that point.. IMO giving users control is the right path, instead of automatically configuring colored logger

@longcw longcw changed the title add json_logs option to cli add log_setup_fnc for cli.run_app Dec 26, 2025
@longcw longcw requested review from a team and davidzhao December 26, 2025 03:37
@theomonnom
Copy link
Member

theomonnom commented Dec 26, 2025

I'm wondering if we should just have a flag that disable any automatic logging configuration from the framework

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logging configuration for LiveKit Agents: avoid JSON stdout in production mode

4 participants