Skip to content

static loggers prevent Dozer usage as a shared library #84

@eis

Description

@eis

Dozer uses "private static final Logger" pattern all around in its code, like for example in DozerCacheManager:

private static final Logger log = LoggerFactory.getLogger(DozerCacheManager.class);

this makes it not possible to deploy Dozer as a shared library without breaking platform log configuration. This issue has been discussed in commons logging wiki, for example. Quoting, in short:

The technical result of using static is obvious: there is only one Log reference
shared across all instances of the class. This is clearly memory efficient; only one
reference(4 or 8 bytes) is needed no matter how many instances are created. It is
also CPU-efficient; the lookup required to find the Log instance is only done once,
when the class is first referenced.

When writing stand-alone application code the use of static is a good idea.

However when the java code concerned is a library that may be deployed within
a container of some sort (such as a J2EE server) then problems can occur. [..]

In most cases, simply leaving out the "static" qualifier from the Log reference is
the correct solution.

This is the issue we're currently seeing using JBoss modules for our libraries.

Static modifier should be dropped from Logger declarations, leaving only final.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions