Skip to content

Not able to save extra properties to SEQ #1330

Open
@jeffkararo

Description

@jeffkararo

QUESTION:: I have tried everything I can think of to get extra properties saved to SEQ. My log event JSON works with the SEQ HTTP endpoint (http://localhost:5341/api/events/raw) but does not work when using loguru and the base SEQ URL (http://localhost:5341/). I even tried using the HTTP URL with loguru but that saved nothing to SEQ. My log event JSON is below. I am using seqlog.log_to_seq as the handler that is passed to loguru.logger (see below for that code)

My question is how can I use loguru to save the json content below to SEQ?

I can save just my "message" in the "MessageTemplate" below but the extra properties are not to be seen. Any help or guidance would be appreciated (or a code snippet). Also, happy to share more of my code if needed.

log_event = {
    "Events":[
        {
            "Timestamp": end_time.isoformat(),
            "Level": LogMessageLevel.INFO.name,  
            "MessageTemplate": message,
            "Properties": {
                "project": app_name,
                "function_name": func_name,
                "time_begin": start_time.isoformat(),
                "time_end": end_time.isoformat(),
                "time_span": (end_time - start_time).total_seconds(),
                # below is prefixed with 'zz-' for alpha sort in log viewer
                "zz_args": _convert_to_serializable(args),
                "zz_kwargs": _convert_to_serializable(kwargs)
            }
        }
    ]
}

    logger.add(
        server_url="http://localhost:5341",  # URL of the SEQ server
        api_key=None,  # No API key used
        level=logging.INFO,  # Set logging level to INFO
        batch_size=5,  # Send log events in batches of size 5
        auto_flush_timeout=10,  # Flush every 10 seconds if batch is not full
        override_root_logger=False,  # Override the root logger with SEQ
        json_encoder_class=json.JSONEncoder,  # Optional, default JSON encoder
        support_extra_properties=True  # Enable support for passing extra properties
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions