-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with Log4j2Plugins.dat when shading with maven-shade-plugin #47
Comments
Looks like it didn't start properly. Let's find out why. I've noticed that you've changed <Configuration status="INFO"> to <Configuration > You may find some useful logs there. If that doesn't help, try to run this HC example with your XML config with status logging and <Root level="info"> (cause <IndexTemplate name="logs-audit-" path="classpath:BOOT-INF/classes/indexTemplate.json" /> (cause template file will not be resolved otherwise) and dependencies you specified. With no other modifications to HC example, cURL should return this:
|
I've changed the Configuration back to status=INFO.
This is when I build the application, and run it with java -jar. I did notice some maven shading errors thrown out when packaging it, which may be part of the problem
I'm not running a spring boot application, it's just a plain java application, so I thought that classpath:indexTemplate.json was required. I tried building the example but it failed to build:
The end goal for me is to insert this configuration into a Spark job (which will have different set of dependencies). |
actually means "I couldn't find the Elasticsearch plugin after collecting all META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat files". Since you're shading, exploded jars will just override each other's .dat files. And yes, you got a warning regarding this file:
I've found an article on this issue, but I haven't testsed this solution and I'm not sure whether this would be acceptable for you ( SpringBoot doesn't have this problem because all jars are kept separately, so each file is loaded as separate resource. Given that, onejar-maven-plugin looks very promising. Fortunately, there's a way to avoid Log4j2 Plugins and XML config completely and use HCHttp as an ES client directly: asyncBatchDelivery.add(indexName, itemSourceFactory.create(logEvent, objectWriter)); Have a look at programmatic config. asyncBatchDelivery.start(); before you put anything in there.
As for your compile issues, I'm not sure how to help you.. At first glance it looks like corrupted download? Try to clean your repository and build again. |
I've managed to build your examples thanks, it was a corrupt log4j dependency. And I've re-jigged my dependencies in my app to match SpringBoot example, and it appears that your appender (no classpath issues) is getting configured and run, but still no output to Elastic. Output below
|
Output looks good (apart from the ChronicleMap error at the end.. should be fixed soon). However, it should also include a line communicating the allocation of response buffer
If it's not there, it means that the response was not received - was there a request at all? What does the cURL say?
There is a chance that logs are not getting to ElasticsearchAppender. Do to you get the logger by name? LogManager.getLogger("elasticsearch"); or by class? LogManager.getLogger(com.pcc.Logging.class); If former, debugging ElasticsearchAppender.append() or HCResultCallback.completed() is the only way to figure out what happened. I'll add some more DEBUG logging in future releases to identify these issues earlier, but for now, I ran out of options. |
@marcusbb Did you manage to identify the issue? |
@marcusbb Are still having this issue? Is there anything I can help you with? |
@rfoltyns - thanks I got distracted and am on a new strategy for collecting and publishing logs. I may end up returning to this or one of my peers. |
Description
Configuring a simple java application to log into a local Elastic node
Configuration
pom.xml
log4j2.xml - Basically copy and paste from your examples
Runtime (please complete the following information):
Additional context
log4j messages printed out fine but no index or other information in debug messages.
The text was updated successfully, but these errors were encountered: