6

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

Community
  • 1
  • 1
Alvaro Pedraza
  • 1,176
  • 6
  • 20
  • 44
  • 1
    have you tried changing the logging level at wildfly? `standalone/configuration/standalone.xml` and find the tag ``. change the loggers you want. – Apostolos Jul 13 '16 at 07:58
  • Thanks @Apostolos, I'm reading the documentation, if you know right now how to configure the `standalone-full.xml` (that's the file I'm using) just post it as an answer. – Alvaro Pedraza Jul 13 '16 at 15:58
  • i think it's the same thing. if this worked for you, please let me post it as an answer to accept it. thnx – Apostolos Jul 13 '16 at 16:15

3 Answers3

5

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)
James R. Perkins
  • 16,800
  • 44
  • 60
1

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).

Alvaro Pedraza
  • 1,176
  • 6
  • 20
  • 44
1

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

Clayton K. N. Passos
  • 1,292
  • 12
  • 15