我不得不承认,配置日志记录让我感到有些困惑:( ...,所以我希望有人可以提供帮助。
基本上,我需要配置日志记录到server.log,以便时间戳包括毫秒。
问题是,看起来默认的logging.properties是为它配置的,但实际的日志消息看起来不像是logging.properties的格式字符串,所以我无法弄明白:< / p>
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中的控件之外还有其他配置文件?
谢谢, 吉姆
答案 0 :(得分:1)
输出看起来像默认的j.u.l.SimpleFormatter。 Q
转换转换模式是自纪元开始以来的毫秒数。使用系统属性更改SimpleFormatter的格式:
-Djava.util.logging.SimpleFormatter.format="%1$tQ %2$s%n%4$s: %5$s%6$s%n"
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类中。