[logback-dev] [JIRA] Commented: (LBCLASSIC-303) LoggingEvent.getCallerData() fails when called from a sub class
Greg Thomas (JIRA)
noreply-jira at qos.ch
Thu Nov 3 21:33:12 CET 2011
[ http://jira.qos.ch/browse/LBCLASSIC-303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12256#action_12256 ]
Greg Thomas commented on LBCLASSIC-303:
---------------------------------------
It does - many thanks. I can now get my re-factored DBAppender test for LBCORE-220 working, I just need to add an additional multi-threaded test.
I think the report in the original description is still valid; but it's a pretty low priority issue, as there is the work around that you suggested. Unfortunately, I mistakenly left the priority at the default (Major) and now can't change it!
> LoggingEvent.getCallerData() fails when called from a sub class
> ---------------------------------------------------------------
>
> Key: LBCLASSIC-303
> URL: http://jira.qos.ch/browse/LBCLASSIC-303
> Project: logback-classic
> Issue Type: Bug
> Affects Versions: 1.0.0
> Reporter: Greg Thomas
> Assignee: Logback dev list
>
> This is probably best demonstrated with a code example;
> package com.example;
> import ch.qos.logback.classic.Level;
> import ch.qos.logback.classic.Logger;
> import ch.qos.logback.classic.LoggerContext;
> import ch.qos.logback.classic.spi.LoggingEvent;
> public class Test {
> Logger logger;
> public static void main(String[] args) {
> Test test = new Test();
> test.go();
> }
> private void go() {
> SuperClass anotherClass = new SuperClass();
> anotherClass.go();
> anotherClass = new SubClass();
> anotherClass.go();
> }
> private class SuperClass {
> public void go() {
> LoggerContext lc = new LoggerContext();
> lc.setName("default");
> // ... a logger
> logger = lc.getLogger("root");
> LoggingEvent le = new LoggingEvent(this.getClass().getName(),
> logger, Level.DEBUG, "Test logging event", new Exception(
> "test Ex"), new String[] { "something" });
> StackTraceElement[] callerData = le.getCallerData();
> System.out.println("LoggingEvent in " + this.getClass().getName() + " has "
> + callerData.length + " stack trace elements:");
> for (StackTraceElement stackTraceElement : callerData) {
> System.out.println("Element=" + stackTraceElement);
> }
> }
> }
> private class SubClass extends SuperClass {
> }
> }
> The output of this is as follows;
> LoggingEvent in com.example.Test$SuperClass has 2 stack trace elements:
> Element=com.example.Test.go(Test.java:20)
> Element=com.example.Test.main(Test.java:14)
> LoggingEvent in com.example.Test$SubClass has 0 stack trace elements:
> This is despite exactly the same go() method being called; it's not being modified in the subclass. Note that although the example uses inner classes, the same behaviour is exhibited in regular classes too.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the logback-dev
mailing list