Akshay Ram
Akshay Ram

Reputation: 19

Openwhisk logging with Python zip actions

I'm a bit new to Apache Openwhisk. It is an awesome project and I'm enjoying using, and learning it. Thank you so much for creating such an amazing project!

I'm not able to figure out the correct way to log from actions so I can see the logging output when an action is executed.

My logging config is:

    import logging
    
    dotenv.load_dotenv()
    logging.basicConfig(
        level="INFO",
        format='%(asctime)s - %(name)s - %(levelname)s - %(threadName)s - %(message)s')
    logger = logging.getLogger(__name__)
    opensearch_logger = logging.getLogger("opensearch")
    opensearch_logger.setLevel(logging.WARNING)
    
    def handler(event):
        logging.info(f"Some logging statement.")
        return {"func": "fin"}

The action was executed successfully, but no logs showed up. Even if I add print statements;

    {
        "namespace": "whisk.system",
        "name": "Test",
        "version": "0.0.7",
        "subject": "whisk.system",
        "activationId": "7170dcb3cfbb4e60b0dcb3cfbb3e6035",
        "start": 1738772766671,
        "end": 1738772767450,
        "duration": 779,
        "statusCode": 0,
        "response": {
            "status": "success",
            "statusCode": 0,
            "success": true,
            "result": {"func": "fin"}
        },
        **"logs": [],**
        "annotations": [
            {
                "key": "path",
                "value": "whisk.system/Test"
            },
            {
                "key": "waitTime",
                "value": 10
            },
            {
                "key": "kind",
                "value": "python:3.9"
            },
            {
                "key": "timeout",
                "value": false
            },
            {
                "key": "limits",
                "value": {
                    "concurrency": 1,
                    "logs": 10,
                    "memory": 256,
                    "timeout": 60000
                }
            }
        ],
        "publish": false
    }

Am I missing something? Any advice would be deeply appreciated.

Upvotes: 1

Views: 33

Answers (1)

user6062970
user6062970

Reputation: 831

Have you tried logging to stdout with print? It could be your logger - is it configured to write to stdout? Also try adding a logger flush.

Upvotes: 0

Related Questions