You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by "gaurav9822@gmail.com" <ga...@gmail.com> on 2017/10/06 14:49:28 UTC

MapMessage conversion layout %K not working

Hi log4j2 users,

I have created a MapMessage with a key-value pair

e.g. userName="log4j"

I have configured JDBCAppender with 

<Column name="userName" pattern="%K{userName}"/>

But, it gives null pointer error when tried to insert into database table using %K/%map/%MAP
and works when you put normal message/literal string.

Note: 
'userName' is same for Column-name, pattern and MapMessage-key as well.
Using log4j version 2.9.0

Please help,

Thanks,
Gaurav

Re: MapMessage conversion layout %K not working

Posted by Gary Gregory <ga...@gmail.com>.
Also, cross-posting between the dev and user ML is bad form ;-)

Gary

On Fri, Oct 6, 2017 at 8:49 AM, gaurav9822@gmail.com <ga...@gmail.com>
wrote:

> Hi log4j2 users,
>
> I have created a MapMessage with a key-value pair
>
> e.g. userName="log4j"
>
> I have configured JDBCAppender with
>
> <Column name="userName" pattern="%K{userName}"/>
>
> But, it gives null pointer error when tried to insert into database table
> using %K/%map/%MAP
> and works when you put normal message/literal string.
>
> Note:
> 'userName' is same for Column-name, pattern and MapMessage-key as well.
> Using log4j version 2.9.0
>
> Please help,
>
> Thanks,
> Gaurav
>