0

I find a lot of examples of how to change Ehcache logging level for slf4j and logback (1, 2). But how to do the same if my application uses JUL for logging?

logging.properties

.level=INFO

# Handlers
handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
org.apache.juli.FileHandler.level = INFO

java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

# this has no visible effect on logging:
net.sf.ehcache=ALL

dependencies

<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache</artifactId>
    <version>2.10.4</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-ehcache</artifactId>
    <version>4.3.11.Final</version>
</dependency>
naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259

1 Answers1

2

Set the logging level by adding .level for the property in the logging properties file. Can be applied to packages as well as individual classes/loggers.

# This should have a bigger effect
net.sf.ehcache.level=ALL

Now this will allow for logging all levels for net.sf.ehcache. Note, that your log handler must also permit logging on that level, so if you need to log more detailed than INFO for a handler you must change that detail level as well. For instance:

java.util.logging.ConsoleHandler.level = ALL

To combine all of this for you logging properties example like this:

.level=INFO

# Handlers
handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
org.apache.juli.FileHandler.level = INFO

java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

net.sf.ehcache.level=ALL

The above will log ehcache logging for all levels in your ConsoleHandler and up to INFO for all other loggers/classes/packages. For FileHandler everything is logged up to INFO level only.

DanielBarbarian
  • 5,093
  • 12
  • 35
  • 44
  • Thanks! Your answer is helpful. But I noticed that I need additionally to lower logging level of ConsoleHandler or FileHandler, otherwise messages below INFO are not displayed in log. For example: `java.util.logging.ConsoleHandler.level = ALL` – naXa stands with Ukraine Mar 22 '18 at 12:02
  • Yeah, I thought you knew that. I added additional explanations in the answer. – DanielBarbarian Mar 22 '18 at 12:22