class name is displayed incorrectly for java inner classes

Hi I am using log back-1.0.13. Bellow is the output and sample java code I used to test log back with. noticed that I have an inner class how ever the log output always displays the class name as the outer class. Is there a way to set up log back so that it prints something like outer.inner ??? Also has anyone given any thought to defining an XSD file? This would allow my ice (eclipse) to catch a lot of configuration problems for me. I really appreciate all the hard work everyone has put into this project thanks in advance andy [SLF4JConsoleTest.java] [line 50] [thr main] [class SLF4JConsoleTest] [execute()] Test: INFO level message. [SLF4JConsoleTest.java] [line 53] [thr main] [class SLF4JConsoleTest] [execute()] Test: WARN level message. [SLF4JConsoleTest.java] [line 56] [thr main] [class SLF4JConsoleTest] [execute()] Test: ERROR level message. [SLF4JConsoleTest.java] [line 73] [thr main] [class SLF4JConsoleTest] [execute()] MyInnerClass: INFO level message. [SLF4JConsoleTest.java] [line 76] [thr main] [class SLF4JConsoleTest] [execute()] MyInnerClass: WARN level message. [SLF4JConsoleTest.java] [line 79] [thr main] [class SLF4JConsoleTest] [execute()] MyInnerClass: ERROR level message. <?xml version="1.0" encoding="UTF-8"?> <configuration> <!-- <turboFilter class="ch.qos.logback.classic.turbo.MarkerFilter"> < ! - - http://logback.qos.ch/manual/filters.html http://logback.qos.ch/demo.html - - > <Name>FORK_JOIN_MARKER_FILTER</Name> <Marker>FORK_JOIN_MARKER</Marker> <OnMismatch>DENY</OnMismatch> <OnMatch>ACCEPT</OnMatch> </turboFilter> --> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <!-- <Pattern>%5p %d{ISO8601} [%t] [%c{0}] [line %L] %m %n</Pattern> --> <Pattern>[%15file] [line %4L] [thr %4t] [class %17c{0}] [%method\(\)] %m %n</Pattern> </layout> </appender> <root level="INFO"> <appender-ref ref="STDOUT" /> </root> </configuration> public class SLF4JConsoleTest { static final Logger LOG = LoggerFactory.getLogger(SLF4JConsoleTest.class); /** * @param args */ public static void main(String[] args) { SLF4JConsoleTest console = new SLF4JConsoleTest(); console.execute(); } public SLF4JConsoleTest() { } public void execute() { if (LOG.isTraceEnabled()) { LOG.trace("Test: TRACE level message."); } if (LOG.isDebugEnabled()) { LOG.debug("Test: DEBUG level message."); } if (LOG.isInfoEnabled()) { LOG.info("Test: INFO level message."); } if (LOG.isWarnEnabled()) { LOG.warn("Test: WARN level message."); } if (LOG.isErrorEnabled()) { LOG.error("Test: ERROR level message."); } MyInnerClass mic = new MyInnerClass(); mic.execute(); } public class MyInnerClass { public void execute() { if (LOG.isTraceEnabled()) { LOG.trace("MyInnerClass: TRACE level message."); } if (LOG.isDebugEnabled()) { LOG.debug("MyInnerClass: DEBUG level message."); } if (LOG.isInfoEnabled()) { LOG.info("MyInnerClass: INFO level message."); } if (LOG.isWarnEnabled()) { LOG.warn("MyInnerClass: WARN level message."); } if (LOG.isErrorEnabled()) { LOG.error("MyInnerClass: ERROR level message."); } } } }

Andy, The name of the logger is set when the logger is created form the LoggerFactory. You are creating LOG in your outer class. Try creating another logger in your inner class. David

Many thanks. I incorrectly the class name was picked off the stack. Andy On Jul 17, 2013, at 1:23 AM, David Roussel <nabble@diroussel.xsmail.com> wrote:
Andy,
The name of the logger is set when the logger is created form the LoggerFactory. You are creating LOG in your outer class. Try creating another logger in your inner class.
David _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Re: XSD See this answer: http://stackoverflow.com/questions/5731162/xml-schema-or-dtd-for-logback-xml But if you can live with an unofficial XSD, try this one: https://github.com/enricopulatzo/logback-XSD If you find any problems with that XSD, remember to submit a pull request back to the author so others may benefit. David

many thanks being new to logback, I have found it hard to figure out where the pattern stuff is documented. What I know is based on copying config files from other projects Andy On Jul 17, 2013, at 2:29 AM, David Roussel <nabble@diroussel.xsmail.com> wrote:
On 17 Jul 2013, at 02:03, Andrew E. Davidson <andy_davidson@apple.com> wrote:
[class %17c{0}]
Note that here you are logging the name of the logger, use upper case C to log the class name of the caller. _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

On 17 Jul 2013, at 18:01, "Andrew E. Davidson" <andy_davidson@apple.com> wrote:
I have found it hard to figure out where the pattern stuff is documented.
Andy, you can find the pattern layout documented here: http://logback.qos.ch/manual/layouts.html#ClassicPatternLayout

many thanks! Andy On Jul 17, 2013, at 10:06 AM, David Roussel <nabble@diroussel.xsmail.com> wrote:
On 17 Jul 2013, at 18:01, "Andrew E. Davidson" <andy_davidson@apple.com> wrote:
I have found it hard to figure out where the pattern stuff is documented.
Andy, you can find the pattern layout documented here: http://logback.qos.ch/manual/layouts.html#ClassicPatternLayout _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
participants (2)
-
Andrew E. Davidson
-
David Roussel