xcube-dev / xcube

xcube is a Python package for generating and exploiting data cubes powered by xarray, dask, and zarr.
https://xcube.readthedocs.io/
MIT License
195 stars 18 forks source link

Allow structured logging for xcube server #1060

Open forman opened 1 month ago

forman commented 1 month ago

Is your feature request related to a problem? Please describe.

We need more detailed information of how xcube server deployments perform.

Describe the solution you'd like

xcube server therefore shall have a new option to output well-structured logs that include key fields such as timestamps, log levels, and unique identifiers. This makes it easier to query and analyze the data.

We'll replace the standard "tornado.access" logs by structured JSON logging that also includes details of the current request.

Example log entry:

{
  "timestamp": "2024-08-15T08:59:23Z",
  "level": "INFO",
  "message": "User login successful",
  "user": {
    "id": "12345",
    "username": "johndoe"
  },
  "request": {
    "method": "POST",
    "url": "/api/login",
    "status": 200,
    "response_time_ms": 123
  },
  "application": {
    "name": "MyApp",
    "version": "1.0.0"
  },
  "environment": "production"
}

Implementing structured logging:

For implementation in Tornado: