Hello, I've been playing around with trying to ge...
# prefect-community
c
Hello, I've been playing around with trying to get the flow logs we see in the UI saved onto disk or on S3. Currently I have my set up like this :
Copy code
@flow
def api_flow(url):
    # logger = get_run_logger()
    logger = logging.getLogger()

    #set lower level
    logger.setLevel(<http://logging.INFO|logging.INFO>)

    #create file handler
    filehdlr = logging.FileHandler('filehandler.txt',mode='w')
    # set level
    filehdlr.setLevel(<http://logging.INFO|logging.INFO>)

    # add handler to logger
    logger.addHandler(filehdlr)
    fact_json = call_api(url)
    <http://logger.info|logger.info>("TEST")
    return fact_json
But it only adds local outputs into the .txt file (filehandler.txt shown below):
Copy code
file handler is created to handle log message in the file
we can create many handlers for the logger
Created task run 'call_api-0' for task 'call_api'
Executing 'call_api-0' immediately...
Finished in state Completed()
TEST
Finished in state Completed()
Is there a way I can get the exact flow logs (including the timestamps) saved somewhere (either onprem or on S3) like the output shown below from prefect?
b
Hey Charles, maybe this discourse article may be of use? How to Stream Prefect Logs to a File
1