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 peter at merikan dot com <"peter at merikan dot co...@got.sema.se> on 2003/01/09 09:42:15 UTC

log4j.xml and variable substitution

is it possible to use variable substitution in the xml configuration file?

if so,how?

Regards
Peter


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: log4j.xml and variable substitution

Posted by Jenny <xw...@yahoo.com>.
My requirement is to track the user activity of our
website. User can come from different site to our
site. so each external site will have their own
directory, an i log the information to particular
directory. 
Also we sell the product from differrent vendor, and i
need to log the buyer activity for each prodcut they
buy, I set up the product information including the
directory where the logging needs to go. 
So i need to decide the the variable in the program. 
Thanks for your help.


--- Thomas Muller <tt...@online.no> wrote:
> Could you elaborate your requirement a bit? Don't
> think standard variable
> interpolation is the right way to do what you want.
> 
> --
> 
> Thomas
> 
> 
> 
> | -----Original Message-----
> | From: Jenny [mailto:xwhu_1999@yahoo.com]
> | Sent: 16 January 2003 18:29
> | To: Log4J Users List; ttm@online.no
> | Subject: RE: log4j.xml and variable substitution
> |
> |
> | Hi,
> | Thanks. It's not a fixed variable for particular
> | server. It needs to be dynamically set in the
> program.
> | Maybe it's the wrong way to use it. But what I
> need is
> | for every logging line I need to check the varible
> to
> | decide which directory to go.
> |
> | Thanks.
> |
> | --- Thomas Muller <tt...@online.no> wrote:
> | > You need to set the relevant System variable
> prior
> | > to log4j configuration,
> | > e.g. with the -D option to the VM.
> | >
> | > --
> | >
> | > Thomas
> | >
> | >
> | >
> | >
> | > | -----Original Message-----
> | > | From: Jenny [mailto:xwhu_1999@yahoo.com]
> | > | Sent: 16 January 2003 17:54
> | > | To: Log4J Users List
> | > | Subject: Re: log4j.xml and variable
> substitution
> | > |
> | > |
> | > | Hi,
> | > | I remember sometime back there was a post
> states
> | > that
> | > | we can do it like:
> | > |
> | > | <param name="DatePattern"
> | > | value="'c:/log/${var}/'yyMMdd'.log'" />
> | > |
> | > | The var can be from system variable.
> | > |
> | > | But I have a question here. I configure log4j
> with
> | > the
> | > | server, so the configure file are read on the
> | > startup.
> | > | but at that time, the variable is not
> available
> | > yet,
> | > | so the value becomes "c:/log//020116.log".
> | > whenever I
> | > | restart the server, there will be an empty
> file
> | > | created under c:/log, but the actual log file
> | > should
> | > | be in the individual subdirectory of c:/log
> for
> | > | differrent $var.
> | > | How can i avoid to create the unuseful files?
> | > |
> | > | Thanks
> | > |
> | > | --- peter at merikan dot com <"peter at
> merikan
> | > dot
> | > | com"@got.sema.se> wrote:
> | > | > is it possible to use variable substitution
> in
> | > the
> | > | > xml configuration file?
> | > | >
> | > | > if so,how?
> | > | >
> | > | > Regards
> | > | > Peter
> | > | >
> | > | >
> | > | > --
> | > | > To unsubscribe, e-mail:
> | > | >
> | >
> <ma...@jakarta.apache.org>
> | > | > For additional commands, e-mail:
> | > | > <ma...@jakarta.apache.org>
> | > | >
> | > |
> | > |
> | > |
> __________________________________________________
> | > | Do you Yahoo!?
> | > | Yahoo! Mail Plus - Powerful. Affordable. Sign
> up
> | > now.
> | > | http://mailplus.yahoo.com
> | > |
> | > | --
> | > | To unsubscribe, e-mail:
> | > |
> <ma...@jakarta.apache.org>
> | > | For additional commands, e-mail:
> | > | <ma...@jakarta.apache.org>
> | > |
> | > |
> | >
> | >
> | >
> | >
> |
>
*************************************************************************
> | > Copyright ERA Technology Ltd. 2002.
> (www.era.co.uk).
> | > All rights reserved.
> | > The information supplied in this Commercial
> | > Communication should be treated
> | > in confidence.
> | > No liability whatsoever is accepted for any loss
> or
> | > damage
> | > suffered as a result of accessing this message
> or
> | > any attachments.
> | >
> | >
> |
>
________________________________________________________________________
> | > This email has been scanned for all viruses by
> the
> | > MessageLabs SkyScan
> | > service. For more information on a proactive
> | > anti-virus service working
> | > around the clock, around the globe, visit
> | > http://www.messagelabs.com
> | >
> |
>
________________________________________________________________________
> | >
> | > --
> | > To unsubscribe, e-mail:
> | >
> <ma...@jakarta.apache.org>
> | > For additional commands, e-mail:
> | > <ma...@jakarta.apache.org>
> | >
> |
> |
> | __________________________________________________
> | Do you Yahoo!?
> | Yahoo! Mail Plus - Powerful. Affordable. Sign up
> now.
> | http://mailplus.yahoo.com
> |
> |
> 
> 
> 
>
*************************************************************************
> Copyright ERA Technology Ltd. 2002. (www.era.co.uk).
> All rights reserved. 
> The information supplied in this Commercial
> Communication should be treated
> in confidence.
> No liability whatsoever is accepted for any loss or
> damage 
> suffered as a result of accessing this message or
> any attachments.
> 
>
________________________________________________________________________
> This email has been scanned for all viruses by the
> MessageLabs SkyScan
> service. For more information on a proactive
> anti-virus service working
> around the clock, around the globe, visit
> http://www.messagelabs.com
>
________________________________________________________________________
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
=== message truncated ===


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: log4j.xml and variable substitution

