Open guillermomolina opened 3 days ago
Hi,
I am really not familiar with Jboss modules, but there is probably a way to allow a module to use the java.util.logging
classes that seems to be disabled by default.
For example there are a few references to adding java.logging
as a module dependency.
What happens here is that Jboss modules are loaded in an isolated classloader that filter what is allowed to access in the JDK, which is why you get a NoClassDefFoundError
on a standard JDK class.
As an alternative, maybe using the library directly into your application instead of JBoss classloader could be a simpler option.
Hi,
Thank you very much for the tip:
This:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.9" name="co.elastic.logging">
<resources>
<resource-root path="ecs-logging-core-1.6.0.jar"/>
<resource-root path="jboss-logmanager-ecs-formatter-1.6.0.jar"/>
</resources>
<dependencies>
<module name="org.jboss.logging"/>
<module name="java.logging"/>
</dependencies>
</module>
Does not throw the exception any more. But I've added a handler, to create a file log with this formatter in my standalone.xml:
<periodic-rotating-file-handler name="ELASTIC" autoflush="true">
<filter-spec value="not(match("JBAS015960"))"/>
<formatter>
<named-formatter name="ECS"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.json"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
The file is created but nothing is written into it:
[jboss@jb7-1 log]$ ls -la server.json
-rw-r--r-- 1 jboss aplicacions 0 Jun 29 06:42 server.json
I've modified standalone/configuration/standalone.xml as documented:
<formatter name="ECS">
<custom-formatter module="co.elastic.logging" class="co.elastic.logging.jboss.logmanager.EcsFormatter" >
<properties>
<property name="serviceName" value="my-app"/>
<property name="serviceVersion" value="my-app-version"/>
<property name="serviceEnvironment" value="my-app-environment"/>
<property name="serviceNodeName" value="my-app-cluster-node"/>
</properties>
</custom-formatter>
</formatter>
But log file is still 0 bytes, any thoughts?
By the way, the documentation is also missing that you have to configure some JAVA options in standalone.conf:
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager"
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:$(ls ${JBOSS_HOME}/modules/system/layers/base/org/wildfly/common/main/wildfly-common-*.jar)"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:$(ls ${JBOSS_HOME}/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-*.jar)"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:${JBOSS_HOME}/jboss-modules.jar"
Again, I have almost no expertise in Jboss logging,
but does the filtering is mandatory with <filter-spec value="not(match("JBAS015960"))"/>
? The URL-encoded characters seem off to me, but trying without it and simplify to the minimum could help here.
For the extra JVM options, those are very jboss/wildfly specific, so I am not sure how relevant they are in general to all jboss deployments. The most common use-case is to use those ECS loggers directly into the applications, not to deploy them globally on the server.
When using the Elastic APM Java agent, the jboss.modules.system.pkgs
and java.util.logging.manager
should be managed by the agent, which makes the setup simpler.
I have JBoss 7.4.15.
I've added the module as the documentation suggested:
modules/co/elastic/logging/main/module.xml
standalone/configuration/standalone.xml
JBoss won't boot:
Please help me, is there anything more to add to the module definition? Thanks