Re: Null pointer error when writing MapMessage key's value to database

2017-10-10 Thread gaurav9...@gmail.com


On 2017-10-11 04:29, Gary Gregory  wrote: 
> On Tue, Oct 10, 2017 at 12:42 AM, gaurav9...@gmail.com  > wrote:
> 
> >
> >
> > On 2017-10-06 20:32, Gary Gregory  wrote:
> > > Hi,
> > >
> > > I think you will get better help if you provide a reproducible JUnit test
> > > case or program, on GitHub for example.
> > >
> > > Whenever you mention an Error or Exception, you should copy it in your
> > > message.
> >
> 
> Again?
> 
> Gary
> 
> 
> > >
> > > Gary
> > >
> > > On Fri, Oct 6, 2017 at 8:48 AM, gaurav9...@gmail.com <
> > gaurav9...@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
> > > >
> > > > 
> > > >
> > > > 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
> > > >
> > > > -
> > > > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > > > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> > > >
> > > >
> > > 1)Test.java
> >
> > package com.test;
> >
> > import org.apache.logging.log4j.*;
> > import org.apache.logging.log4j.message.MapMessage;
> > import java.util.*;
> >
> > public class Test {
> >
> >   public static void main(String[] args) {
> > dbLog();
> >   }
> >
> >   public static void dbLog() {
> > Logger logger = LogManager.getLogger("dbLogger");
> >
> > Map myMap = new HashMap<>();
> > myMap.put("username", "123456");
> > logger.error(new MapMessage(myMap));
> >   }
> > }
> >
> > 2)  log4j2.xml
> >
> > 
> > 
> > 
> >  > method="getDatabaseConnection"/>
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> >
> > 
> > 
> > 
> > 
> > 
> >
> >
> > -
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
> >
> 

The pattern="%K{username}" is not working

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



Re: How to store custom-message variable values to the database table's column using log4j2

2017-10-10 Thread gaurav9...@gmail.com


On 2017-10-11 00:49, Matt Sicker  wrote: 
> Are you using ColumnMapping? See <
> https://logging.apache.org/log4j/2.x/manual/appenders.html#JDBCAppender>.
> 
> See <
> https://github.com/apache/logging-log4j2/blob/master/log4j-nosql/src/test/resources/CassandraAppenderTest.xml>
> for example usage (even though that uses the CassandraAppender, the same
> ColumnMapping element works in JdbcAppender).
> 
> On 10 October 2017 at 09:03, gaurav9...@gmail.com 
> wrote:
> 
> > Hi Log4j2 users,
> >
> > I've created custom-message implementing log4j2's 'message' interface like
> > following tutorial
> > https://logging.apache.org/log4j/2.x/manual/messages.html
> >
> > I've defined JDBCAppender in lo4j2.xml which writes values from above
> > message to database table.
> > I've tried using conversion-pattern %m in the Column configuration but it
> > stores the whole message.
> > Which conversion-pattern to use here to get specific variable values and
> > writing them in the table's column?
> >
> > Link to Stackoverflow question: https://stackoverflow.com/
> > questions/46668645/store-custom-message-variable-
> > values-to-the-database-tables-column-using-log4j2
> >
> >
> > -
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
> >
> 
> 
> -- 
> Matt Sicker 
> 

No.
Here, they are taking the whole message



I dont want that.

e.g.
What I want is following:

when we execute
logger.info(new MyMessage("temp","1234","a...@gmail.com"));

then it should write into a table

name  idemail
temp   1234   a...@gmail.com



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



Re: Null pointer error when writing MapMessage key's value to database

2017-10-10 Thread Gary Gregory
On Tue, Oct 10, 2017 at 12:42 AM, gaurav9...@gmail.com  wrote:

>
>
> On 2017-10-06 20:32, Gary Gregory  wrote:
> > Hi,
> >
> > I think you will get better help if you provide a reproducible JUnit test
> > case or program, on GitHub for example.
> >
> > Whenever you mention an Error or Exception, you should copy it in your
> > message.
>

Again?

Gary


