当我在代码中记录消息时,服务器会打印两次相同的消息,只有开头日期的差异。
我正在使用服务器Wildfly 10附带的默认日志配置。
的server.log
09:43:09,122 INFO [es.myapp.business.scheduler.boundary.Job] (default task-91) ----------INIT Job Mon Nov 20 10:05:08 CET 2017
2017-11-20 09:43:09,122 INFO [es.myapp.business.scheduler.boundary.Job] (default task-91) ----------INIT Job Mon Nov 20 10:05:08 CET 2017
Job.java
import org.apache.log4j.Logger;
...
public class Job {
protected Logger logger = Logger.getLogger(getClass().getName());
public void execute() throws IOException {
logger.info("----------INIT Job " + new Date());
}
}
Wildfly logging.properties
# Note this file has been generated and will be overwritten if a
# logging subsystem has been defined in the XML configuration.
# Additional loggers to configure (the root logger is always configured)
loggers=sun.rmi,org.jboss.as.config,com.arjuna
logger.level=INFO
logger.handlers=FILE,CONSOLE
logger.sun.rmi.level=WARN
logger.sun.rmi.useParentHandlers=true
logger.org.jboss.as.config.level=DEBUG
logger.org.jboss.as.config.useParentHandlers=true
logger.com.arjuna.level=WARN
logger.com.arjuna.useParentHandlers=true
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.level=INFO
handler.CONSOLE.formatter=COLOR-PATTERN
handler.CONSOLE.properties=enabled,autoFlush,target
handler.CONSOLE.enabled=true
handler.CONSOLE.autoFlush=true
handler.CONSOLE.target=SYSTEM_OUT
handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.FILE.level=ALL
handler.FILE.formatter=PATTERN
handler.FILE.properties=append,autoFlush,enabled,suffix,fileName
handler.FILE.append=true
handler.FILE.autoFlush=true
handler.FILE.enabled=true
handler.FILE.suffix=.yyyy-MM-dd
handler.FILE.fileName=/home/u24282/servers/wildfly-10.1.0.Final/standalone/log/server.log
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=%d{yyyy-MM-dd HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%e%n
formatter.COLOR-PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.COLOR-PATTERN.properties=pattern
formatter.COLOR-PATTERN.pattern=%K{level}%d{HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%e%n
答案 0 :(得分:0)
您是否可能将WildFly流程输出传递给日志文件?或者,您是否在域模式下运行?