Posted by Thomas Muller <tt...@online.no>.
Could you elaborate your requirement a bit? Don't think standard variable
interpolation is the right way to do what you want.

--

Thomas



| -----Original Message-----
| From: Jenny [mailto:xwhu_1999@yahoo.com]
| Sent: 16 January 2003 18:29
| To: Log4J Users List; ttm@online.no
| Subject: RE: log4j.xml and variable substitution
|
|
| Hi,
| Thanks. It's not a fixed variable for particular
| server. It needs to be dynamically set in the program.
| Maybe it's the wrong way to use it. But what I need is
| for every logging line I need to check the varible to
| decide which directory to go.
|
| Thanks.
|
| --- Thomas Muller <tt...@online.no> wrote:
| > You need to set the relevant System variable prior
| > to log4j configuration,
| > e.g. with the -D option to the VM.
| >
| > --
| >
| > Thomas
| >
| >
| >
| >
| > | -----Original Message-----
| > | From: Jenny [mailto:xwhu_1999@yahoo.com]
| > | Sent: 16 January 2003 17:54
| > | To: Log4J Users List
| > | Subject: Re: log4j.xml and variable substitution
| > |
| > |
| > | Hi,
| > | I remember sometime back there was a post states
| > that
| > | we can do it like:
| > |
| > | <param name="DatePattern"
| > | value="'c:/log/${var}/'yyMMdd'.log'" />
| > |
| > | The var can be from system variable.
| > |
| > | But I have a question here. I configure log4j with
| > the
| > | server, so the configure file are read on the
| > startup.
| > | but at that time, the variable is not available
| > yet,
| > | so the value becomes "c:/log//020116.log".
| > whenever I
| > | restart the server, there will be an empty file
| > | created under c:/log, but the actual log file
| > should
| > | be in the individual subdirectory of c:/log for
| > | differrent $var.
| > | How can i avoid to create the unuseful files?
| > |
| > | Thanks
| > |
| > | --- peter at merikan dot com <"peter at merikan
| > dot
| > | com"@got.sema.se> wrote:
| > | > is it possible to use variable substitution in
| > the
| > | > xml configuration file?
| > | >
| > | > if so,how?
| > | >
| > | > Regards
| > | > Peter
| > | >
| > | >
| > | > --
| > | > To unsubscribe, e-mail:
| > | >
| > <ma...@jakarta.apache.org>
| > | > For additional commands, e-mail:
| > | > <ma...@jakarta.apache.org>
| > | >
| > |
| > |
| > | __________________________________________________
| > | Do you Yahoo!?
| > | Yahoo! Mail Plus - Powerful. Affordable. Sign up
| > now.
| > | http://mailplus.yahoo.com
| > |
| > | --
| > | To unsubscribe, e-mail:
| > | <ma...@jakarta.apache.org>
| > | For additional commands, e-mail:
| > | <ma...@jakarta.apache.org>
| > |
| > |
| >
| >
| >
| >
| *************************************************************************
| > Copyright ERA Technology Ltd. 2002. (www.era.co.uk).
| > All rights reserved.
| > The information supplied in this Commercial
| > Communication should be treated
| > in confidence.
| > No liability whatsoever is accepted for any loss or
| > damage
| > suffered as a result of accessing this message or
| > any attachments.
| >
| >
| ________________________________________________________________________
| > This email has been scanned for all viruses by the
| > MessageLabs SkyScan
| > service. For more information on a proactive
| > anti-virus service working
| > around the clock, around the globe, visit
| > http://www.messagelabs.com
| >
| ________________________________________________________________________
| >
| > --
| > To unsubscribe, e-mail:
| > <ma...@jakarta.apache.org>
| > For additional commands, e-mail:
| > <ma...@jakarta.apache.org>
| >
|
|
| __________________________________________________
| Do you Yahoo!?
| Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
| http://mailplus.yahoo.com
|
|



