2

I'm in the middle of a upgrade for an application currently moving Spring core from 4.3 to 5.2 (yeah, trying the milestone expecting the LTS release) and it requires us to move to log4j2.

The problem we have so far is that I cannot seem to find anything on how to make JAMon work with this new configuration. The appender fail with this message:

java.lang.NoSuchMethodException: org.apache.log4j.api.LoggingEvent.<init>(Ljava/lang/String;Lorg/apache/log4j/Category;Jorg/apache/log4j/Priority...)

And, in the project, the last we heard from maintainer was this (looks like the current version does not support changing appenders to log4j2).

E.g. in log4j.jsp, it imports

<%@ page import="com.jamonapi.MonitorFactory, org.apache.log4j.Logger, org.apache.log4j.PropertyConfigurator, java.util.Properties" %>

and the JAMonAppender class in the source code says

public class JAMonAppender extends AppenderSkeleton {
    /* Prefix for this classes jamon monitor labels */
    private final String PREFIX = "com.jamonapi.log4j.JAMonAppender.";

    // any of these poperties can be overridden via log4j configurators.
    private int bufferSize = 100;

    private String units = "log4j"; // units in jamon montiors

So it seems to be hardwired to ye olde log4j. Has anyone managed to make it work?

Alfabravo
  • 7,493
  • 6
  • 46
  • 82

2 Answers2

0

I think you have a typo above. The class should be org.apache.log4j.spi.LoggingEvent. Both Log4j2 and SLF4J provide adapters for Log4j 1.x but neither of them includes a LoggingEvent constructor, much less one that matches the signature you are missing. But I really don't think that is necessary (no one has ever requested it before). Unless the JAMonAppender is being programmatically instantiated it would be fairly simple to create a JAMonAppender for Log4j. That said, the last update to JAMon was 4 years ago so I'd be surprised if a PR would be accepted.

One thing I should make clear - the JAMonAppender will ONLY work with log4j 1.2 doing the logging. If your goal is to use Log4j 2 rewriting the appender will be required.

rgoers
  • 8,696
  • 1
  • 22
  • 24
0

Note, I am the creator of jamonapi. Although, I haven't made updates in a while it is still supported and we could add a log4j 2 appender if anyone would want it. I know this is an old post, but let me know what you think....

EDIT: as of jamon 2.82 JAMonAppender has been updated to work with log4j 2. For log4j It gives the ability to see how many times each level was called (ERROR, INFO) as well as allows you to 'tail' the log via a web app. It monitors many other aspects of your application too. Here is a link for log4j2 - http://jamonapi.sourceforge.net/log4j_jamonappender.html