You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Eduardo Macarron <ed...@gmail.com> on 2013/04/11 10:08:34 UTC

FQCN in log4j 2

HI all,

We have just included a log4j 2 wrapper in MyBatis. It is trivial, it
just takes a class, implements  org.apache.ibatis.logging.Log and
holds a log4j 2 Logger instance inside.

https://github.com/mybatis/mybatis-3/blob/master/src/main/java/org/apache/ibatis/logging/log4j2/Log4j2Impl.java

In the log4j and slf4j wrappers we use these methods so the logging
tool is able to know the right caller:

Looger#log(String callerFQCN, Priority level, Object message, Throwable t)
LocationAwareLogger#log(Marker marker, String fqcn, int level, String
message, Object[] argArray, Throwable t)

How can we port that code to Log4j 2?

Thanks in advance!!

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: FQCN in log4j 2

Posted by Ralph Goers <ra...@dslextreme.com>.
Yes - that is exactly what the class is for.  You can find couple examples of how to use it in the SLF4J adapter and the JCL bridge sub projects.

Ralph


On Apr 11, 2013, at 9:22 AM, Eduardo Macarron wrote:

> Hi again,
> 
> I found an AbstractLoggerWrapper class that looks suitable for this.
> 
> https://github.com/mybatis/mybatis-3/commit/6b7dd95d042b6e283c16eefbaa35a754184b7c9c
> 
> Not sure if this is the right way but... works! :)
> 
> 2013/4/11 Eduardo Macarron <ed...@gmail.com>:
>> HI all,
>> 
>> We have just included a log4j 2 wrapper in MyBatis. It is trivial, it
>> just takes a class, implements  org.apache.ibatis.logging.Log and
>> holds a log4j 2 Logger instance inside.
>> 
>> https://github.com/mybatis/mybatis-3/blob/master/src/main/java/org/apache/ibatis/logging/log4j2/Log4j2Impl.java
>> 
>> In the log4j and slf4j wrappers we use these methods so the logging
>> tool is able to know the right caller:
>> 
>> Looger#log(String callerFQCN, Priority level, Object message, Throwable t)
>> LocationAwareLogger#log(Marker marker, String fqcn, int level, String
>> message, Object[] argArray, Throwable t)
>> 
>> How can we port that code to Log4j 2?
>> 
>> Thanks in advance!!
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: FQCN in log4j 2

Posted by Eduardo Macarron <ed...@gmail.com>.
Hi again,

I found an AbstractLoggerWrapper class that looks suitable for this.

https://github.com/mybatis/mybatis-3/commit/6b7dd95d042b6e283c16eefbaa35a754184b7c9c

Not sure if this is the right way but... works! :)

2013/4/11 Eduardo Macarron <ed...@gmail.com>:
> HI all,
>
> We have just included a log4j 2 wrapper in MyBatis. It is trivial, it
> just takes a class, implements  org.apache.ibatis.logging.Log and
> holds a log4j 2 Logger instance inside.
>
> https://github.com/mybatis/mybatis-3/blob/master/src/main/java/org/apache/ibatis/logging/log4j2/Log4j2Impl.java
>
> In the log4j and slf4j wrappers we use these methods so the logging
> tool is able to know the right caller:
>
> Looger#log(String callerFQCN, Priority level, Object message, Throwable t)
> LocationAwareLogger#log(Marker marker, String fqcn, int level, String
> message, Object[] argArray, Throwable t)
>
> How can we port that code to Log4j 2?
>
> Thanks in advance!!

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org