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 "Poythress, Lynn" <ap...@skymail.csus.edu> on 2008/11/20 23:55:37 UTC

How to log ip addresses?

Hi,

We are running Unicon's uPortal product.  It utilizes log4j and we have a log4j.properties file which creates a portal.log file.  In that portal.log file it logs users that log on to the portal.  We would like it to log the ip address of each user; currently it just shows user name and userid.

Do we modify the log4j.properties file to have it add each user's ip address to the log?

If so, can you point me in the right direction?  I read about appenders, but couldn't see any parameters that would specifically capture ip addresses.

Thanks,
Lynn Poythress


RE: How to log ip addresses?

Posted by "Poythress, Lynn" <ap...@skymail.csus.edu>.
Maarten,

Thanks for the suggestion.  I'll look into PatternLayout.

Lynn

-----Original Message-----
From: Maarten Bosteels [mailto:mbosteels.dns@gmail.com]
Sent: Friday, November 21, 2008 12:14 AM
To: Log4J Users List
Subject: Re: How to log ip addresses?

 Hi,

I don't know uPortal, but I you can probably do something like this:

* at the start of every request, retrieve the user's IP addess and put it in
the MDC
* in your log4j.properties specify a PatternLayout that outputs the MDC,
something like %X{IP}
* at the end of the request remove the IP from the MDC

see
http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html
http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/MDC.html

Maarten

On Fri, Nov 21, 2008 at 2:45 AM, Dong Zhang <dz...@seven.com> wrote:

> Hi Lynn,
>
> I have no idea about uPortal, but for log4j, it has no application
> specific configuration, e.g. username, ip address, etc.
>
> The reason you see username, is uPortal application logged it. So if you
> want ip address, you need to look into uPortal doc/configuration files,
> instead of log4j configuration.
>
> Dong
>
> -----Original Message-----
> From: Poythress, Lynn [mailto:apoythre@skymail.csus.edu]
> Sent: Friday, November 21, 2008 6:56 AM
> To: log4j-user@logging.apache.org
> Subject: How to log ip addresses?
>
> Hi,
>
> We are running Unicon's uPortal product.  It utilizes log4j and we have
> a log4j.properties file which creates a portal.log file.  In that
> portal.log file it logs users that log on to the portal.  We would like
> it to log the ip address of each user; currently it just shows user name
> and userid.
>
> Do we modify the log4j.properties file to have it add each user's ip
> address to the log?
>
> If so, can you point me in the right direction?  I read about appenders,
> but couldn't see any parameters that would specifically capture ip
> addresses.
>
> Thanks,
> Lynn Poythress
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: How to log ip addresses?

Posted by Maarten Bosteels <mb...@gmail.com>.
 Hi,

I don't know uPortal, but I you can probably do something like this:

* at the start of every request, retrieve the user's IP addess and put it in
the MDC
* in your log4j.properties specify a PatternLayout that outputs the MDC,
something like %X{IP}
* at the end of the request remove the IP from the MDC

see
http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html
http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/MDC.html

Maarten

On Fri, Nov 21, 2008 at 2:45 AM, Dong Zhang <dz...@seven.com> wrote:

> Hi Lynn,
>
> I have no idea about uPortal, but for log4j, it has no application
> specific configuration, e.g. username, ip address, etc.
>
> The reason you see username, is uPortal application logged it. So if you
> want ip address, you need to look into uPortal doc/configuration files,
> instead of log4j configuration.
>
> Dong
>
> -----Original Message-----
> From: Poythress, Lynn [mailto:apoythre@skymail.csus.edu]
> Sent: Friday, November 21, 2008 6:56 AM
> To: log4j-user@logging.apache.org
> Subject: How to log ip addresses?
>
> Hi,
>
> We are running Unicon's uPortal product.  It utilizes log4j and we have
> a log4j.properties file which creates a portal.log file.  In that
> portal.log file it logs users that log on to the portal.  We would like
> it to log the ip address of each user; currently it just shows user name
> and userid.
>
> Do we modify the log4j.properties file to have it add each user's ip
> address to the log?
>
> If so, can you point me in the right direction?  I read about appenders,
> but couldn't see any parameters that would specifically capture ip
> addresses.
>
> Thanks,
> Lynn Poythress
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

RE: How to log ip addresses?

Posted by "Poythress, Lynn" <ap...@skymail.csus.edu>.
Dong,

Thanks for the suggestion.  I'll look into it from that angle.

Lynn

-----Original Message-----
From: Dong Zhang [mailto:dzhang@seven.com]
Sent: Thursday, November 20, 2008 5:45 PM
To: Log4J Users List
Subject: RE: How to log ip addresses?

Hi Lynn,

I have no idea about uPortal, but for log4j, it has no application
specific configuration, e.g. username, ip address, etc.

The reason you see username, is uPortal application logged it. So if you
want ip address, you need to look into uPortal doc/configuration files,
instead of log4j configuration.

Dong

-----Original Message-----
From: Poythress, Lynn [mailto:apoythre@skymail.csus.edu]
Sent: Friday, November 21, 2008 6:56 AM
To: log4j-user@logging.apache.org
Subject: How to log ip addresses?

Hi,

We are running Unicon's uPortal product.  It utilizes log4j and we have
a log4j.properties file which creates a portal.log file.  In that
portal.log file it logs users that log on to the portal.  We would like
it to log the ip address of each user; currently it just shows user name
and userid.

Do we modify the log4j.properties file to have it add each user's ip
address to the log?

If so, can you point me in the right direction?  I read about appenders,
but couldn't see any parameters that would specifically capture ip
addresses.

Thanks,
Lynn Poythress


---------------------------------------------------------------------
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: How to log ip addresses?

Posted by Dong Zhang <dz...@seven.com>.
Hi Lynn,

I have no idea about uPortal, but for log4j, it has no application
specific configuration, e.g. username, ip address, etc.

The reason you see username, is uPortal application logged it. So if you
want ip address, you need to look into uPortal doc/configuration files,
instead of log4j configuration.

Dong

-----Original Message-----
From: Poythress, Lynn [mailto:apoythre@skymail.csus.edu] 
Sent: Friday, November 21, 2008 6:56 AM
To: log4j-user@logging.apache.org
Subject: How to log ip addresses?

Hi,

We are running Unicon's uPortal product.  It utilizes log4j and we have
a log4j.properties file which creates a portal.log file.  In that
portal.log file it logs users that log on to the portal.  We would like
it to log the ip address of each user; currently it just shows user name
and userid.

Do we modify the log4j.properties file to have it add each user's ip
address to the log?

If so, can you point me in the right direction?  I read about appenders,
but couldn't see any parameters that would specifically capture ip
addresses.

Thanks,
Lynn Poythress


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