logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: Unit testing log4j JMS Appender
Date Wed, 02 Apr 2014 17:53:47 GMT
I do not have time to dig deeper today, sorry. Maybe someone else will
chirp in...

Gary


On Wed, Apr 2, 2014 at 1:40 PM, Mohit Anchlia <mohitanchlia@gmail.com>wrote:

> It appears that the dependency jar is trying to use log4j 1. Do you have
> any suggestion on how I can resolve this issue? This is my new config and
> error follows that:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="warn" name="MyApp" packages="">
>   <Appenders>
>     <RollingFile name="search-indexer-async-log"
> fileName="${mule.home}/logs/mule-search-indexer-async.log"
> filePattern="logs/app-%d{MM-dd-yyyy}.log.gz>
>       <PatternLayout>
>         <Pattern>[%d{MM/dd/yyyy HH:mm:ss,SSS}] %-5p %c{3} [%t](%x):
> %m%n</pattern>
>       </PatternLayout>
>         <TimeBasedTriggeringPolicy />
>         <SizeBasedTriggeringPolicy size="500 MB"/>
>     </RollingFile>
>     <Async name="async" blocking="false">
>       <AppenderRef ref="search-indexer-async-log"/>
>     </Async>
>         <JMSTopic name="search-indexer-async-jms-topic"
> topicBindingName="indexTopicEndpoint"
>               factoryBindingName="ConnectionFactory"
> providerURL="tcp://localhost:61616"/>
>         <Async name="async-jms" blocking="false">
>           <AppenderRef ref="search-indexer-async-jms-topic"/>
>         </Async>
>   </Appenders>
>   <Loggers>
>      <Logger name="com.intuit.cfp.search.async" additivity="false"
> level="TRACE">
>       <AppenderRef ref="async-jms"/>
>     </Logger>
>     <Root level="error">
>       <AppenderRef ref="async"/>
>     </Root>
>   </Loggers>
> </Configuration>
>
>
>
> SLF4J: Class path contains multiple SLF4J bindings.
>
> SLF4J: Found binding in
>
> [jar:file:/C:/Users/manchlia/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
>
> SLF4J: Found binding in
>
> [jar:file:/C:/Users/manchlia/.m2/repository/org/apache/activemq/activemq-all/5.9.0/activemq-all-5.9.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
>
> SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
> explanation.
>
>
>
> log4j:WARN Continuable parsing error 2 and column 68
>
> log4j:WARN Document root element "Configuration", must match DOCTYPE root
> "null".
>
> log4j:WARN Continuable parsing error 2 and column 68
>
> log4j:WARN Document is invalid: no grammar found.
>
> log4j:ERROR DOM element is - not a <log4j:configuration> element.
>
> log4j:WARN No appenders could be found for logger
> (org.apache.activemq.broker.BrokerService).
>
> log4j:WARN Please initialize the log4j system properly.
>
> log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
> more info.
>
>
> On Wed, Apr 2, 2014 at 10:12 AM, Gary Gregory <garydgregory@gmail.com
> >wrote:
>
> > The stack trace below shows the code trying to process an XML
> configuration
> > with Log4j 1. You cannot have log4j version 1 on the classpath if you
> want
> > to use version 2. The XML format between version 1 and 2 is different.
> > Log4j 2 has a version 1 compatibility module you can use.
> >
> > Gary
> >
> >
> > On Wed, Apr 2, 2014 at 1:07 PM, Mohit Anchlia <mohitanchlia@gmail.com
> > >wrote:
> >
> > > 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
> > > >
> > >
> >
> >
> >
> > --
> > 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
> >
>



-- 
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