logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mohit Anchlia <mohitanch...@gmail.com>
Subject Re: Unit testing log4j JMS Appender
Date Wed, 02 Apr 2014 17:07:25 GMT
I am trying to convert my log4.properties from 1.x to log4j.xml 2.0-rc1 but
I am running into this issue

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
 <appender class="org.apache.log4j.appender.TimeAndSizeRollingAppender"
  name="search-indexer-async">
  <param value="false" name="BufferedIO" />
  <param value="'.'yyyy-MM-dd" name="DatePattern" />
  <param value="true" name="DateRollEnforced" />
  <param value="${mule.home}/logs/mule-app-client-api.log" name="file" />
  <param value="500MB" name="MaxFileSize" />
  <param value="10" name="MaxRollFileCount" />
  <layout class="org.apache.log4j.PatternLayout">
   <param value="[%d{MM/dd/yyyy HH:mm:ss,SSS}] %-5p %c{3} [%t](%x): %m%n"
    name="ConversionPattern" />
  </layout>
  <!-- Log entries that make it past this filter will be logged -->
 </appender>
 <appender name="async" class="org.apache.log4j.AsyncAppender">
  <param name="BufferSize" value="4096" />
  <param name="blocking" value="false" />
  <appender-ref ref="search-indexer-async" />
 </appender>
 <appender name="search-indexer-async-jms"
class="org.apache.log4j.net.JMSAppender">
  <param name="InitialContextFactoryName"
   value="org.apache.activemq.jndi.ActiveMQInitialContextFactory" />
  <param name="ProviderURL" value="tcp://localhost:61616" />
  <param name="TopicBindingName" value="indexTopicEndpoint" />
  <param name="TopicConnectionFactoryBindingName" value="ConnectionFactory"
/>
  <appender-ref ref="async" />
 </appender>

log4j:WARN No such property [blocking] in org.apache.log4j.AsyncAppender.
log4j:ERROR Could not create an Appender. Reported error follows.
java.lang.ClassNotFoundException:
org.apache.log4j.appender.TimeAndSizeRollingAppender
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Unknown Source)
 at org.apache.log4j.helpers.Loader.loadClass(Loader.java:160)
 at
org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:164)
 at
org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:140)
 at
org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153)
 at
org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:201)
 at
org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:140)
 at
org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153)
 at
org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:415)
 at
org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:335)
 at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:781)
 at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:666)
 at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616)
 at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:602)
 at
org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:460)
 at org.apache.log4j.LogManager.<clinit>(LogManager.java:113)
 at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
 at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
 at
org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
 at
org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
 at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272)
 at org.mule.util.SystemUtils.<clinit>(SystemUtils.java:35)
 at
org.mule.tck.junit4.AbstractMuleTestCase.<clinit>(AbstractMuleTestCase.java:71)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
 at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
 at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
 at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
 at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
 at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
 at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
 at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
log4j:ERROR Could not create an Appender. Reported error follows.
java.lang.NullPointerException
 at java.util.Hashtable.put(Unknown Source)
 at
org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:141)
 at
org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153)
 at
org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:201)
 at
org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:140)
 at
org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153)
 at
org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:415)
 at
org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:335)
 at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:781)
 at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:666)
 at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616)
 at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:602)
 at
org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:460)
 at org.apache.log4j.LogManager.<clinit>(LogManager.java:113)
 at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
 at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
 at
org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
 at
org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
 at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272)
 at org.mule.util.SystemUtils.<clinit>(SystemUtils.java:35)
 at
org.mule.tck.junit4.AbstractMuleTestCase.<clinit>(AbstractMuleTestCase.java:71)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
On Tue, Apr 1, 2014 at 12:41 PM, Gary Gregory <garydgregory@gmail.com>wrote:

> On Tue, Apr 1, 2014 at 3:13 PM, Mohit Anchlia <mohitanchlia@gmail.com
> >wrote:
>
> > Is there a stable version available?
>
>
> Yes: https://logging.apache.org/log4j/2.x/
>
>
> > How do I reload configuration?
>
>
> Please see:
> -
>
> https://logging.apache.org/log4j/2.x/manual/configuration.html#AutomaticReconfiguration
> -
>
> https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/config/Reconfigurable.html#reconfigure()
>
>
> > I am
> > using log4j.properties and not xml
> >
>
> Log4j 2 does not support properties files for configuration. It might one
> day, but not now.
>
> Gary
>
>
> >
> > On Tue, Apr 1, 2014 at 12:09 PM, Gary Gregory <garydgregory@gmail.com
> > >wrote:
> >
> > > You would be better served using version 2 which we are actively
> working
> > > on.
> > >
> > > Gary
> > >
> > > -------- Original message --------
> > > From: Mohit Anchlia <mohitanchlia@gmail.com>
> > > Date:04/01/2014  15:01  (GMT-05:00)
> > > To: Log4J Users List <log4j-user@logging.apache.org>
> > > Subject: Unit testing log4j JMS Appender
> > >
> > > I am trying to unit test log4j with jms appender, however even before I
> > > bring up the jms embedded broker service log4j.properties get loaded
> and
> > it
> > > fails to connect to the broker. Is there a way to reload log4j after
> the
> > > broker is up?
> > >
> >
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition<
> http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message