1. <legend id='HcBuD'><style id='HcBuD'><dir id='HcBuD'><q id='HcBuD'></q></dir></style></legend>

    <tfoot id='HcBuD'></tfoot>
    • <bdo id='HcBuD'></bdo><ul id='HcBuD'></ul>

    <small id='HcBuD'></small><noframes id='HcBuD'>

    <i id='HcBuD'><tr id='HcBuD'><dt id='HcBuD'><q id='HcBuD'><span id='HcBuD'><b id='HcBuD'><form id='HcBuD'><ins id='HcBuD'></ins><ul id='HcBuD'></ul><sub id='HcBuD'></sub></form><legend id='HcBuD'></legend><bdo id='HcBuD'><pre id='HcBuD'><center id='HcBuD'></center></pre></bdo></b><th id='HcBuD'></th></span></q></dt></tr></i><div id='HcBuD'><tfoot id='HcBuD'></tfoot><dl id='HcBuD'><fieldset id='HcBuD'></fieldset></dl></div>

      指定 log4j 日期的时区

      Specify time zone of log4j#39;s date(指定 log4j 日期的时区)

          <bdo id='fSvvN'></bdo><ul id='fSvvN'></ul>
            <tbody id='fSvvN'></tbody>
          <legend id='fSvvN'><style id='fSvvN'><dir id='fSvvN'><q id='fSvvN'></q></dir></style></legend>

            1. <small id='fSvvN'></small><noframes id='fSvvN'>

                <i id='fSvvN'><tr id='fSvvN'><dt id='fSvvN'><q id='fSvvN'><span id='fSvvN'><b id='fSvvN'><form id='fSvvN'><ins id='fSvvN'></ins><ul id='fSvvN'></ul><sub id='fSvvN'></sub></form><legend id='fSvvN'></legend><bdo id='fSvvN'><pre id='fSvvN'><center id='fSvvN'></center></pre></bdo></b><th id='fSvvN'></th></span></q></dt></tr></i><div id='fSvvN'><tfoot id='fSvvN'></tfoot><dl id='fSvvN'><fieldset id='fSvvN'></fieldset></dl></div>

                <tfoot id='fSvvN'></tfoot>
                本文介绍了指定 log4j 日期的时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                是否可以指定 log4j 将使用的时区?我需要日志文件中的日期与应用程序的时区不同.log4j 的 PatternLayout 使用 SimpleDateFormat.不幸的是,似乎没有办法通过模式字符串来控制 SimpleDateFormat 的时区(DateFormatsetTimeZone 方法,但这并没有'没有帮助).

                Is it possible to specify the time zone that log4j will use? I need the dates in the log file to be a different time zone than the application's. log4j's PatternLayout uses SimpleDateFormat. Unfortunately there doesn't appear to be a way to control SimpleDateFormat's time zone via the pattern string (DateFormat has setTimeZone method but that doesn't help).

                我查看了 log4j 的源代码,并且 SimpleDateFormatPatternParser.finalizeConverter 中被实例化.不幸的是,没有一种简单的方法可以获取 DateFormat 来设置时区.

                I looked at log4j's source and SimpleDateFormat is being instiantiated in PatternParser.finalizeConverter. Unfortunately there's not an easy way to get a hold of the DateFormat to set the time zone.

                推荐答案

                如果在类路径中使用 Log4J extras JAR 文件,EnhancedPatternLayout 类支持此配置选项.请参阅 此链接上的 Javadoc.它作为 %d 模式组件的一部分处理,如下所示:

                If you use the Log4J extras JAR file on your classpath, the EnhancedPatternLayout class supports this configuration option. See the Javadoc at this link. It's handled as part of the %d pattern component like this:

                log4j.appender.stdout.layout.ConversionPattern=%d{}{America/New_York} %p [%c] - %m%n
                

                您可以在这里下载附加包.

                这篇关于指定 log4j 日期的时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Java Bytecode Manipulation Library Suggestions(Java 字节码操作库建议)
                Java CLI UI-design: frameworks or libraries?(Java CLI UI 设计:框架还是库?)
                About the use of Beans.xml configuration file in Spring Framework application(关于Spring Framework应用中Beans.xml配置文件的使用)
                What is the difference between Spring, Struts, Hibernate, JavaServer Faces, Tapestry?(Spring、Struts、Hibernate、JavaServer Faces、Tapestry 有什么区别?)
                Are there any android application framework like spring?(有没有像spring这样的android应用程序框架?)
                Java Swing based game framework. Any advice?(基于 Java Swing 的游戏框架.有什么建议吗?)
                    <tbody id='IGiwO'></tbody>

                  1. <small id='IGiwO'></small><noframes id='IGiwO'>

                    • <bdo id='IGiwO'></bdo><ul id='IGiwO'></ul>

                        <legend id='IGiwO'><style id='IGiwO'><dir id='IGiwO'><q id='IGiwO'></q></dir></style></legend>

                          <tfoot id='IGiwO'></tfoot>
                          <i id='IGiwO'><tr id='IGiwO'><dt id='IGiwO'><q id='IGiwO'><span id='IGiwO'><b id='IGiwO'><form id='IGiwO'><ins id='IGiwO'></ins><ul id='IGiwO'></ul><sub id='IGiwO'></sub></form><legend id='IGiwO'></legend><bdo id='IGiwO'><pre id='IGiwO'><center id='IGiwO'></center></pre></bdo></b><th id='IGiwO'></th></span></q></dt></tr></i><div id='IGiwO'><tfoot id='IGiwO'></tfoot><dl id='IGiwO'><fieldset id='IGiwO'></fieldset></dl></div>