[logback-user] OOM on debug level with SLF4j + Logback

Jeff Jensen jjensen at apache.org
Mon Sep 6 20:27:17 CEST 2010

Hey Joern!

Thanks for the reply.  I should have mentioned that all loggers are created
  private final Logger log = LoggerFactory.getLogger(TheClassname.class);

None are static - I don't think there are affects of that, as it is still
one logger instance per class.

Thanks for the code snippet.  I added that in a @BeforeClass and did a
"loggers.size()" for the "// do something"; the max number was 673.  That's
not high (to me).  And that count wouldn't go up or down based on log

I also output the names to review and they are all package or class names.

Thanks again, I appreciate your ideas!

-----Original Message-----
From: logback-user-bounces at qos.ch [mailto:logback-user-bounces at qos.ch] On
Behalf Of Joern Huxhorn
Sent: Monday, September 06, 2010 10:52 AM
To: logback users list
Subject: Re: [logback-user] OOM on debug level with SLF4j + Logback

Hi Jeff,

On 06.09.2010, at 17:25, Jeff Jensen wrote:

> On a whim I changed the log level from DEBUG to INFO and the OOMs stopped;
> this really surprised us.  A lot of logging was occurring so I then
> experimented with appenders, e.g. not using Lilith appender, but that had
> effect.  Only reducing the level had an effect. 

Nice to hear that Lilith wasn't the culprit ;)

> Has anyone experienced this too?  Are their known issues or gotchas that
> may be unknowingly doing with logging?  Any advice on how to find root
> cause?

The only idea I have how this could happen would be the creation of a large
amount of loggers with different names.
Loggers instances are kept in the LoggerFactory so if you have code
somewhere that creates Loggers based on anything else than classname, this
could be the reason.
For example, there could be some code that is creating Loggers using
toString - which would be quite random in case of Objects that have no
explicit toString().

You could check for this using LoggerContext.getLoggerList():

ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
if (loggerFactory instanceof LoggerContext) {
  LoggerContext loggerContext = (LoggerContext) loggerFactory;
  List<Logger> loggers=loggerContext.getLoggerList();
  // do something

I have no other idea right now.

Logback-user mailing list
Logback-user at qos.ch

More information about the Logback-user mailing list