You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Kari Arvonen <su...@gmail.com> on 2014/07/23 17:36:24 UTC

How to get Log4j2, Tomcat and Chainsaw work together?

Hello,

Versions:
- Apache Log4j2 2.0 release version
- Apache Tomcat 7.0.54
- Apache Chainsaw 2.1 snapshot (http://people.apache.org/~sdeboy/)
- Oracle Java SE 7 u60 JDK

I have tried to get the XMLLayout to work with Log4j2 assuming it is the
best format for Chainsaw. What is preferred way to do this?

In any case current log4j2.xml placed in one of the Webapps WEB-INF\classes
-directory
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="ALL">
  <Appenders>
    <File name="XmlFile" fileName="logs/0000Atest.log"
immediateFlush="true" append="true">
      <XMLLayout complete="true" charset="UTF-8" compact="false"/>
    </File>
  </Appenders>

  <Loggers>
    <AsyncRoot level="ALL" includeLocation="false">
      <AppenderRef ref="XmlFile"/>
    </AsyncRoot>
  </Loggers>
</Configuration>

Configuration is read properly. Where I have been struggling is which jars
and which versions to include. I have tried various versions and seem to
have always either class not found or implementation missing.

Jars and versions:
- log4j-api-2.0.jar, log4j-core-2.0.jar, log4j-web-2.0.jar,
log4j-1.2-api-2.0.jar
- disruptor-3.2.1.jar
- jackson-annotations-2.4.1.jar, jackson-core-2.4.1.1.jar,
jackson-databind-2.4.1.2.jar
- jackson-dataformat-xml-2.4.1.jar, jackson-datatype-jdk7-2.4.1.jar,
jackson-datatype-json-org-2.4.1.jar,
jackson-module-jaxb-annotations-2.4.1.jar
- stax2-api-3.1.4.jar

I have tried with less jars and various version combinations without
success. Best I have had is log gets written, but only actual text to be
logged not with full XML events. Non XML-layout worked fine.

Code snippets in webapp servlet:
// Log4J 2.x
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.EventLogger;

private Logger log = null;

this.log = LogManager.getLogger(EventReceiverServlet.class.getName());

log.info("Logger initiated");
log.debug("åäöÅÄÖ");
log.debug("Добро пожаловать.");

Latest exception:
SEVERE: Exception processing: 0
org.apache.logging.log4j.core.async.AsyncLoggerConfigHelper$Log4jEventWrapper@1045e84
java.lang.NoSuchMethodError:
com.fasterxml.jackson.databind.util.LRUMap.put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
at
com.fasterxml.jackson.dataformat.xml.util.XmlRootNameLookup.findRootName(XmlRootNameLookup.java:83)

Any help would  be appreciated.

Regards, Suomilapsi

Re: How to get Log4j2, Tomcat and Chainsaw work together?

Posted by Kari Arvonen <su...@gmail.com>.
Hello,

Here is classpath written from Servlet: "Classpath: C:\Program Files
(x86)\test\Tomcat\bin\bootstrap.jar;C:\Program Files
(x86)\test\Tomcat\bin\tomcat-juli.jar". Note that rest is handled by
Tomcat. All of the above mentioned jars are in Webapps/testapp/WEB-INF/lib
-directory of that webapp I am trying to get this working in.

Tomcat/lib has log4j1.2.17.jar.

Regards, Suomilapsi



On Wed, Jul 23, 2014 at 6:51 PM, Gary Gregory <ga...@gmail.com>
wrote:

> Can you add code to your app that shows the value of the java.class.path
> system property? That should help us see what jars and in what order your
> app is using.
>
> Gary
>
>
> On Wed, Jul 23, 2014 at 11:36 AM, Kari Arvonen <su...@gmail.com>
> wrote:
>
>> Hello,
>>
>> Versions:
>> - Apache Log4j2 2.0 release version
>> - Apache Tomcat 7.0.54
>> - Apache Chainsaw 2.1 snapshot (http://people.apache.org/~sdeboy/)
>> - Oracle Java SE 7 u60 JDK
>>
>> I have tried to get the XMLLayout to work with Log4j2 assuming it is the
>> best format for Chainsaw. What is preferred way to do this?
>>
>> In any case current log4j2.xml placed in one of the Webapps
>> WEB-INF\classes
>> -directory
>> <?xml version="1.0" encoding="UTF-8"?>
>> <Configuration status="ALL">
>>   <Appenders>
>>     <File name="XmlFile" fileName="logs/0000Atest.log"
>> immediateFlush="true" append="true">
>>       <XMLLayout complete="true" charset="UTF-8" compact="false"/>
>>     </File>
>>   </Appenders>
>>
>>   <Loggers>
>>     <AsyncRoot level="ALL" includeLocation="false">
>>       <AppenderRef ref="XmlFile"/>
>>     </AsyncRoot>
>>   </Loggers>
>> </Configuration>
>>
>> Configuration is read properly. Where I have been struggling is which jars
>> and which versions to include. I have tried various versions and seem to
>> have always either class not found or implementation missing.
>>
>> Jars and versions:
>> - log4j-api-2.0.jar, log4j-core-2.0.jar, log4j-web-2.0.jar,
>> log4j-1.2-api-2.0.jar
>> - disruptor-3.2.1.jar
>> - jackson-annotations-2.4.1.jar, jackson-core-2.4.1.1.jar,
>> jackson-databind-2.4.1.2.jar
>> - jackson-dataformat-xml-2.4.1.jar, jackson-datatype-jdk7-2.4.1.jar,
>> jackson-datatype-json-org-2.4.1.jar,
>> jackson-module-jaxb-annotations-2.4.1.jar
>> - stax2-api-3.1.4.jar
>>
>> I have tried with less jars and various version combinations without
>> success. Best I have had is log gets written, but only actual text to be
>> logged not with full XML events. Non XML-layout worked fine.
>>
>> Code snippets in webapp servlet:
>> // Log4J 2.x
>> import org.apache.logging.log4j.LogManager;
>> import org.apache.logging.log4j.Logger;
>> import org.apache.logging.log4j.EventLogger;
>>
>> private Logger log = null;
>>
>> this.log = LogManager.getLogger(EventReceiverServlet.class.getName());
>>
>> log.info("Logger initiated");
>> log.debug("åäöÅÄÖ");
>> log.debug("Добро пожаловать.");
>>
>> Latest exception:
>> SEVERE: Exception processing: 0
>>
>> org.apache.logging.log4j.core.async.AsyncLoggerConfigHelper$Log4jEventWrapper@1045e84
>> java.lang.NoSuchMethodError:
>>
>> com.fasterxml.jackson.databind.util.LRUMap.put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
>> at
>>
>> com.fasterxml.jackson.dataformat.xml.util.XmlRootNameLookup.findRootName(XmlRootNameLookup.java:83)
>>
>> Any help would  be appreciated.
>>
>> Regards, Suomilapsi
>>
>
>
>
> --
> 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
>

Re: How to get Log4j2, Tomcat and Chainsaw work together?

Posted by Gary Gregory <ga...@gmail.com>.
Can you add code to your app that shows the value of the java.class.path
system property? That should help us see what jars and in what order your
app is using.

Gary


On Wed, Jul 23, 2014 at 11:36 AM, Kari Arvonen <su...@gmail.com> wrote:

> Hello,
>
> Versions:
> - Apache Log4j2 2.0 release version
> - Apache Tomcat 7.0.54
> - Apache Chainsaw 2.1 snapshot (http://people.apache.org/~sdeboy/)
> - Oracle Java SE 7 u60 JDK
>
> I have tried to get the XMLLayout to work with Log4j2 assuming it is the
> best format for Chainsaw. What is preferred way to do this?
>
> In any case current log4j2.xml placed in one of the Webapps WEB-INF\classes
> -directory
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="ALL">
>   <Appenders>
>     <File name="XmlFile" fileName="logs/0000Atest.log"
> immediateFlush="true" append="true">
>       <XMLLayout complete="true" charset="UTF-8" compact="false"/>
>     </File>
>   </Appenders>
>
>   <Loggers>
>     <AsyncRoot level="ALL" includeLocation="false">
>       <AppenderRef ref="XmlFile"/>
>     </AsyncRoot>
>   </Loggers>
> </Configuration>
>
> Configuration is read properly. Where I have been struggling is which jars
> and which versions to include. I have tried various versions and seem to
> have always either class not found or implementation missing.
>
> Jars and versions:
> - log4j-api-2.0.jar, log4j-core-2.0.jar, log4j-web-2.0.jar,
> log4j-1.2-api-2.0.jar
> - disruptor-3.2.1.jar
> - jackson-annotations-2.4.1.jar, jackson-core-2.4.1.1.jar,
> jackson-databind-2.4.1.2.jar
> - jackson-dataformat-xml-2.4.1.jar, jackson-datatype-jdk7-2.4.1.jar,
> jackson-datatype-json-org-2.4.1.jar,
> jackson-module-jaxb-annotations-2.4.1.jar
> - stax2-api-3.1.4.jar
>
> I have tried with less jars and various version combinations without
> success. Best I have had is log gets written, but only actual text to be
> logged not with full XML events. Non XML-layout worked fine.
>
> Code snippets in webapp servlet:
> // Log4J 2.x
> import org.apache.logging.log4j.LogManager;
> import org.apache.logging.log4j.Logger;
> import org.apache.logging.log4j.EventLogger;
>
> private Logger log = null;
>
> this.log = LogManager.getLogger(EventReceiverServlet.class.getName());
>
> log.info("Logger initiated");
> log.debug("åäöÅÄÖ");
> log.debug("Добро пожаловать.");
>
> Latest exception:
> SEVERE: Exception processing: 0
>
> org.apache.logging.log4j.core.async.AsyncLoggerConfigHelper$Log4jEventWrapper@1045e84
> java.lang.NoSuchMethodError:
>
> com.fasterxml.jackson.databind.util.LRUMap.put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
> at
>
> com.fasterxml.jackson.dataformat.xml.util.XmlRootNameLookup.findRootName(XmlRootNameLookup.java:83)
>
> Any help would  be appreciated.
>
> Regards, Suomilapsi
>



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

Re: How to get Log4j2, Tomcat and Chainsaw work together?

Posted by Scott Deboy <sc...@gmail.com>.
Regarding Chainsaw, it currently doesn't support the XML format
generated by Log4j2, but does support pattern layout based log
formats.  Chainsaw supports most regular text log formats, and has
special support for Log4j's pattern layout.

I'd suggest either configuring Chainsaw manually, or use the
advertiser mechanism described here:
http://logging.apache.org/log4j/2.x/manual/configuration.html#ChainsawSupport

The log4j2 advertiser mechanism works with patternlayout-formatted log
files and requires  the jmdns jar to be on the classpath.

To configure Chainsaw manually to tail a log file generated with a
pattern layout, choose the 'process a log file' option from Chainsaw's
'load Chainsaw configuration' menu option.  If the log file is on the
local file system, browse to it via the 'open file' button.

Next, set the 'log file format type' to PaternLayout format and
provide the pattern layout format used by your appender, then specify
the timestamp format used in your pattern layout.

You can save this configuration in this dialog as an xml file for
later use, and you can tell Chainsaw to always use this configuration
when starting.

Hope that helps.  Feel free to send questions to the list.

Scott


On 7/23/14, Ralph Goers <ra...@dslextreme.com> wrote:
> I recall that there are dependencies on both the jackson 2.x and 1.x jars.
>
> Ralph
>
> On Jul 23, 2014, at 8:36 AM, Kari Arvonen <su...@gmail.com> wrote:
>
>> Hello,
>>
>> Versions:
>> - Apache Log4j2 2.0 release version
>> - Apache Tomcat 7.0.54
>> - Apache Chainsaw 2.1 snapshot (http://people.apache.org/~sdeboy/)
>> - Oracle Java SE 7 u60 JDK
>>
>> I have tried to get the XMLLayout to work with Log4j2 assuming it is the
>> best format for Chainsaw. What is preferred way to do this?
>>
>> In any case current log4j2.xml placed in one of the Webapps
>> WEB-INF\classes
>> -directory
>> <?xml version="1.0" encoding="UTF-8"?>
>> <Configuration status="ALL">
>>  <Appenders>
>>    <File name="XmlFile" fileName="logs/0000Atest.log"
>> immediateFlush="true" append="true">
>>      <XMLLayout complete="true" charset="UTF-8" compact="false"/>
>>    </File>
>>  </Appenders>
>>
>>  <Loggers>
>>    <AsyncRoot level="ALL" includeLocation="false">
>>      <AppenderRef ref="XmlFile"/>
>>    </AsyncRoot>
>>  </Loggers>
>> </Configuration>
>>
>> Configuration is read properly. Where I have been struggling is which
>> jars
>> and which versions to include. I have tried various versions and seem to
>> have always either class not found or implementation missing.
>>
>> Jars and versions:
>> - log4j-api-2.0.jar, log4j-core-2.0.jar, log4j-web-2.0.jar,
>> log4j-1.2-api-2.0.jar
>> - disruptor-3.2.1.jar
>> - jackson-annotations-2.4.1.jar, jackson-core-2.4.1.1.jar,
>> jackson-databind-2.4.1.2.jar
>> - jackson-dataformat-xml-2.4.1.jar, jackson-datatype-jdk7-2.4.1.jar,
>> jackson-datatype-json-org-2.4.1.jar,
>> jackson-module-jaxb-annotations-2.4.1.jar
>> - stax2-api-3.1.4.jar
>>
>> I have tried with less jars and various version combinations without
>> success. Best I have had is log gets written, but only actual text to be
>> logged not with full XML events. Non XML-layout worked fine.
>>
>> Code snippets in webapp servlet:
>> // Log4J 2.x
>> import org.apache.logging.log4j.LogManager;
>> import org.apache.logging.log4j.Logger;
>> import org.apache.logging.log4j.EventLogger;
>>
>> private Logger log = null;
>>
>> this.log = LogManager.getLogger(EventReceiverServlet.class.getName());
>>
>> log.info("Logger initiated");
>> log.debug("åäöÅÄÖ");
>> log.debug("Добро пожаловать.");
>>
>> Latest exception:
>> SEVERE: Exception processing: 0
>> org.apache.logging.log4j.core.async.AsyncLoggerConfigHelper$Log4jEventWrapper@1045e84
>> java.lang.NoSuchMethodError:
>> com.fasterxml.jackson.databind.util.LRUMap.put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
>> at
>> com.fasterxml.jackson.dataformat.xml.util.XmlRootNameLookup.findRootName(XmlRootNameLookup.java:83)
>>
>> Any help would  be appreciated.
>>
>> Regards, Suomilapsi
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: How to get Log4j2, Tomcat and Chainsaw work together?

Posted by Ralph Goers <ra...@dslextreme.com>.
I recall that there are dependencies on both the jackson 2.x and 1.x jars.

Ralph

On Jul 23, 2014, at 8:36 AM, Kari Arvonen <su...@gmail.com> wrote:

> Hello,
> 
> Versions:
> - Apache Log4j2 2.0 release version
> - Apache Tomcat 7.0.54
> - Apache Chainsaw 2.1 snapshot (http://people.apache.org/~sdeboy/)
> - Oracle Java SE 7 u60 JDK
> 
> I have tried to get the XMLLayout to work with Log4j2 assuming it is the
> best format for Chainsaw. What is preferred way to do this?
> 
> In any case current log4j2.xml placed in one of the Webapps WEB-INF\classes
> -directory
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="ALL">
>  <Appenders>
>    <File name="XmlFile" fileName="logs/0000Atest.log"
> immediateFlush="true" append="true">
>      <XMLLayout complete="true" charset="UTF-8" compact="false"/>
>    </File>
>  </Appenders>
> 
>  <Loggers>
>    <AsyncRoot level="ALL" includeLocation="false">
>      <AppenderRef ref="XmlFile"/>
>    </AsyncRoot>
>  </Loggers>
> </Configuration>
> 
> Configuration is read properly. Where I have been struggling is which jars
> and which versions to include. I have tried various versions and seem to
> have always either class not found or implementation missing.
> 
> Jars and versions:
> - log4j-api-2.0.jar, log4j-core-2.0.jar, log4j-web-2.0.jar,
> log4j-1.2-api-2.0.jar
> - disruptor-3.2.1.jar
> - jackson-annotations-2.4.1.jar, jackson-core-2.4.1.1.jar,
> jackson-databind-2.4.1.2.jar
> - jackson-dataformat-xml-2.4.1.jar, jackson-datatype-jdk7-2.4.1.jar,
> jackson-datatype-json-org-2.4.1.jar,
> jackson-module-jaxb-annotations-2.4.1.jar
> - stax2-api-3.1.4.jar
> 
> I have tried with less jars and various version combinations without
> success. Best I have had is log gets written, but only actual text to be
> logged not with full XML events. Non XML-layout worked fine.
> 
> Code snippets in webapp servlet:
> // Log4J 2.x
> import org.apache.logging.log4j.LogManager;
> import org.apache.logging.log4j.Logger;
> import org.apache.logging.log4j.EventLogger;
> 
> private Logger log = null;
> 
> this.log = LogManager.getLogger(EventReceiverServlet.class.getName());
> 
> log.info("Logger initiated");
> log.debug("åäöÅÄÖ");
> log.debug("Добро пожаловать.");
> 
> Latest exception:
> SEVERE: Exception processing: 0
> org.apache.logging.log4j.core.async.AsyncLoggerConfigHelper$Log4jEventWrapper@1045e84
> java.lang.NoSuchMethodError:
> com.fasterxml.jackson.databind.util.LRUMap.put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
> at
> com.fasterxml.jackson.dataformat.xml.util.XmlRootNameLookup.findRootName(XmlRootNameLookup.java:83)
> 
> Any help would  be appreciated.
> 
> Regards, Suomilapsi


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org