Uploaded image for project: 'SLF4J'
  1. SLF4J
  2. SLF4J-317

Get wrong %class content in wrapper class

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • None
    • 1.7.x
    • jul-to-slf4j
    • None
    • Operating System: Windows NT
      Platform: PC

    Description

      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.

      Attachments

        Activity

          People

            slf4j-dev SLF4J developers list
            monkeyk1987@gmail.com shengzhao li
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: