Q:

custom Log4j2 wrapper and output

I have an Custom Wrapper around Log4j2.  and I have some problems on output, under the XXX line is what i want.  but when I use "Log.info()"  I cant get the same result.  any workaround except "Log .getLog().info()" 

here is code
public class TestMyLog {
public static void main(String[] args){
    Log.info("asdasggg");
    Log.debug("asdasda");
    Log.fatal("asdwefe");
    Log.error("fgggg");
    Log.warn("sdsdee");
    Log.trace("ioimom");
    System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
    Log.getLog().info("sdss");
    Log.getLog().debug("dddddd");
    Log.getLog().error("erffs");

}

}
public class Log{
public static Log4j getLog(){
    return new Log4j2Wrapper();
}
public static void info(String str){
    new  Log4j2Wrapper().info(str);
}
public static void debug(String str){
    new  Log4j2Wrapper().debug(str);
}
public static void error(String str){
    new  Log4j2Wrapper().error(str);
}
public static void fatal(String str){
    new  Log4j2Wrapper().fatal(str);
}
public static void trace(String str){
    new  Log4j2Wrapper().trace(str);
}
public static void warn(String str){
    new  Log4j2Wrapper().warn(str);
}
public static boolean isInfoEnabled(){
    return new Log4j2Wrapper().isInfoEnabled();
}
public static boolean isDebugEnabled(){
    return new Log4j2Wrapper().isDebugEnabled();
}
public static boolean isErrorEnabled(){
    return new Log4j2Wrapper().isErrorEnabled();
}
public static boolean isFatalEnabled(){
    return new Log4j2Wrapper().isFatalEnabled();
}
public static boolean isWarnEnabled(){
    return new Log4j2Wrapper().isWarnEnabled();
}
public static boolean isTraceEnabled(){
    return new Log4j2Wrapper().isTraceEnabled();
}

}
public class Log4j2Wrapper implements Log4j{
private static final String FQCN = Log4j2Wrapper.class.getName();
private ExtendedLoggerWrapper log;

public Log4j2Wrapper() {
    Logger logger = LogManager.getLogger();
    log = new ExtendedLoggerWrapper((ExtendedLogger) logger,
            logger.getName(), logger.getMessageFactory());
}

public boolean isInfoEnabled() {
    return log.isInfoEnabled();
}
public boolean isDebugEnabled() {
    return log.isDebugEnabled();
}
public boolean isErrorEnabled() {
    return log.isErrorEnabled();
}
public boolean isFatalEnabled() {
    return log.isFatalEnabled();
}
public boolean isWarnEnabled() {
    return log.isWarnEnabled();
}
public boolean isTraceEnabled() {
    return log.isTraceEnabled();
}
public void info(String str) {
    log.logIfEnabled(FQCN, Level. INFO, null, new SimpleMessage(str), null);
}
public void info(String str, Throwable t) {
    log.logIfEnabled(FQCN, Level. INFO, null, new SimpleMessage(str), t);
}
public void debug(String str){
    log.logIfEnabled(FQCN, Level. DEBUG,null,new SimpleMessage(str),null);
}
public void error(String str){
    log.logIfEnabled(FQCN, Level. ERROR,null,new SimpleMessage(str),null);
}
public void fatal(String str){
    log.logIfEnabled(FQCN, Level. FATAL,null,new SimpleMessage(str),null);
}
public void trace(String str){
    log.logIfEnabled(FQCN, Level. TRACE,null,new SimpleMessage(str),null);
}
public void warn(String str){
    log.logIfEnabled(FQCN, Level. WARN,null,new SimpleMessage(str),null);
}

}
public interface Log4j {
boolean isInfoEnabled();
boolean isDebugEnabled();
boolean isErrorEnabled();
boolean isFatalEnabled();
boolean isWarnEnabled();
boolean isTraceEnabled();
void info(String str);
void info(String str, Throwable t);
void debug(String str);
void error(String str);
void fatal(String str);
void warn(String str);
void trace(String str);

}

A:

If you want to write a custom Logger wrapper it becomes tricky to get location info right because Log4j2 walks the stacktrace for a number of steps to find that location, and your wrapper adds an extra StacktraceElement.  
I recommend you create your custom wrapper using a Log4j2 tool: take a look at the manual page for custom log levels.  This tool can generate code for a custom logger that correctly handles location information.  
P.S.
Be aware that walking the stacktrace to find the logging location is very expensive in terms of performance.  The async logging page has some concrete numbers.  It's like throwing an exception with every log message. 