When creating an embedded server via
EmbeddedProcessFactory.createStandaloneServer
there is no possibility to enable stdout echoing - the command --std-out=echo
arg is not allowed here.
Now calling CLI commands on this server discards all the output and if any error message is not meaningful, how to debug this?
If you're using the WildFly embedded server directly, you can control logging via any log manager. By default this will use the JBoss Log Manager. You'd just need to make sure a logging.properties
file is on your class path. Here is an example configuration for the JBoss Log Manager.
# Additional logger names to configure (root logger is always configured)
loggers=
# Root logger level
logger.level=INFO
# Root logger handlers
logger.handlers=CONSOLE
# Console handler configuration
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.properties=autoFlush
handler.CONSOLE.autoFlush=true
handler.CONSOLE.formatter=PATTERN
# Formatter pattern configuration
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=%K{level}%d{HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%e%n
You could use a different log manager as well like logback or log4j2. With the Configuration.Builder
you'd set the logging hint. Here is an example using log4j2.
final StandaloneServer server = EmbeddedProcessFactory.createStandaloneServer(
Configuration.Builder.of(Path.of("/opt/wildfly-27.0.1.Final"))
.setLoggerHint(Configuration.LoggerHint.LOG4J2)
.build());
try {
server.start();
try (ModelControllerClient client = ModelControllerClient.Factory.create("localhost", 9990)) {
final ModelNode op = Operations.createOperation("read-resource");
op.get("attributes-only").set(true);
System.out.println(client.execute(op));
}
} finally {
server.stop();
}