Laragon pick up python logs

51 views Asked by At

I have this python API that is running in port 8011. I am logging the steps happenning in the processes via python logging module.

# Configure the root logger
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)

# Create a handler for standard output (stdout)
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setLevel(logging.DEBUG)

# Create a handler for standard error (stderr)
stderr_handler = logging.StreamHandler(sys.stderr)
stderr_handler.setLevel(logging.ERROR)

# Create a formatter for log messages
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")

# Set the formatter for handlers
stdout_handler.setFormatter(formatter)
stderr_handler.setFormatter(formatter)

# Add handlers to the root logger
root_logger.addHandler(stdout_handler)
root_logger.addHandler(stderr_handler)

...

def main_api():
    uvicorn.run(app, host="0.0.0.0", port=8011)


if __name__ == '__main__':
    main_api()

However, I am scheduling the calls from laragon, via a laragon cronical.dat file. Is there any way for laragon to pick stdout and stderr and show them somewhere?

0

There are 0 answers