> >
> > Gary
> >
> > On Fri, Oct 6, 2017 at 8:48 AM, gaurav9...@gmail.com <
> gaurav9...@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
> > >
> > > 
> > >
> > > 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
> > >
> > > -
> > > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> > >
> > >
> > 1)Test.java
>
> package com.test;
>
> import org.apache.logging.log4j.*;
> import org.apache.logging.log4j.message.MapMessage;
> import java.util.*;
>
> public class Test {
>
>   public static void main(String[] args) {
> dbLog();
>   }
>
>   public static void dbLog() {
> Logger logger = LogManager.getLogger("dbLogger");
>
> Map myMap = new HashMap<>();
> myMap.put("username", "123456");
> logger.error(new MapMessage(myMap));
>   }
> }
>
> 2)  log4j2.xml
>
> 
> 
> 
>  method="getDatabaseConnection"/>
> 
> 
> 
> 
> 
> 
> 
>
> 
> 
> 
> 
> 
>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


Re: How to store custom-message variable values to the database table's column using log4j2

2017-10-10 Thread Matt Sicker
Are you using ColumnMapping? See <
https://logging.apache.org/log4j/2.x/manual/appenders.html#JDBCAppender>.

See <
https://github.com/apache/logging-log4j2/blob/master/log4j-nosql/src/test/resources/CassandraAppenderTest.xml>
for example usage (even though that uses the CassandraAppender, the same
ColumnMapping element works in JdbcAppender).

On 10 October 2017 at 09:03, gaurav9...@gmail.com 
wrote:

> Hi Log4j2 users,
>
> I've created custom-message implementing log4j2's 'message' interface like
> following tutorial
> https://logging.apache.org/log4j/2.x/manual/messages.html
>
> I've defined JDBCAppender in lo4j2.xml which writes values from above
> message to database table.
> I've tried using conversion-pattern %m in the Column configuration but it
> stores the whole message.
> Which conversion-pattern to use here to get specific variable values and
> writing them in the table's column?
>
> Link to Stackoverflow question: https://stackoverflow.com/
> questions/46668645/store-custom-message-variable-
> values-to-the-database-tables-column-using-log4j2
>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
Matt Sicker 


Re: Version 1.2 - send one logger to a separate file

