You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi.
I found that after compiling my micronaut project as a docker native app, its timezone is GMT+0, even when I mount the host's /etc/localtime to the docker container. This also causes logback to output logs with GMPT+0 time as well.
I tried to force the timezone to be set at the beginning of the Application's main method, as in:
This also only makes the time zone specified GMT+8 when the JVM runtime code generates the time, but the logback output is still GMT+0.
I then tried implementing LoggingSystem as per the documentation, replacing the framework's LogbackLoggingSystem, but it causes the logback.xml configuration to be unreadable.
Finally I found a bad solution: immediately after forcing the timezone at the beginning of the main method of the Application, call the following sample code to reinitialize the LoggeContext:
LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory();
contxt.reset();
new ContextInitializer(context).autoConfig();
However, this change will cause the related classes used in logback.xml and the resource files under resources to be unavailable to the native image, and reflect-config.json and resource-config.json must be configured to solve the problem.
This text is useful but very inelegant, is there a good official solution for this?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi.
I found that after compiling my micronaut project as a docker native app, its timezone is GMT+0, even when I mount the host's /etc/localtime to the docker container. This also causes logback to output logs with GMPT+0 time as well.
I tried to force the timezone to be set at the beginning of the Application's main method, as in:
This also only makes the time zone specified GMT+8 when the JVM runtime code generates the time, but the logback output is still GMT+0.
I then tried implementing LoggingSystem as per the documentation, replacing the framework's LogbackLoggingSystem, but it causes the logback.xml configuration to be unreadable.
Finally I found a bad solution: immediately after forcing the timezone at the beginning of the main method of the Application, call the following sample code to reinitialize the LoggeContext:
However, this change will cause the related classes used in logback.xml and the resource files under resources to be unavailable to the native image, and reflect-config.json and resource-config.json must be configured to solve the problem.
This text is useful but very inelegant, is there a good official solution for this?
Beta Was this translation helpful? Give feedback.
All reactions