SAP / cf-java-logging-support

The Java Logging Support for Cloud Foundry supports the creation of structured log messages and the collection of request metrics
Apache License 2.0
77 stars 48 forks source link

Dynamic setting of log level for individual tenants #92

Closed krebsr closed 2 years ago

krebsr commented 3 years ago

Hi,

As a Developer, Quality Engineer or Operations Experts I want to set the log level on a tenants individual basis in order to debug issues reported for one tenant only.

This allows me to:

  1. keep the amount of log below the technical request limitations/plan of the backend logging service,
  2. reduce logs to focus on the problems reported by that specific tenant,
  3. not log potentially critical data of tenants which are not impacted by a dedicated issue (data avoidence/minimization).

Optional: As a Developer, Quality Engineer or Operations Experts I want to set the log level on a tenants individual basis at runtime without restarting any service instances, in order to avoid unexpected service interruptions

Thanks in advance

KarstenSchnitter commented 3 years ago

Hi,

thanks for submitting this issue. You can accomplish those requirements with a TurboFilter when using logback or a Filter when using log4j2. Check out some examples from this library: DynamicLevelPrefixLoggerTurboFilter for logback or DynamicLevelPrefixLoggerFilter for log4j2. These filters are executed for every log event. If you can determine your tenant from the log event alone, you can implement your required logic in such a filter. Alternatively you can use the Dynamic Log Level Feature of this library by providing suitable JWT tokens in the requests of all your tenants you want debug logs for. If you do not want to use JWT, you can still instruct the filters from above to apply different log levels by setting the two MDC fields dynamic_log_level and dynamic_log_level_prefixes as documented in the extension section of the documentation. This could be done by the code identifying your tenants.

Please let me know, how I can help you.

Best Regards, Karsten

KarstenSchnitter commented 2 years ago

Closing due to lack of response.