In this case MyPatternLayout recognizes %# conversion pattern. It outputs the value of an internal counter which is also incremented at each call.
See source code for more details.
this(DEFAULT_CONVERSION_PATTERN);
super(pattern);
return new MyPatternParser( pattern == null ? DEFAULT_CONVERSION_PATTERN : pattern);
Layout layout = new MyPatternLayout("[counter=%.10#] - %m%n"); Logger logger = Logger.getLogger("some.cat"); logger.addAppender(new ConsoleAppender(layout, ConsoleAppender.SYSTEM_OUT)); logger.debug("Hello, log"); logger.info("Hello again...");