title: Log4j2 wanna log the file&line number of caller
body: <p>I got the way to log the file path and line number from <a href="https://stackoverflow.com/questions/7930844/is-it-possible-to-have-clickable-class-names-in-console-output-in-intellij">Is it possible to have clickable class names in console output in IntelliJ?</a></p>
  <p>But for some reason I have to do call the logging related method in a wrapped class (the reason is that I am bridging some self developped logging framework to log4j2):</p>
  <pre class="lang-java prettyprint-override"><code>public class ILogAdapter extends CommonLogger {
      @Override
      public void info(String title, Throwable throwable) {
          // this.logger = org.apache.logging.log4j.LogManager.getLogger(key);
          logger.info(title, throwable);
      }
  </code></pre>
  <p>now when I do the log, the top method of callstack and file and line number always in this method, can I someway change this behavior?</p>
  <p>update:</p>
  <p>anyway I got a way to get the file/linenumber of the caller, and put it in the mdc context:</p>
  <pre class="lang-java prettyprint-override"><code>    private void getLineAndFileOfCaller() {
          ThreadContext.clearAll();
          try {
              throw new IllegalStateException();
          } catch (Exception ex) {
              final StackTraceElement[] stackTrace = ex.getStackTrace();
              if(stackTrace.length &gt; 3) {
                  final StackTraceElement stackTraceElement = stackTrace[stackTrace.length - 3];
                  ThreadContext.put(&quot;file&quot; , Objects.toString(stackTraceElement.getFileName()));
                  ThreadContext.put(&quot;line&quot;, Objects.toString(stackTraceElement.getLineNumber()));
              }
          }
      }
  </code></pre>
  <p>then I change my bridge method to:</p>
  <pre class="lang-java prettyprint-override"><code>    @Override
      public void debug(String title, String message) {
          getLineAndFileOfCaller();
          logger.debug(String.format(&quot;[%s] %s&quot;, title, message));
      }
  </code></pre>
  <p>and set the log pattern to:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;Configuration status=&quot;INFO&quot;&gt;
      &lt;Appenders&gt;
          &lt;Console name=&quot;Console&quot; target=&quot;SYSTEM_OUT&quot;&gt;
              &lt;!--&lt;PatternLayout pattern=&quot;%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n&quot;/&gt;--&gt;
              &lt;!--&lt;PatternLayout pattern=&quot;%-5p - [%-80m] - at %c.%M(%F:%L)%n&quot;/&gt;--&gt;
              &lt;PatternLayout pattern=&quot;%(X{file}:%X{line}): %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n&quot;/&gt;
          &lt;/Console&gt;
      &lt;/Appenders&gt;
      &lt;Loggers&gt;
          &lt;Root level=&quot;INFO&quot;&gt;
              &lt;AppenderRef ref=&quot;Console&quot;/&gt;
          &lt;/Root&gt;
      &lt;/Loggers&gt;
  &lt;/Configuration&gt;
  </code></pre>
  <p>when I calling something like</p>
  <pre class="lang-java prettyprint-override"><code>ILogAdapter#debug(java.lang.String, java.lang.String)
  </code></pre>
  <p>I can get the file and linenumber of where i logged, but not the file and linenumber of the adapter in console.</p>
  <p>I dont know if it's any better solution yet.</p>