0

I am building a JSF application that utilizes the expect4j library and am having a really hard time suppressing the output in the glassfish server log. I tried creating a logging.properties file in my src/main/resources directory based on the expect4j's logging.properties file. I also tried creating a log4j2.xml file to accomplish the same thing. I even tried moving the log4j2.xml file to the WEB-INF directory next to web.xml based on another post I found through the research.

I would like to suppress it because it generates a lot of messages at the info/debug level. Here is an example of the message:

[2016-06-25T14:36:06.195-0600] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=225 _ThreadName=Thread-8] [timeMillis: 1466886966195] [levelValue: 800] [[4229 [__ejb-thread-pool5] DEBUG expect4j.Expect4j  - Found EOF]]

Looking over expect4j, it appears that it only depends on slf4j, so I shouldn't have any issue with defining log4j2 as my logger.

Here are the following dependencies I'm including in my maven project:

  • expect4j : 1.6
  • slf4j-log4j12 : 1.7.7
  • jstl : 1.2
  • jstl-api : 1.2-rev-1
  • javax.ejb-api : 3.2
  • jsf-api : 2.2.8-02
  • jsf-impl : 2.2.8-02
  • primefaces : 5.2
  • log4j-web : 2.6.1

Here is what I have in my logging.properties file:

handlers=java.util.logging.ConsoleHandler
.level=INFO
java.util.logging.ConsoleHandler.level=INFO
#expect4j.handler=java.util.logging.ConsoleHandler
expect4j.level=SEVERE

Here is what I have in my log4j2.xml file:

<?xml version="1.0" encoding="UTF-8" ?>
<Configuration status="INFO">
  <Appenders>
    <Console name="Console" target="STDOUT">
      <PatternLayout
        pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
    </Console>
  </Appenders>
  <Loggers>
    <Logger name="expect4j" level="error" additivity="false">
      <AppenderRef ref="Console" />
    </Logger>
    <Root level="warn">
      <AppenderRef ref="Console" />
    </Root>
  </Loggers>
</Configuration>

I did look at this link, but I wasn't seeing any of what it was pointing out in jconsole when I attached to my glassfish server. Suppress java util logging from 3rd party jar.

Thank you for any help you might be able to provide.

Community
  • 1
  • 1
klog
  • 486
  • 3
  • 10

1 Answers1

2

You are routing all your slf4j output to log4j 1.x by using slf4j-log4j12. Instead, you should use log4j-slf4j-impl. If expect4j is using slf4j you should not need the logging.properties. Althought log4j-slf4j-impl should include them, you should also include the log4j-api and log4j-core jars. If you want java util logging output directed to log4j 2 as well then also include the log4j-jul jar.

rgoers
  • 8,696
  • 1
  • 22
  • 24
  • Thank you @rgoers, that seems to have done the trick. When I initially set up my eclipse project, the suggestions that Maven was offering was incomplete. Eclipse was indicating that the Maven Indexing was disabled, so I did a google search on how to enable it, and eventually I got a more complete repository to search in. This yielded all of the slf4j and log4j libraries I needed. In my case with the expect4j library, the java.util.logging was not necessary as the library is utilizing slf4j. Thanks again for your help. – klog Jun 27 '16 at 03:25