ActiveMq异常:线程中的异常" ActiveMQ InactivityMonitor WriteCheckTimer"

时间:2017-07-11 16:51:20

标签: java logging log4j activemq

我正在使用log4j将日志生成为活动的mq。

当我将日志级别设置为DEBUG,INFO,WARN,ERROR和FATAL时,日志消息将存储到队列中。

但是当设置为TRACE和所有情况时。我正在低于例外。

  

线程中的异常" ActiveMQ InactivityMonitor WriteCheckTimer"   java.lang.StackOverflowError。       at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2333)         在java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2312)         at java.util.Calendar.setTimeInMillis(Calendar.java:1804)         at java.util.Calendar.setTime(Calendar.java:1770)         at java.text.SimpleDateFormat.format(SimpleDateFormat.java:943)         at java.text.SimpleDateFormat.format(SimpleDateFormat.java:936)         at java.text.DateFormat.format(DateFormat.java:345)         在org.apache.log4j.helpers.PatternParser $ DatePatternConverter.convert(PatternParser.java:443)         在org.apache.log4j.helpers.PatternConverter.format(PatternConverter.java:65)         在org.apache.log4j.PatternLayout.format(PatternLayout.java:506)         在org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:310)         在org.apache.log4j.RollingFileAppender.subAppend(RollingFileAppender.java:276)         在org.apache.log4j.WriterAppender.append(WriterAppender.java:162)         在org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)         在org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)         在org.apache.log4j.Category.callAppenders(Category.java:206)         在org.apache.log4j.Category.forcedLog(Category.java:391)         在org.apache.log4j.Category.log(Category.java:856)         at org.slf4j.impl.Log4jLoggerAdapter.trace(Log4jLoggerAdapter.java:154)         at org.apache.activemq.util.ClassLoadingAwareObjectInputStream.load(ClassLoadingAwareObjectInputStream.java:128)         atorg.apache.activemq.util.ClassLoadingAwareObjectInputStream.resolveClass(ClassLoadingAwareObjectInputStream.java:56)       at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1620)         at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521)         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1781)         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353)         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)         在org.apache.activemq.command.ActiveMQObjectMessage.getObject(ActiveMQObjectMessage.java:206)         at org.apache.activemq.command.ActiveMQObjectMessage.toString(ActiveMQObjectMessage.java:250)         at java.lang.String.valueOf(String.java:2994)         在java.lang.StringBuilder.append(StringBuilder.java:131)         在org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1952)         在org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:288)         在org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:223)         在org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:241)         在org.apache.activemq.ActiveMQTopicPublisher.publish(ActiveMQTopicPublisher.java:123)。

请帮我理解这个问题,我的代码是:

import java.io.File;
import java.io.IOException;

import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.FileAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.RollingFileAppender;
import org.apache.log4j.net.JMSAppender;

public class Example {
    private static Logger log = Logger.getLogger(Example.class);
    public void publishLogs() throws IOException
    {
        log.info("set the level to root logger");
        Logger logger = Logger.getRootLogger();

        logger.setLevel(Level.TRACE);
        PatternLayout layout = new PatternLayout("%d{ISO8601} [%t] %-5p %c %x - %m%n");
        logger.addAppender(new ConsoleAppender(layout));
        logger.setAdditivity(false);
        JMSAppender jmsappender = new JMSAppender();
        jmsappender.setInitialContextFactoryName("org.apache.activemq.jndi.ActiveMQInitialContextFactory");
        jmsappender.setProviderURL("tcp://localhost:61616");
        jmsappender.setTopicConnectionFactoryBindingName("ConnectionFactory");
        jmsappender.setTopicBindingName("dynamicTopics/logtopic1");
        jmsappender.activateOptions();
        logger.addAppender(jmsappender);
    }
    public static void main(String[] args) throws IOException {

        log.info("main method");

        Example ex = new Example();

        log.info("call the publish logs method");
        ex.publishLogs();

    }

}

的log4j.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true"
    xmlns:log4j='http://jakarta.apache.org/log4j/'>

    <appender name="file" class="org.apache.log4j.RollingFileAppender">
       <param name="append" value="false" />
       <param name="maxFileSize" value="5MB" />
       <param name="maxBackupIndex" value="5" />
       <!-- For Tomcat -->
       <param name="file" value="D:/logs/myStruts1App.log" />
       <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern"
            value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
       </layout>
    </appender>

    <root>
        <level value="ERROR" />
        <appender-ref ref="file" />
    </root>

</log4j:configuration>

0 个答案:

没有答案