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 wolverine my <wo...@gmail.com> on 2006/08/10 03:33:16 UTC
Different client's log file?
Hi!
One or more clients connecting to the server. How can we log the
message into different client's log files?
E.g. when there are client X, Y, Z connecting to the server. The
messages will be logged into X.log, Y.log and Z.log.
This will be easier for us to debug when one client encounter problem.
Thanks for your help!
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
RE: Different client's log file?
Posted by "Levy, Jeremy" <Je...@morganstanley.com>.
James,
That was perfect, I have extended it to log to separate directories based on a MDC value as well as name the file based on the MDC value and append today's date.
I have posted the version I am now using at:
http://jeremylevy.com/MDCFileAppender.java
Jeremy
-----Original Message-----
From: James Stauffer [mailto:stauffer.james@gmail.com]
Sent: Friday, August 11, 2006 11:21 AM
To: Log4J Users List
Subject: Re: Different client's log file?
Yes. I made an Appender that changes the filename based on the time.
You could change it based on anything in the LoggingEvent.
http://stauffer.james.googlepages.com/DateFormatFileAppender.java
On 8/11/06, Levy, Jeremy <Je...@morganstanley.com> wrote:
> In my application, we have the consumer pass in the name of the application that is using our service.
>
> So we generally only have about 4,5 consumers. This is small enough that we can manually add them to the properties file. However, as our utility grows I don't want to have to maintain or add appenders to the properties file.
>
> Is it possible to dynamically change the file name of a log file based on a value?
>
> So if someone calls a web service, if I call getLogger or maybe MDC/NDC is there a way to change the name of the log file based a value passed in at runtime?
>
> Jeremy
>
> -----Original Message-----
> From: Javier Gonzalez [mailto:jagonzal@gmail.com]
> Sent: Thursday, August 10, 2006 1:23 AM
> To: Log4J Users List
> Subject: Re: Different client's log file?
>
> On 8/10/06, wolverine my <wo...@gmail.com> wrote:
> > Hi!
> >
> > I'm actually developing a web application using servlet and so I can
> > use the client's IP address instead of the client.getName()...
>
> Ah, a web application... no way to know beforehand every single client's id.
>
> mmm, I don't think you can have a log file per client, but maybe you can still include the ip address in the logger name. That way, you can grep over the logs with the ip address of a given client to study just that client's activity.
>
> --
> Javier González Nicolini
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
>
> --------------------------------------------------------
>
> Important Notice to Recipients:
> It is important that you do not use e-mail to request, authorize or effect the purchase or sale of any security or commodity, to send fund transfer instructions, or to effect any other transactions. Any such request, orders, or instructions that you send will not be accepted and will not be processed by Morgan Stanley.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
--
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
--------------------------------------------------------
Important Notice to Recipients:
It is important that you do not use e-mail to request, authorize or effect the purchase or sale of any security or commodity, to send fund transfer instructions, or to effect any other transactions. Any such request, orders, or instructions that you send will not be accepted and will not be processed by Morgan Stanley.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Different client's log file?
Posted by James Stauffer <st...@gmail.com>.
Yes. I made an Appender that changes the filename based on the time.
You could change it based on anything in the LoggingEvent.
http://stauffer.james.googlepages.com/DateFormatFileAppender.java
On 8/11/06, Levy, Jeremy <Je...@morganstanley.com> wrote:
> In my application, we have the consumer pass in the name of the application that is using our service.
>
> So we generally only have about 4,5 consumers. This is small enough that we can manually add them to the properties file. However, as our utility grows I don't want to have to maintain or add appenders to the properties file.
>
> Is it possible to dynamically change the file name of a log file based on a value?
>
> So if someone calls a web service, if I call getLogger or maybe MDC/NDC is there a way to change the name of the log file based a value passed in at runtime?
>
> Jeremy
>
> -----Original Message-----
> From: Javier Gonzalez [mailto:jagonzal@gmail.com]
> Sent: Thursday, August 10, 2006 1:23 AM
> To: Log4J Users List
> Subject: Re: Different client's log file?
>
> On 8/10/06, wolverine my <wo...@gmail.com> wrote:
> > Hi!
> >
> > I'm actually developing a web application using servlet and so I can
> > use the client's IP address instead of the client.getName()...
>
> Ah, a web application... no way to know beforehand every single client's id.
>
> mmm, I don't think you can have a log file per client, but maybe you can still include the ip address in the logger name. That way, you can grep over the logs with the ip address of a given client to study just that client's activity.
>
> --
> Javier González Nicolini
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
>
> --------------------------------------------------------
>
> Important Notice to Recipients:
> It is important that you do not use e-mail to request, authorize or effect the purchase or sale of any security or commodity, to send fund transfer instructions, or to effect any other transactions. Any such request, orders, or instructions that you send will not be accepted and will not be processed by Morgan Stanley.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
--
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
RE: Different client's log file?
Posted by "Levy, Jeremy" <Je...@morganstanley.com>.
In my application, we have the consumer pass in the name of the application that is using our service.
So we generally only have about 4,5 consumers. This is small enough that we can manually add them to the properties file. However, as our utility grows I don't want to have to maintain or add appenders to the properties file.
Is it possible to dynamically change the file name of a log file based on a value?
So if someone calls a web service, if I call getLogger or maybe MDC/NDC is there a way to change the name of the log file based a value passed in at runtime?
Jeremy
-----Original Message-----
From: Javier Gonzalez [mailto:jagonzal@gmail.com]
Sent: Thursday, August 10, 2006 1:23 AM
To: Log4J Users List
Subject: Re: Different client's log file?
On 8/10/06, wolverine my <wo...@gmail.com> wrote:
> Hi!
>
> I'm actually developing a web application using servlet and so I can
> use the client's IP address instead of the client.getName()...
Ah, a web application... no way to know beforehand every single client's id.
mmm, I don't think you can have a log file per client, but maybe you can still include the ip address in the logger name. That way, you can grep over the logs with the ip address of a given client to study just that client's activity.
--
Javier González Nicolini
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
--------------------------------------------------------
Important Notice to Recipients:
It is important that you do not use e-mail to request, authorize or effect the purchase or sale of any security or commodity, to send fund transfer instructions, or to effect any other transactions. Any such request, orders, or instructions that you send will not be accepted and will not be processed by Morgan Stanley.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Different client's log file?
Posted by Javier Gonzalez <ja...@gmail.com>.
On 8/10/06, wolverine my <wo...@gmail.com> wrote:
> Hi!
>
> I'm actually developing a web application using servlet and so I can
> use the client's IP address instead of the client.getName()...
Ah, a web application... no way to know beforehand every single client's id.
mmm, I don't think you can have a log file per client, but maybe you
can still include the ip address in the logger name. That way, you can
grep over the logs with the ip address of a given client to study just
that client's activity.
--
Javier González Nicolini
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Different client's log file?
Posted by wolverine my <wo...@gmail.com>.
Hi!
I'm actually developing a web application using servlet and so I can
use the client's IP address instead of the client.getName()...
On 8/10/06, Javier Gonzalez <ja...@gmail.com> wrote:
> On 8/9/06, wolverine my <wo...@gmail.com> wrote:
> > One or more clients connecting to the server. How can we log the
> > message into different client's log files?
> >
> > E.g. when there are client X, Y, Z connecting to the server. The
> > messages will be logged into X.log, Y.log and Z.log.
> >
> > This will be easier for us to debug when one client encounter problem.
>
> If the clients' names (every possible one) are known beforehand, you
> can create an appender for each client, and log to a logger named
> after the client - create your loggers as
> "Logger.getLogger(client.getName())" and attach an appender to each
> possible name.
>
> --
> Javier González Nicolini
>
> ---------------------------------------------------------------------
> 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: Different client's log file?
Posted by ysuneelreddy <sr...@smarteinc.com>.
Hi for this purpose use MDC & NDC
See details more
Use key & values in MDC
-----Original Message-----
From: Javier Gonzalez [mailto:jagonzal@gmail.com]
Sent: Thursday, August 10, 2006 10:04 AM
To: Log4J Users List
Subject: Re: Different client's log file?
On 8/9/06, wolverine my <wo...@gmail.com> wrote:
> One or more clients connecting to the server. How can we log the
> message into different client's log files?
>
> E.g. when there are client X, Y, Z connecting to the server. The
> messages will be logged into X.log, Y.log and Z.log.
>
> This will be easier for us to debug when one client encounter problem.
If the clients' names (every possible one) are known beforehand, you
can create an appender for each client, and log to a logger named
after the client - create your loggers as
"Logger.getLogger(client.getName())" and attach an appender to each
possible name.
--
Javier González Nicolini
---------------------------------------------------------------------
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: Different client's log file?
Posted by Javier Gonzalez <ja...@gmail.com>.
On 8/9/06, wolverine my <wo...@gmail.com> wrote:
> One or more clients connecting to the server. How can we log the
> message into different client's log files?
>
> E.g. when there are client X, Y, Z connecting to the server. The
> messages will be logged into X.log, Y.log and Z.log.
>
> This will be easier for us to debug when one client encounter problem.
If the clients' names (every possible one) are known beforehand, you
can create an appender for each client, and log to a logger named
after the client - create your loggers as
"Logger.getLogger(client.getName())" and attach an appender to each
possible name.
--
Javier González Nicolini
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org