1 /** 2 * LOGBack: the reliable, fast and flexible logging library for Java. 3 * 4 * Copyright (C) 1999-2006, QOS.ch 5 * 6 * This library is free software, you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public License as 8 * published by the Free Software Foundation. 9 */ 10 package ch.qos.logback.classic.pattern; 11 12 import ch.qos.logback.classic.spi.CallerData; 13 import ch.qos.logback.classic.spi.LoggingEvent; 14 15 public class LineOfCallerConverter extends ClassicConverter { 16 17 public String convert(LoggingEvent le) { 18 CallerData[] cda = le.getCallerData(); 19 if (cda != null && cda.length > 0) { 20 return Integer.toString(cda[0].getLineNumber()); 21 } else { 22 return CallerData.NA; 23 } 24 } 25 26 }