Configuring Ray Serve Logging: JSON Formatting, Stream Handling, and CLI Output

Hello Ray Community,

I’m currently working with Ray Serve and seeking guidance on configuring its logging system to meet specific requirements. Specifically, I have the following questions:

  1. JSON Log Formatting: How can I configure the Ray logger to output logs in JSON format?
  2. Stream Handling: What are the best practices for configuring different log streams, such as stderr and stdout, within Ray Serve?
  3. CLI Log Configuration: How can I adjust the logging behavior for Ray Serve’s CLI commands to align with the above configurations?

I have reviewed the Ray documentation on configuring logging, but I’m looking for more detailed insights or examples from the community.

Any advice or shared experiences on achieving these logging configurations in Ray Serve would be highly valuable.

Thank you in advance for your assistance!

Hi @sambbhavgarg The doc you are looking is more general for Ray. If you are looking for configure Serve’s logger, you can check out this doc Monitor Your Application — Ray 2.38.0

The same logging config also exist in Serve’s config files if you need a global config Serve Config Files — Ray 2.38.0

The best practice is in your application code, always using ray.serve logger to log anything.

I believe cli loggers behavior very differently than the standard ray.serve logger. If you need a way to configure the cli logger, feel free to file a GH issue or directly contribute to the open source codebase :slight_smile: