JSON logging

570 views
Skip to first unread message

Torste Aikio

unread,
May 7, 2018, 1:50:10 PM5/7/18
to Thorntail
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


Ladislav Thon

unread,
May 9, 2018, 3:30:31 AM5/9/18
to thor...@googlegroups.com

Updating a library that comes from WildFly itself is usually painful. I'm afraid there's little WildFly Swarm -- ah sorry! -- Thorntail can do.

To explain what's going on with the log -- what you're able to configure is WildFly's logging subsystem. Before the subsystem kicks in, there's a default logging configuration, which in WildFly can be customized by editing logging.properties, but that's not possible in Thorntail: https://issues.jboss.org/browse/THORN-743

LT

--
You received this message because you are subscribed to the Google Groups "Thorntail" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thorntail+...@googlegroups.com.
To post to this group, send email to thor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/thorntail/c7cf8995-4178-4680-9723-5a11e7473f66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thorntail

unread,
Jul 2, 2018, 3:51:55 PM7/2/18
to Thorntail
I have started a new fraction for OpenShift/k8s logging, which also requires JSON output.

The key is using as the reference the logstash fraction, that uses the jboss-logging-ext library which has a JSON formatter.

And you get stuff like:

{"@version":1,"@timestamp":"2018-07-02T14:23:50.004-0500","sequence":36,"loggerClassName":"org.wildfly.extension.undertow.logging.UndertowLogger_$logger","loggerName":"org.wildfly.extension.undertow","level":"INFO","threadName":"MSC service thread 1-1","message":"WFLYUT0004: Undertow 1.4.18.Final stopping","threadId":21,"mdc":{},"ndc":"","wildflySwarmNode":"vm101037-cts70"}
{"@version":1,"@timestamp":"2018-07-02T14:23:50.084-0500","sequence":37,"loggerClassName":"org.jboss.as.server.logging.ServerLogger_$logger","loggerName":"org.jboss.as.server.deployment","level":"INFO","threadName":"MSC service thread 1-6","message":"WFLYSRV0028: Stopped deployment examples-openshift-logging.war (runtime-name: examples-openshift-logging.war) in 214ms","threadId":26,"mdc":{},"ndc":"","wildflySwarmNode":"vm101037-cts70"}
{"@version":1,"@timestamp":"2018-07-02T14:23:50.123-0500","sequence":38,"loggerClassName":"org.jboss.as.server.logging.ServerLogger_$logger","loggerName":"org.jboss.as","level":"INFO","threadName":"MSC service thread 1-1","message":"WFLYSRV0050: WildFly Swarm 2018.5.0 (WildFly Core 3.0.8.Final) stopped in 195ms","threadId":21,"mdc":{},"ndc":"","wildflySwarmNode":"vm101037-cts70"}

I am having some problems replacing the default CONSOLE handler to use the new OPENSHIFT formatter. To get this to work I need to add some code to the project-defaults.yml which I am trying to avoid.

If you want a look I can put up in my Github fork. Or if someone has a good answer.

-dave

Ken Finnigan

unread,
Jul 3, 2018, 2:32:14 PM7/3/18
to Thorntail
Reply all
Reply to author
Forward
0 new messages