From Angsuman Chakraborty (archived) :
/** Get the current line number.
* @return int - Current line number.
*/
public static int getLineNumber() {
return Thread.currentThread().getStackTrace()[2].getLineNumber();
}
More Related Contents:
- How to read and copy the HTTP servlet response output stream content for logging
- How to Create a Custom Appender in log4j2?
- How to do a JUnit assert on a message in a logger
- Redirect System.out.println
- Turning off hibernate logging console output
- How can I create 2 separate log files with one log4j config file?
- How to use AOP with AspectJ for logging?
- Should you report the message text of exceptions?
- Most efficient way to log messages to JavaFX TextArea via threads with simple custom logging frameworks
- How to use MDC with thread pools?
- How to configure slf4j-simple
- limiting java ssl debug logging
- Where can I view Tomcat log files in Eclipse?
- Should a “static final Logger” be declared in UPPER-CASE?
- log4j configuration via JVM argument(s)?
- Disable HttpClient logging
- How do I change java logging console output from std err to std out?
- Logging user activity in web app
- How can I configure Logback to log different levels for a logger to different destinations?
- Spring: Standard Logging aspect (interceptor)
- how to make log4j to write to the console as well
- Java Logging vs Log4J [closed]
- Know of any Java garbage collection log analysis tools? [closed]
- Disable the log from specific class/jar via logback.xml
- How to delete old logs with log4j2
- Spring Boot, logback and logging.config property
- java.util.logging: how to suppress date line
- How to configure log4j to only keep log files for the last seven days?
- Why chose XML over properties files for Log4J configuration?
- log4j migration to log4j2