2017-10-10 Thread Shawn Heisey
On 10/9/2017 5:56 PM, Remko Popma wrote:
> Log4j 1.x was declared End of Life in August 2015 
> (https://blogs.apache.org/foundation/entry/apache_logging_services_project_announces).
>  
> Also, Log4j 1.2 is known to be broken on Java 9 
> (https://blogs.apache.org/logging/entry/moving_on_to_log4j_2). 
>
> Other than that, the people in this community have been focused on Log4j2 for 
> several years and I actually don't think there is anyone here with Log4j 1.x 
> expertise. 
>
> If you're willing to migrate to Log4j2 we may be able to help. 

We are aware of the end of life status, but it's not a trivial exercise
to upgrade.  Multiple issues have been filed to upgrade log4j in Solr,
this is the one that's left after resolving duplicates:

https://issues.apache.org/jira/browse/SOLR-7887

Presumably we're going to need a new LogWatcher implementation for
log4j2 before we can complete the log4j upgrade.  I know almost nothing
about that code.  SOLR-7887 has a work in progress patch that might
implement that watcher, which I have not looked at in depth yet.

Thanks,
Shawn


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



Fwd: How to store custom-message variable values to the database table's column using log4j2

2017-10-10 Thread Matt Sicker
-- Forwarded message --
From: Gaurav Deshpande 
Date: 10 October 2017 at 09:02
Subject: How to store custom-message variable values to the database
table's column using log4j2
To: "mattsic...@apache.org" , "rgo...@apache.org" <
rgo...@apache.org>


Hi Matt/Ralph,



I've created custom-message implementing log4j2's 'message' interface like
following tutorial

https://logging.apache.org/log4j/2.x/manual/messages.html



I've also defined JDBCAppender in lo4j2.xml which writes values from above
message to database table.

I've tried using conversion-pattern %m in the Column configuration but it
stores the whole message.



*Which conversion-pattern to use here to get specific variable values and
writing them in the table's column*?



Link to Stackoverflow question: https://stackoverflow.com/
questions/46668645/store-custom-message-variable-
values-to-the-database-tables-column-using-log4j2



Thanks & Regards,

*Gaurav Deshpande*|*Software Engineer*|


How to store custom-message variable values to the database table's column using log4j2

2017-10-10 Thread gaurav9...@gmail.com
Hi Log4j2 users,

I've created custom-message implementing log4j2's 'message' interface like 
following tutorial
https://logging.apache.org/log4j/2.x/manual/messages.html 

I've defined JDBCAppender in lo4j2.xml which writes values from above message 
to database table.
I've tried using conversion-pattern %m in the Column configuration but it 
stores the whole message.
Which conversion-pattern to use here to get specific variable values and 
writing them in the table's column?

Link to Stackoverflow question: 
https://stackoverflow.com/questions/46668645/store-custom-message-variable-values-to-the-database-tables-column-using-log4j2
 


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



Re: Upgrade from 2.5 to 2.9.0 and Logstash

2017-10-10 Thread Gary Gregory
You might want to post your config and the precise message along with any
stack trace. You can also set status="DEBUG" on the Configuration element
in the config file.

Gary

On Tue, Oct 10, 2017 at 12:54 AM, Pietro Galassi 
wrote:

> Hi,
>
> i've just upgrated log4j from 2.5 to 2.9.0 but after the upgrade i'm not
> able to send logs to logstash.
>
> Either while starting up now the application says that it cant find the
> Async logger.
>


Re: How to add log level for a specific package in log4j2?

2017-10-10 Thread Asma Zinneera Jabir
You can add it as below.

loggers = org.apache.parquet
logger.org.apache.parquet.name = org.apache.parquet
logger.org.apache.parquet.level = ERROR

If you need to add more loggers, add it to the loggers separated by a comma
and add two more lines as above to specify the name and level.

On Fri, Oct 6, 2017 at 2:16 AM, alwin james  wrote:

> Hi Experts -
>
> How can I add log level to a specific package in my project in log4j2 using
> log4j2.properties file?
>
> I am looking forward to something similar to :
> 'log4j.logger.org.apache.parquet=ERROR'
>
> Any help is highly appreciated.
>
> Regards,
> Alwin
>


Re: Programmatically added loggers lost due to automatic reconfiguration

2017-10-10 Thread Michael Heinen

Thanks Gary!
That was exactly what I was looking for.

Michael

Am 06.10.2017 um 17:09 schrieb Gary Gregory:

Hi Michael,

How about
using 
org.apache.logging.log4j.core.config.Configuration.addListener(ConfigurationListener)
?

Gary



On Fri, Sep 29, 2017 at 6:30 AM, Michael Heinen 
wrote:


I use Log4j 2.9.1 with the XML configuration. A monitorInterval is
specified in the XML config in order to reconfigure log4j, e.g. for
debugging.
Besides the XML configuration some loggers and appendes are created
dynamically in Java.

Problem:
The dynamically added loggers and appenders are lost after the XML
configuration has been reloaded.


LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();

Appender appender = RollingFileAppender.newBuilder()...
config.addAppender(appender);

LoggerConfig loggerConfig = LoggerConfig.createLogger(...)
loggerConfig.addAppender(appender, null, null);
config.addLogger(loggerName, loggerConfig);
ctx.updateLoggers();


Could the dynamically added loggers/appenders be isolated from the
automatic reconfiguration?
Is there another way to add them programamtically?

Thanks,
Michael


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





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



Upgrade from 2.5 to 2.9.0 and Logstash

2017-10-10 Thread Pietro Galassi
Hi,

i've just upgrated log4j from 2.5 to 2.9.0 but after the upgrade i'm not
able to send logs to logstash.

Either while starting up now the application says that it cant find the
Async logger.


Re: Null pointer error when writing MapMessage key's value to database

2017-10-10 Thread gaurav9...@gmail.com


On 2017-10-06 20:32, Gary Gregory  wrote: 
> Hi,
> 
> I think you will get better help if you provide a reproducible JUnit test
> case or program, on GitHub for example.
> 
> Whenever you mention an Error or Exception, you should copy it in your
> message.
> 
> Gary
> 
> On Fri, Oct 6, 2017 at 8:48 AM, gaurav9...@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
> >
> > 
> >
> > 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
> >
> > -
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
> >
> 1)Test.java

package com.test;

import org.apache.logging.log4j.*;
import org.apache.logging.log4j.message.MapMessage;
import java.util.*;

public class Test {

  public static void main(String[] args) {
dbLog();
  }

  public static void dbLog() {
Logger logger = LogManager.getLogger("dbLogger");

Map myMap = new HashMap<>();
myMap.put("username", "123456");
logger.error(new MapMessage(myMap));
  }
}

2)  log4j2.xml




















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