gpt4 book ai didi

java - 如何配置 GlassFish 日志记录以在时间戳中显示毫秒?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:14:26 24 4
gpt4 key购买 nike

我不得不承认,配置日志让我有点困惑:(...,所以我希望这里有人能提供帮助。

基本上,我需要将日志记录配置到 server.log,以便时间戳包括毫秒。

问题是,看起来默认的 logging.properties 是为此配置的,但实际的日志消息看起来一点也不像 logging.properties 的格式字符串,所以我想不通:

1) server.log 中的日志格式消息到底是什么(文件)控制的2) 我需要更改什么,大概是 GlassFish logging.properties,以使用 logging.properties 中的格式,以便我在日志时间戳中看到毫秒?

这是我当前的 logging.properties:

#GlassFish logging.properties list
#Thu Jan 19 11:44:17 EST 2012

# 02-05-2012 - try to isolate auditing of permit/deny
com.sun.enterprise.security.auth.level=INFO

javax.enterprise.system.tools.admin.level=INFO
#handlers=java.util.logging.ConsoleHandler,com.sun.enterprise.server.logging.GFFileHandler

handlers=com.sun.enterprise.server.logging.GFFileHandler

#java.util.logging.ConsoleHandler.formatter=com.sun.enterprise.server.logging.UniformLogFormatter
com.sun.enterprise.server.logging.GFFileHandler.logFormatDateFormat=yyyy-MM-dd'T'HH\:mm\:ss.SSSZ
javax.enterprise.system.ssl.security.level=INFO
org.apache.jasper.level=INFO
com.sun.enterprise.server.logging.GFFileHandler.flushFrequency=1
org.eclipse.persistence.session.level=INFO
javax.enterprise.system.tools.backup.level=INFO
javax.enterprise.resource.corba.level=INFO
javax.enterprise.resource.webcontainer.jsf.resource.level=INFO
javax.enterprise.system.core.classloading.level=INFO
javax.enterprise.resource.jta.level=INFO
java.util.logging.ConsoleHandler.level=FINER
com.sun.enterprise.server.logging.GFFileHandler.file=${com.sun.aas.instanceRoot}/logs/server.log

javax.enterprise.system.webservices.saaj.level=INFO
java.util.logging.FileHandler.formatter=java.util.logging.XMLFormatter
javax.enterprise.system.tools.deployment.level=INFO
javax.enterprise.system.container.ejb.level=INFO
javax.enterprise.system.core.transaction.level=INFO
org.apache.catalina.level=INFO
javax.enterprise.resource.webcontainer.jsf.lifecycle.level=INFO
com.sun.enterprise.server.logging.GFFileHandler.rotationTimelimitInMinutes=0
javax.enterprise.resource.webcontainer.jsf.config.level=INFO
javax.enterprise.system.container.ejb.mdb.level=INFO
javax.enterprise.resource.webcontainer.jsf.timing.level=INFO

# 02-05-2012 - try to isolate auditing of permit/deny
javax.enterprise.system.core.level=FINE

com.sun.enterprise.server.logging.GFFileHandler.rotationOnDateChange=false

org.apache.coyote.level=INFO
ShoalLogger.level=INFO
javax.level=INFO
javax.enterprise.resource.webcontainer.jsf.taglib.level=INFO
java.util.logging.FileHandler.limit=50000
javax.enterprise.system.webservices.rpc.level=INFO
javax.enterprise.resource.javamail.level=INFO
com.sun.enterprise.server.logging.GFFileHandler.logtoConsole=false
javax.enterprise.system.container.web.level=INFO
javax.enterprise.resource.webcontainer.jsf.facelets.level=INFO
javax.enterprise.resource.resourceadapter.level=INFO
javax.enterprise.system.util.level=INFO
com.sun.enterprise.server.logging.GFFileHandler.level=ALL
javax.org.glassfish.persistence.level=INFO
javax.enterprise.resource.webcontainer.jsf.context.level=INFO
javax.enterprise.resource.webcontainer.jsf.application.level=INFO
javax.enterprise.resource.jms.level=INFO
javax.enterprise.system.core.config.level=INFO
com.sun.enterprise.server.logging.GFFileHandler.rotationLimitInBytes=2000000
org.jvnet.hk2.osgiadapter.level=INFO
javax.enterprise.system.level=INFO

# 02-05-2012 - try to isolate auditing of permit/deny
javax.enterprise.system.core.security.level=INFO

javax.enterprise.system.container.cmp.level=INFO
java.util.logging.FileHandler.pattern=%h/java%u.log
com.sun.enterprise.server.logging.SyslogHandler.useSystemLogging=false
javax.enterprise.resource.sqltrace.level=INFO
javax.enterprise.resource.webcontainer.jsf.renderkit.level=INFO
javax.enterprise.system.webservices.registry.level=INFO
javax.enterprise.system.core.selfmanagement.level=INFO

# 02-05-2012 - try to isolate auditing of permit/deny
com.sun.enterprise.security.Audit.level=INFO
com.sun.enterprise.security.level=INFO

com.sun.enterprise.server.logging.GFFileHandler.formatter=com.sun.enterprise.server.logging.UniformLogFormatter.level=FINE
com.sun.enterprise.server.logging.GFFileHandler.maxHistoryFiles=0
log4j.logger.org.hibernate.validator.util.Version=warn
java.util.logging.FileHandler.count=1

# 02-05-2012 - try to isolate auditing of permit/deny
com.sun.enterprise.security.auth.realm.level=INFO

javax.enterprise.resource.webcontainer.jsf.managedbean.level=INFO
org.glassfish.admingui.level=INFO
javax.enterprise.system.core.naming.level=INFO
javax.enterprise.resource.jdo.level=INFO
com.sun.enterprise.server.logging.GFFileHandler.retainErrorsStasticsForHours=0
security.level=FINE
LDAPRealm.level=FINE

您会注意到 .logFormatDateFormat 有一种格式,但我在实际 server.log 中得到的内容看起来与该格式完全不同,例如:

Feb 5, 2012 2:30:44 PM com.sun.enterprise.v3.server.GFDomainXml
FINE: Total time to parse domain.xml: 516 milliseconds

所以它似乎是一些其他配置文件,而不是我在 GF logging.properties 中的配置文件在控制中?

谢谢,吉姆

最佳答案

输出看起来像默认的 j.u.l.SimpleFormatter。 Q conversion 转换模式是自纪元开始以来的毫秒数。更改 SimpleFormatter 的格式使用系统属性:

-Djava.util.logging.SimpleFormatter.format="%1$tQ %2$s%n%4$s: %5$s%6$s%n"

或在logging.properties :

java.util.logging.SimpleFormatter.format=%1$tQ %2$s%n%4$s: %5$s%6$s%n

L 转换模式是秒内的毫秒,格式为三位数字。可以使用系统属性修改默认模式:

-Djava.util.logging.SimpleFormatter.format="%1$ta %1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS.%1$tL %1$Tp %2$s%n%4$s: %5$s%n"

或在 logging.properties 中:

java.util.logging.SimpleFormatter.format=%1$ta %1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS.%1$tL %1$Tp %2$s%n%4$s: %5$s%n

所有这些属性都记录在 format 中方法和 java.util.Formatter类。

关于java - 如何配置 GlassFish 日志记录以在时间戳中显示毫秒?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9186682/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com