[slf4j-dev] [Bug 326] New: Get wrong %class content in wrapper class

bugzilla-daemon at qos.ch bugzilla-daemon at qos.ch
Wed Feb 4 12:39:04 CET 2015


http://bugzilla.slf4j.org/show_bug.cgi?id=326

          Priority: P5
            Bug ID: 326
          Assignee: slf4j-dev at qos.ch
           Summary: Get wrong %class content in wrapper class
          Severity: enhancement
    Classification: Unclassified
                OS: Windows NT
          Reporter: monkeyk1987 at gmail.com
          Hardware: PC
            Status: NEW
           Version: 1.7.x
         Component: jul-to-slf4j
           Product: SLF4J

I define a Java Object: LogHelper, use it wrapper the logger operations, the
main codes as follow:

    private final Logger logger;

    protected LogHelper(Class clazz) {
        this.logger = LoggerFactory.getLogger(clazz);
    }

    public void info(String msg) {
        if (logger.isInfoEnabled()) {
            logger.info(currentUser() + LOG_DELIMITER + msg);
        }
    }
    ...

Then when i want to record log use LogHelper replace Logger, code as follow:

    private static final LogHelper LOG = LogHelper.create(Activity.class);


In the log file can not get the current Class name(Activity class),
always get LogHelper class name, the log content look like:

2014-11-28 14:39:15 xxx.infrastructure.log.LogHelper:89 - lisz|Start to
generate [2014-10] Attendance-Report...

the log appender configuration is:
    <appender name="SchedulerAppender"
class="ch.qos.logback.core.FileAppender">
        <file>../logs/xxx_scheduler.log</file>
        <append>true</append>
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss} %class:%line - %msg%n</pattern>
        </encoder>
    </appender>


We expect the %class is Activity class, not LogHelper class, but it is failed.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/slf4j-dev/attachments/20150204/d20f328f/attachment.html>


More information about the slf4j-dev mailing list