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

AMQ org.jboss.logmanager.handlers.SizeRotatingFileHandler not creating a log file

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

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% 07-25-2017 04:59 16cae5b1 org/jboss/logmanager/handlers/SizeRotatingFileHandler.class

当我使用您指定的配置时,我在启动代理时收到此异常:

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.validate(AbstractPropertyConfiguration.java:205)
    at org.jboss.logmanager.config.AbstractPropertyConfiguration.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.run(LogManager.java:399)
    at java.util.logging.LogManager.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.access0(LogManager.java:145)
    at java.util.logging.LogManager.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)。当我使用这个值时,一切都按预期工作。