micronaut-projects / micronaut-core

Micronaut Application Framework
http://micronaut.io
Apache License 2.0
6.08k stars 1.07k forks source link

Ensure Logging System is always refreshed #8918

Closed driverpt closed 1 year ago

driverpt commented 1 year ago

Expected Behavior

Logging System to be refreshed everytime application starts and Context is Refreshed

Actual Behaviour

Only happens if logger.levels property is defined

Steps To Reproduce

No response

Environment Information

No response

Example Application

No response

Version

3.8.7

driverpt commented 1 year ago

This is causing a Serverless Function (Non-Native, AWS java11 runtime) not to log anything

sdelamo commented 1 year ago

This is causing a Serverless Function (Non-Native, AWS java11 runtime) not to log anything

do you have sample app which reproduce this?

driverpt commented 1 year ago

Give me a couple of hours to create Sample App. In the meanwhile I've already created a PR with a Test Reproducing this issue

sdelamo commented 1 year ago

This is causing a Serverless Function (Non-Native, AWS java11 runtime) not to log anything

Are you saying such an app will not log anything?

https://micronaut.io/launch?type=DEFAULT&name=demo&package=com.example&javaVersion=JDK_11&lang=JAVA&build=GRADLE&test=JUNIT&features=aws-lambda&features=aws-cdk&features=amazon-api-gateway&version=3.8.7

driverpt commented 1 year ago

Hello @sdelamo , please find the demo app here.

To reproduce try to set the Environment variable: LOGGER_LEVELS_COM_EXAMPLE=DEBUG in Lambda Configuration.

This also causes issue with Native Build when we're using Environment Variables unrelated to LOGGER_LEVELS and used in Logback.

I've created a Test and Proposed a Fix for this issue

Thanks

sdelamo commented 1 year ago

Does the issue only happen when you use Lombok @Slf4j?

driverpt commented 1 year ago

Hello @sdelamo , did not test that.

yuri1969 commented 1 year ago

This issue causes more undesirable side-effects.

I can confirm that the logging-related config property logger.config (and maybe others) takes effect only when the logger.levels property is set. A peek into the code revealed it was caused by the lack of a refresh.