最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

serverless - Openwhisk logging with Python zip actions - Stack Overflow

programmeradmin0浏览0评论

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.

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.

Share Improve this question edited Feb 5 at 19:08 f_puras 2,5054 gold badges35 silver badges45 bronze badges asked Feb 5 at 16:42 Akshay RamAkshay Ram 197 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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.

发布评论

评论列表(0)

  1. 暂无评论