*************************************************************************
Copyright ERA Technology Ltd. 2002. (www.era.co.uk). All rights reserved. 
The information supplied in this Commercial Communication should be treated
in confidence.
No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: log4j.xml and variable substitution

Posted by Jenny <xw...@yahoo.com>.
Hi,
Thanks. It's not a fixed variable for particular
server. It needs to be dynamically set in the program.
Maybe it's the wrong way to use it. But what I need is
for every logging line I need to check the varible to
decide which directory to go.

Thanks.

--- Thomas Muller <tt...@online.no> wrote:
> You need to set the relevant System variable prior
> to log4j configuration,
> e.g. with the -D option to the VM.
> 
> --
> 
> Thomas
> 
> 
> 
> 
> | -----Original Message-----
> | From: Jenny [mailto:xwhu_1999@yahoo.com]
> | Sent: 16 January 2003 17:54
> | To: Log4J Users List
> | Subject: Re: log4j.xml and variable substitution
> |
> |
> | Hi,
> | I remember sometime back there was a post states
> that
> | we can do it like:
> |
> | <param name="DatePattern"
> | value="'c:/log/${var}/'yyMMdd'.log'" />
> |
> | The var can be from system variable.
> |
> | But I have a question here. I configure log4j with
> the
> | server, so the configure file are read on the
> startup.
> | but at that time, the variable is not available
> yet,
> | so the value becomes "c:/log//020116.log".
> whenever I
> | restart the server, there will be an empty file
> | created under c:/log, but the actual log file
> should
> | be in the individual subdirectory of c:/log for
> | differrent $var.
> | How can i avoid to create the unuseful files?
> |
> | Thanks
> |
> | --- peter at merikan dot com <"peter at merikan
> dot
> | com"@got.sema.se> wrote:
> | > is it possible to use variable substitution in
> the
> | > xml configuration file?
> | >
> | > if so,how?
> | >
> | > Regards
> | > Peter
> | >
> | >
> | > --
> | > To unsubscribe, e-mail:
> | >
> <ma...@jakarta.apache.org>
> | > For additional commands, e-mail:
> | > <ma...@jakarta.apache.org>
> | >
> |
> |
> | __________________________________________________
> | Do you Yahoo!?
> | Yahoo! Mail Plus - Powerful. Affordable. Sign up
> now.
> | http://mailplus.yahoo.com
> |
> | --
> | To unsubscribe, e-mail:
> | <ma...@jakarta.apache.org>
> | For additional commands, e-mail:
> | <ma...@jakarta.apache.org>
> |
> |
> 
> 
> 
>
*************************************************************************
> Copyright ERA Technology Ltd. 2002. (www.era.co.uk).
> All rights reserved. 
> The information supplied in this Commercial
> Communication should be treated
> in confidence.
> No liability whatsoever is accepted for any loss or
> damage 
> suffered as a result of accessing this message or
> any attachments.
> 
>
________________________________________________________________________
> This email has been scanned for all viruses by the
> MessageLabs SkyScan
> service. For more information on a proactive
> anti-virus service working
> around the clock, around the globe, visit
> http://www.messagelabs.com
>
________________________________________________________________________
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: log4j.xml and variable substitution

