logzio / logzio-log4j2-appender

Log4j2 Appender that ships logs using HTTPs bulk
Apache License 2.0
9 stars 11 forks source link

NullpointerException in Mule 3.9 #14

Closed jonasliekens closed 6 years ago

jonasliekens commented 6 years ago

When using the appender in the Mule 3.9 runtime, A NullpointException gets thrown on startup. Is it possible some dependencies are missing or I am overlooking something in the configuration?

As far as I am aware, Mule 3.9 uses Log4j2 (2.8.2) through SLF4J.

Stacktrace.txt log4j2.xml

asafalima commented 6 years ago

Hi @jonasliekens,

Can you please provide us with more info ? I used your log4j2.xml with mule-standalone-3.9.0 by adding the jar of our appender to the classpath in conf/wrapper.conf and it worked.

jonasliekens commented 6 years ago

Hi @asafalima

We use maven to build our Mule projects which are deployed on Cloudhub (Anypoint Platform). I created a little hello world project that reproduces the problem. You can find it here.

asafalima commented 6 years ago

Can you please provide the output of: mvn dependency:tree

I can't run the project, the project you created uses dependencies from the EE version

jonasliekens commented 6 years ago

Sure, output attached here. :)

justinsaliba commented 6 years ago

Hi all,

I'm piggybacking on this issue because I'm facing the same issue. I've done some digging but I would like the developer of this appender to validate my claims.

Basically MuleSoft have two offerings of Mule:

What @asafalima tested was the on premise version, which I can understand works OK because Mule in itself uses a file to log its log events, whereas the applications are free to choose whatever appenders they want. I may have traced the issue to MappedPageFactory, within the BigQueue library which the logzio-sender uses (and is packaged with this appender).

The problem is that, on startup the logging framework (log4j2) is starting, and as part of the startup process, MappedPageFactory class is calling private final static Logger logger = LoggerFactory.getLogger(MappedPageFactory.class);. This returns a null, and therefore a NPE is encountered at io.logz.sender.com.bluejeans.common.bigqueue.MappedPageFactory.acquirePage(MappedPageFactory.java:90). Line 90 contains the following: if (logger.isDebugEnabled())

The above does not break when deploying to the on premise version is because Mule in itself has already initialised log4j, and therefore this library is able to obtain a logger without issues. However, this is not the case on CloudHub since the log4j framework is initialised along with the application.

jonasliekens commented 6 years ago

Hi @justinsaliba,

I also issued a ticket to Mulesoft Support, because the issue pops up with every other 3rd party log appender. As far as I understood, they more or less confirmed what you are describing. :) The way the application or the mule runtime is booted in Cloudhub basically prevents you from using 3rd party appenders, as the dependencies are not available for log4j at boot. Even the Log4j JsonAppender crashes the Mulesoft application.

MuleSoft Support proposed to create an entry in the Mulesoft Ideas portal (https://support.mulesoft.com/s/ideas) so that at some point in time they could update the runtime to support 3rd party appenders if the demand is there.

I hope this helps to validate your claims :)

Botom of the line: There is nothing wrong with the Logzio appender, even works quite nice with Java Spring. Just not for Mulesofts Cloudhub...

@asafalima: I will close the ticket, because the issue is not on logzios side. Thanks for the support though 👍

justinsaliba commented 6 years ago

Hi Jonas, thanks for closing the loop on this. Did you ever create the "idea" on the MuleSoft portal. I could +1 it in hopes of getting this addressed.

cr-dev1 commented 5 years ago

Hello @justinsaliba.

I am working on the custom appender for mule application to push logs into logzio. I am not able to achieve this. Below is the log4j2 file configuration. Could you please help me.

<?xml version="1.0" encoding="utf-8"?>

******** myAwesomeType https://listener.logz.io:8071 true
idohalevi commented 5 years ago

@cr-dev1 Can you check if the in-memory solution works for you? I believe it should work around this issue.

ramusettypalli commented 5 years ago

@idohalevi This is cr-dev1. I have added inMemoryQueue as true But no luck.

<?xml version="1.0" encoding="utf-8"?>

************** myAwesomeType https://listener.logz.io:8071 true
idohalevi commented 5 years ago

@cr-dev1 Can you please share the error logs you get?