Hi,
I'm trying to set up Wildfly Swarm logger to use JSON format for logs. So far I've stumbled upon following issues:
* project-defaults.yml where logging is configured is not picked up from WAR automatically
* JsonFormatter is only included in jboss-logmanager 2.1.x, WF swarm is using 2.0.7
* Above can be worked around by creating custom module that uses jboss-logmanager-ext
* Custom modules do not work with the default microprofile hollow JAR because the module is not found before the WAR is loaded (as far as I can tell)
* Even with uberjar and custom module and everything mostly working, the first few lines are still output using some default formatter:
> java -jar target\myapp-swarm.jar -s src\main\resources\project-defaults.yml
2018-05-07 16:43:12,423 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Logging - STABLE org.wildfly.swarm:logging:2018.3.3
2018-05-07 16:43:12,430 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Bean Validation - STABLE org.wildfly.swarm:bean-validation:2018.3.3
2018-05-07 16:43:12,432 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: CDI Configuration - STABLE org.wildfly.swarm:cdi-config:2018.3.3
2018-05-07 16:43:12,433 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Elytron - STABLE org.wildfly.swarm:elytron:2018.3.3
2018-05-07 16:43:12,434 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: CDI - STABLE org.wildfly.swarm:cdi:2018.3.3
2018-05-07 16:43:12,436 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: JAX-RS - STABLE org.wildfly.swarm:jaxrs:2018.3.3
2018-05-07 16:43:12,437 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Eclipse MicroProfile Config - STABLE org.wildfly.swarm:microprofile-config:2018.3.3
2018-05-07 16:43:12,438 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Transactions - STABLE org.wildfly.swarm:transactions:2018.3.3
2018-05-07 16:43:12,438 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Undertow - STABLE org.wildfly.swarm:undertow:2018.3.3
2018-05-07 16:43:14,540 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.7.SP1
2018-05-07 16:43:14,639 INFO [
org.jboss.as] (MSC service thread 1-7) WFLYSRV0049: WildFly Swarm 2018.3.3 (WildFly Core 3.0.8.Final) starting
2018-05-07 16:43:14,685 INFO [org.wildfly.swarm] (MSC service thread 1-7) WFSWARM0019: Install MSC service for command line args: [-s, src\main\resources\project-defaults.yml]
2018-05-07 16:43:15,501 INFO [org.wildfly.security] (ServerService Thread Pool -- 9) ELY00001: WildFly Elytron version 1.1.6.Final
{"timestamp":"2018-05-07T16:43:18+03:00","sequence":13,"loggerClassName":"org.jboss.as.jaxrs.logging.JaxrsLogger_$logger","loggerName":"org.jboss.as.jaxrs","level":"INFO","message":"WFLYRS0016: RESTEasy version 3.0.24.Final","threadName":"ServerService Thread Pool -- 21","threadId":51,"mdc":{},"ndc":""}
...
For reference this is the project-defaults.yml I'm using now:
swarm:
logging:
console-handlers:
JSON_CONSOLE:
named-formatter: json-formatter
custom-formatters:
json-formatter:
attribute-class: org.jboss.logmanager.ext.formatters.JsonFormatter
module: logmanager-ext
root-logger:
handlers:
- JSON_CONSOLE
This all seems very convoluted for something that I hoped would be fairly straightforward thing to configure. Any ideas on how to make JSON logging less painful here? Would making some custom "JSON logger" fraction possibly help somehow? Although I'm not sure if that could possibly help with the bootstrap process apparently using its own logger (??). And I would need to build my own hollowjar and all that jazz. I was also thinking if it would be possible to update jboss-logmanager in WF swarm, but I have no idea how to do that and what it would involve.
/Torste Aikio