Posted by Thomas Muller <tt...@online.no>.
You need to set the relevant System variable prior to log4j configuration,
e.g. with the -D option to the VM.

--

Thomas




| -----Original Message-----
| From: Jenny [mailto:xwhu_1999@yahoo.com]
| Sent: 16 January 2003 17:54
| To: Log4J Users List
| Subject: Re: log4j.xml and variable substitution
|
|
| Hi,
| I remember sometime back there was a post states that
| we can do it like:
|
| <param name="DatePattern"
| value="'c:/log/${var}/'yyMMdd'.log'" />
|
| The var can be from system variable.
|
| But I have a question here. I configure log4j with the
| server, so the configure file are read on the startup.
| but at that time, the variable is not available yet,
| so the value becomes "c:/log//020116.log". whenever I
| restart the server, there will be an empty file
| created under c:/log, but the actual log file should
| be in the individual subdirectory of c:/log for
| differrent $var.
| How can i avoid to create the unuseful files?
|
| Thanks
|
| --- peter at merikan dot com <"peter at merikan dot
| com"@got.sema.se> wrote:
| > is it possible to use variable substitution in the
| > xml configuration file?
| >
| > if so,how?
| >
| > Regards
| > Peter
| >
| >
| > --
| > To unsubscribe, e-mail:
| > <ma...@jakarta.apache.org>
| > For additional commands, e-mail:
| > <ma...@jakarta.apache.org>
| >
|
|
| __________________________________________________
| Do you Yahoo!?
| Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
| http://mailplus.yahoo.com
|
| --
| To unsubscribe, e-mail:
| <ma...@jakarta.apache.org>
| For additional commands, e-mail:
| <ma...@jakarta.apache.org>
|
|



*************************************************************************
Copyright ERA Technology Ltd. 2002. (www.era.co.uk). All rights reserved. 
The information supplied in this Commercial Communication should be treated
in confidence.
No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: log4j.xml and variable substitution

Posted by Jenny <xw...@yahoo.com>.
Hi,
I remember sometime back there was a post states that
we can do it like:

<param name="DatePattern"
value="'c:/log/${var}/'yyMMdd'.log'" />

The var can be from system variable.

But I have a question here. I configure log4j with the
server, so the configure file are read on the startup.
but at that time, the variable is not available yet,
so the value becomes "c:/log//020116.log". whenever I
restart the server, there will be an empty file
created under c:/log, but the actual log file should
be in the individual subdirectory of c:/log for
differrent $var.
How can i avoid to create the unuseful files?

Thanks

--- peter at merikan dot com <"peter at merikan dot
com"@got.sema.se> wrote:
> is it possible to use variable substitution in the
> xml configuration file?
> 
> if so,how?
> 
> Regards
> Peter
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>