AMQ org.jboss.logmanager.handlers.SizeRotatingFileHandler未创建日志文件

时间:2018-11-06 22:20:53

标签: jboss-logging jboss-amq

在Linux上运行的AMQ 7 当前默认配置:

handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.FILE.level=DEBUG
handler.FILE.properties=suffix,append,autoFlush,fileName
handler.FILE.suffix=.yyyy-MM-dd
handler.FILE.append=true
handler.FILE.autoFlush=true
handler.FILE.fileName=${artemis.instance}/log/artemis.log
handler.FILE.formatter=PATTERN

尝试转换为:

handler.FILE=org.jboss.logmanager.handlers.SizeRotatingFileHandler
handler.FILE.level=DEBUG
handler.FILE.formatter=PATTERN
handler.FILE.properties=append,autoFlush,enabled,maxBackupIndex,rotateOnBoot,rotateSize,fileName
handler.FILE.append=true
handler.FILE.autoFlush=true
handler.FILE.enabled=true
handler.FILE.maxBackupIndex=2
handler.FILE.rotateOnBoot=true
handler.FILE.rotateSize=5K
handler.FILE.fileName=${artemis.instance}/log/artemis.log

导致未创建日志文件。

经过验证的jboss-logmanager-2.0.7.Final-redhat-1.jar包含

6196 Defl:N 2786 55%2017年7月25日04:59 16cae5b1 org / jboss / logmanager / handlers / SizeRotatingFileHandler.class

1 个答案:

答案 0 :(得分:0)

使用您指定的配置时,启动代理时会出现此异常:

java.lang.NumberFormatException: For input string: "5K"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Long.parseLong(Long.java:589)
    at java.lang.Long.valueOf(Long.java:803)
    at org.jboss.logmanager.config.LogContextConfigurationImpl.getValue(LogContextConfigurationImpl.java:448)
    at org.jboss.logmanager.config.AbstractPropertyConfiguration$1.validate(AbstractPropertyConfiguration.java:205)
    at org.jboss.logmanager.config.AbstractPropertyConfiguration$1.validate(AbstractPropertyConfiguration.java:196)
    at org.jboss.logmanager.config.LogContextConfigurationImpl.doPrepare(LogContextConfigurationImpl.java:335)
    at org.jboss.logmanager.config.LogContextConfigurationImpl.prepare(LogContextConfigurationImpl.java:288)
    at org.jboss.logmanager.config.LogContextConfigurationImpl.commit(LogContextConfigurationImpl.java:297)
    at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:546)
    at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:97)
    at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:514)
    at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:476)
    at java.util.logging.LogManager$3.run(LogManager.java:399)
    at java.util.logging.LogManager$3.run(LogManager.java:396)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.util.logging.LogManager.readPrimordialConfiguration(LogManager.java:396)
    at java.util.logging.LogManager.access$800(LogManager.java:145)
    at java.util.logging.LogManager$2.run(LogManager.java:345)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.util.logging.LogManager.ensureLogManagerInitialized(LogManager.java:338)
    at java.util.logging.LogManager.getLogManager(LogManager.java:378)
    at java.util.logging.Logger.demandLogger(Logger.java:448)
    at java.util.logging.Logger.getLogger(Logger.java:502)
    at org.apache.activemq.artemis.boot.Artemis.<clinit>(Artemis.java:40)

问题是您的配置这一行:

handler.FILE.rotateSize=5K

The code expects a valid Java long value,代表旋转前写入文件的字节数。 5K转换为5120(5 * 1024)。当我使用此值时,一切都会按预期进行。