Alvaro Pedraza
Alvaro Pedraza

Reputation: 1292

Wildfly 10 not showing debug messages

I'm testing my ear application on the container and I need to see some debugging messages I spread on my application. I'm using slf4j-api with log4j as logging framework.

During my test phase (out of the container) all logging was working perfectly, so the configuration is fine. But now I've deployed the application with the same configuration but my messages are not showing. Here is my log4j's config:

#rootLogger config
log4j.rootLogger=INFO, console

#appender config
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console..threshold=DEBUG
log4j.appender.console.target=System.out
log4j.appender.console.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.console.layout.ConversionPattern=%d{ABSOLUTE} [%t] %p %l - %m%n

# Log JDBC bind parameter runtime arguments
log4j.logger.org.hibernate.type=INFO

#application logger config
log4j.logger.ar.edu.unt.sigea=DEBUG, console

As I said, when I run my @Test methods, all my logger.debug() messages are shown correctly, but now that I'm running on the container with the same configuration, no debug message is shown.

I found this post and added the line log4j.appender.console..threshold=DEBUG as suggested by the answer but didn't work.

I'm deploying on Wildfly-10.0.0.Final Application Server and I'm using this logging dependencies:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.21</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.7.21</version>
</dependency>

What am I missing? Where should I look for? Thanks in advance for your answers

Upvotes: 6

Views: 13426

Answers (3)

Clayton K. N. Passos
Clayton K. N. Passos

Reputation: 1362

switch the log level to DEBUG on console

{wildfly}/bin/jboss-cli.sh --connect

[standalone@localhost:9990 /] /subsystem=logging/console-handler=CONSOLE:write-attribute(name=level,value=DEBUG)

[standalone@localhost:9990 /] /subsystem=logging/root-logger=ROOT:write-attribute(name=level,value=DEBUG)

switch it back to whatever it was initial configuration (here it is INFO)

[standalone@localhost:9990 /] /subsystem=logging/console-handler=CONSOLE:write-attribute(name=level,value=INFO)

[standalone@localhost:9990 /] /subsystem=logging/root-logger=ROOT:write-attribute(name=level,value=INFO)

From: https://gist.github.com/lfryc/aae879ceb5534292e150

Upvotes: 2

Alvaro Pedraza
Alvaro Pedraza

Reputation: 1292

looking at this Wildfly Documentation I realized that my log4j.properties file was located in a wrong place: it was in a submodule of my project and must be in the META-INF folder of the EAR module.

By default, Wildfly takes the deployment's logging configuration, so no extra configuration is needed in standalone.xml (or standalone-full.xml depending on what profile are you using, which is my case).

Upvotes: 1

James R. Perkins
James R. Perkins

Reputation: 17780

You don't need to use the log4j binding unless you want to use your own log4j configuration. From the configuration file it looks like you're just using console appender which is already provided by the WildFly logging subsystem.

All you need to do to see debug messages with your current configuration is to remove the log4j.properties from your deployment and remove the org.slf4j:slf4j-log4j12 dependency from your pom. Then you can use the logging subsystem to configure logging and turn on/off debug logging. If you use CLI or the web console you can change logging levels without restarting the server.

To add a debug level and change the default console-handler level to DEBUG. The following two CLI commands are all you need to configure debug logging.

/subsystem=logging/logger=ar.edu.unt.sigea:add(level=DEBUG)
/subsystem=logging/console-handler=CONSOLE:write-attribute(name=level, value=DEBUG)

Upvotes: 5

Related Questions