问题描述
我需要为在斐济中的服务器中运行的某些应用程序配置DST时间. OS级别时间已正确配置:
Tue Nov 11 17:28:51 **FJST** 2014
(fjst -fiji夏季时间)
我已经更改了Log4j.xml配置,如下所示:
<layout class="org.apache.log4j.EnhancedPatternLayout"> <param name="ConversionPattern" value="%d{ISO8601}{GMT+13} %-5p %c{1} [%x] [%t] - %m%n" />
这有点好,但这只能是解决方法,不能成为解决方案.以下两个问题:
-
需要两次重新启动所有应用程序.在每次DST更改期间,服务都将在那里中断.生产不可能.
-
我们不能说,每天的时间变化恰好是+/- 1小时.有时候可能大约50分钟.因此,在这种情况下,日志将不会随着适当的时间而更新.
有没有可供以下Java版本进行修复的补丁? - " 1.7.0_09-cideTea"
还有其他方法可以将log4j时间更改为OS时间吗?如果是这样,这将是一个很好的解决方案,因为不会有太多的服务中断.
推荐答案
根据 > ,%d之后的第二组括号中的值是要内部传递到 TimeZone.getTimeZone(String) ,该字符串应为:
时区的ID,诸如" PST"之类的缩写,诸如" America/LOS_ANGELES"之类的全名,或" GMT-8:00"等自定义ID.
因此,您应该能够通过Pacific/Fiji,在一年中的不同时间自动使用正确的时区偏移.
<param name="ConversionPattern" value="%d{ISO8601}{Pacific/Fiji} %-5p %c{1} [%x] [%t] - %m%n" />
此外,从历史上看,斐济因设置DST日期时没有提供足够通知而闻名.大多数国家都试图建立稳定的复发模式,但斐济选择每年宣布DST改变. 2014年的最新更改是于10月20日宣布,并于11月2日生效 - 仅留下12天的时间来实施和分发对时区数据库的更改. iana tzdb group 行动很快, 10月22日发布2014i,Oracle随后发出了相应的 tzupdater 1.4.9 在10月31日结合此更改.
确保您下载tzupdater 1.4.9或更大的并将其应用于您的环境.只要斐济不稳定,您将来也可能需要这样做.这意味着您关于不想重新启动生产的拳头要点是不可能的.一个人无法预测政府.
关于您的第二个项目符号:世界上任何地方都没有时区的转移50分钟.除Australia/Lord_Howe外,所有使用DST移动整整一个小时都换一个.
问题描述
I need to configure DST time for some application running in a server which is in Fiji. OS level time has configured properly :
Tue Nov 11 17:28:51 **FJST** 2014
(FJST - Fiji Summer Time)
I have changed the log4j.xml configuration as follow and tried:
<layout class="org.apache.log4j.EnhancedPatternLayout"> <param name="ConversionPattern" value="%d{ISO8601}{GMT+13} %-5p %c{1} [%x] [%t] - %m%n" />
This works bit fine, but this can be a workaround only, can't be a solution. Following two issues are there:
Need to restart all the application two times. During every DST changes service interruption will be there. It's not possible for production.
We can't say, every day the time change will be exactly +/- 1 hour. Some days it can be like 50 mins. So in that case, log won't be updated with proper time.
Is there any patch available for following java version to fix this ? - "1.7.0_09-icedtea"
Else is there any way to change the log4j time as OS time? If so that will be a great solution since there won't be much service interruption.
推荐答案
According to the docs for EnhancedPatternLayout, the value in the second set of braces following %d is a string to be passed internally to TimeZone.getTimeZone(String), which states the string should be:
The ID for a TimeZone, either an abbreviation such as "PST", a full name such as "America/Los_Angeles", or a custom ID such as "GMT-8:00".
Therefore, you should be able to pass Pacific/Fiji, to automatically use the correct time zone offset at different times of the year.
<param name="ConversionPattern" value="%d{ISO8601}{Pacific/Fiji} %-5p %c{1} [%x] [%t] - %m%n" />
Also, historically Fiji has been known for not providing adequate notice when setting their DST dates. Most countries try to establish a stable recurrence pattern, but Fiji has chosen to announce DST changes each individual year. The latest change for 2014 was announced on Oct 20th, and went into effect on Nov 2nd - leaving only 12 days to implement and distribute changes to the time zone databases. The IANA tzdb group acted quickly, releasing version 2014i on Oct 22, and Oracle then issued the corresponding TZUpdater 1.4.9 on Oct 31 to incorporate this change.
Make sure you download TZUpdater 1.4.9 or greater and apply it to your environment. As long as Fiji is unstable, you will likely need to do this in the future as well. That means your fist bullet point about not wanting to restart production is an impossibility. One cannot predict the government.
Regarding your second bullet point: There are no time zones anywhere in the world that shift by 50 minutes. All that use DST shift by one whole hour, except for Australia/Lord_Howe which shifts by 30 minutes.