she*_*n89 2 timezone poco-libraries
我目前正在使用一些c ++代码中的Poco Logger库.它在美国的服务器上运行,但即使系统时间存在正确的时区,日志文件也会将时间戳打印为GMT.
这是一个可配置的Poco设置,还是我需要找到的系统设置?我似乎无法在任何地方找到答案!
下面可能有用的输出.
日志文件示例:2013-04-03 11:49:32.862 GMT[31015]:Debug:...
日志文件格式字符串:pattern = "%Y-%m-%d %H:%M:%S.%i %Z[%P]:%p:%t"
输出来自/etc/sysconfig/clock:
ZONE="America/Los_Angeles"
UTC=true
ARC=false
Run Code Online (Sandbox Code Playgroud)
输出自date:Wed Apr 3 04:57:44 PDT 2013
输出echo $TZ:America/Los_Angeles
任何想法非常感谢!
Poco :: PatternFormatter类有一个属性"times",可以设置为"UTC"(默认)或"local"(您正在查找的内容).您可以在配置文件中进行设置,但是您必须明确定义格式化程序:
logging.channels.c1.class = FileChannel
logging.channels.c1.path = ${system.tempDir}/sample.log
logging.channels.c1.formatter.class = PatternFormatter
logging.channels.c1.formatter.pattern = %Y-%m-%d %H:%M:%S.%i %Z[%P]:%p:%t
logging.channels.c1.formatter.times = local
Run Code Online (Sandbox Code Playgroud)
如果要以编程方式创建格式化程序,请使用setProperty()方法:
pPatternFormatter->setProperty("times", "local");
Run Code Online (Sandbox Code Playgroud)
另见:http://pocoproject.org/slides/185-LoggingConfiguration.pdf
| 归档时间: |
|
| 查看次数: |
1456 次 |
| 最近记录: |