0

I have several web app modules with same groupId deployed on wildfly 18, let's say org.foo.ecommerce

These modules are configured with its own subgroup , therefore:

  1. module1 - org.foo.ecommerce.mod1
  2. module2 - org.foo.ecommerce.mod2
  3. module3 - org.foo.ecommerce.mod3

So I configured wildfly with an handler for each module, like the following:

<periodic-rotating-file-handler name="MOD1_HANDLER">
    <level name="DEBUG"/>
    <encoding value="UTF-8"/>
    <formatter>
        <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] - %s%E%n"/>
    </formatter>
    <file relative-to="log.path" path="mod1.log"/>
    <suffix value=".yyyy-MM-dd"/>
</periodic-rotating-file-handler>

<logger category="org.foo.ecommerce.mod1" use-parent-handlers="false">
    <handlers>
        <handler name="MOD1_HANDLER"/>
    </handlers>
</logger>

Now, if for some reason a NullPointerException is thrown, I can find it ONLY on wildfly server.log.

How can I display all exceptions on the module that belongs from ?

UPDATE

This is the stacktrace on console / server.log

org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
    at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:82)
    at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:346)
    at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:193)
    at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:456)
    at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:229)
    at org.jboss.resteasy.resteasy-jaxrs@3.9.1.Final//org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:135)
    at org.jboss.resteasy.resteasy-

Notice that even if I declare my own exception the behaviour is the same

@javax.ejb.ApplicationException(rollback = true)
public class ApplicationException extends RuntimeException {
}
Fabrizio Stellato
  • 1,727
  • 21
  • 52

2 Answers2

1

The reason the NullPointerException is always logged to the server.log is because it's coming from RESTEasy. Any server level modules will log at the servers log configuration level. If a deployment creates it's own log configuration only log messages logged from the deployment are logged to that configuration.

That said there is an open issue, WFCORE-4807, which may allow logs created in server modules to be logged to a deployments configuration.

James R. Perkins
  • 16,800
  • 44
  • 60
0

You are better to use per deployment logging. That way you get logs for anything based on that deployment, not just based on the package name of the class

Will Tatam
  • 566
  • 3
  • 10
  • Can I still use jboss logging or I should disable it ? Is there any guide on how to configure per deployment logging? – Fabrizio Stellato Aug 06 '20 at 09:09
  • UPDATE: I added slf4j-log4j12 library and log4j.properties, but I can't spot differences on how errors are handled, as I can see NullPointerException logged ONLY on server dev output – Fabrizio Stellato Aug 06 '20 at 11:07