dosubot[bot] commented on issue #30135: URL: https://github.com/apache/superset/issues/30135#issuecomment-2326725774
<!-- Answer --> I found a similar unsolved discussion that might be relevant to your issue: [Additional StreamHandler in the DefaultLoggingConfigurator causes duplicate logs](https://github.com/apache/superset/discussions/23963) <sup>[[1]](https://github.com/apache/superset/discussions/23963)</sup>. To address the issue of Apache Superset version 4.0.2 writing logs to `stderr` in production mode, you can modify the logging configuration to redirect logs to `stdout`. Here is an example of how you can achieve this by subclassing `DefaultLoggingConfigurator`: ```python import logging import sys from flask import Config from superset.utils.logging_configurator import DefaultLoggingConfigurator class StdoutLoggingConfigurator(DefaultLoggingConfigurator): def configure_logging(self, app_config: Config, debug_mode: bool) -> None: # Call the parent method to set up the initial configuration super().configure_logging(app_config, debug_mode) # Get the 'superset' logger superset_logger = logging.getLogger("superset") # Remove all existing handlers for handler in superset_logger.handlers: superset_logger.removeHandler(handler) # Add a new handler that writes to stdout handler = logging.StreamHandler(sys.stdout) handler.setFormatter(logging.Formatter(app_config["LOG_FORMAT"])) superset_logger.addHandler(handler) # Set the custom logging configurator LOGGING_CONFIGURATOR = StdoutLoggingConfigurator() # Apply the basic configuration to redirect logs to stdout logging.basicConfig( stream=sys.stdout, format="%(asctime)s:%(levelname)s:%(name)s:%(message)s", force=True, ) ``` This code will ensure that logs are written to `stdout` instead of `stderr`, preventing the misclassification of log messages in cloud environments like Google Kubernetes Engine (GKE) <sup>[[2]](https://github.com/apache/superset/blob/master/superset/utils/logging_configurator.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org