# logging-log4j-user mailing list archives

##### Site index · List index
Message view
Top
From Jacob Kjome <h...@visi.com>
Subject RE: Configuring Log4j for testing vs. development vs. deployment
Date Mon, 29 Dec 2003 16:39:26 GMT
You are purely speculating here.  I have just stated below that, in fact,
log4j.xml *does* support referencing system variables.  You can disbelieve me
and not use them yourself or you can test as to whether what I am saying is
actually true or not, but please don't post stuff like this and spread
misinformation when you aren't sure of the facts.  I currently use the
following in a FileAppender and it sure works for me...

<param name="File" value="\${myapp.log.home}/main.log" />

I set up a system variable named "myapp.log.home" in a servlet context listener
at application startup with the path to the log file.  The file fills up with
logging statements as expected.

Also I may be mistaken here since I don't use properties files much with log4j,
but I'm pretty sure properties files *do* support creation of local variables
in the properties file to reference later in the same file in addition to
reading system variables.  You'll have to get verification of this since I'm
not positive, but I'm pretty sure it is true.

Jake

Quoting haggaic2v7-loguser@yahoo.com:

> Actually, I don't believe that log4j.xml supports either creation or
> reference of variables.  log4j.properties, on other hand, supports
> reference of variables, but not creation of them.
>
> --Ian
>
> --- Jacob Kjome <hoju@visi.com> wrote:
> > At 06:45 AM 12/24/2003 -0800, you wrote:
> > >The only downside is that (at least as of 1.2.8) variable
> > interpolation
> > >is only available in the PropertyConfigurator, not in the
> > >DOMConfigurator.  But if your config files are relatively simple,
> > then
> > >variable interpolation is definitely the way to go.
> > >
> > >--Ian
> >
> > Just to clarify (maybe I'm misunderstanding what you just said).
> > Although
> > you can't create variables in log4j.xml to reference later in
> > log4j.xml,
> > you can reference system properties like \${my.system.variable} in
> > log4j.xml.
> >
> > Jake
> >
> >
> > >--- Steve Ebersole <steveebersole@austin.rr.com> wrote:
> > > > Another great option is the variable interpolation available in
> > > > log4j, which
> > > > allows you to do something like:
> > > >
> > > > log4j.appender.daily.File=\${log.dir}/coldev.log
> > > >
> > > > where the variable "log.dir" (or whatever you want to name it) is
> > a
> > > > java
> > > > system property.
> > > >
> > > >
> > > >
> > > > -----Original Message-----
> > > > From: Wendy Smoak [mailto:Wendy.Smoak@asu.edu]
> > > > Sent: Tuesday, December 23, 2003 1:02 PM
> > > > To: log4j-user@logging.apache.org
> > > > Subject: Configuring Log4j for testing vs. development vs.
> > deployment
> > > >
> > > >
> > > >
> > > > I figured out that this problem:
> > > > [junit] log4j:ERROR setFile(null,true) call failed.
> > > > [junit] java.io.FileNotFoundException:
> > > > \opt\hpws\tomcat\logs\coldev.log
> > > > (The system cannot find the path specified)
> > > >
> > > > Is caused by log4j.properties saying:
> > > > # Configure the name of the logout for the daily appender
> > > > log4j.appender.daily.File=/opt/hpws/tomcat/logs/coldev.log
> > > >
> > > > That path belongs on the HPUX web server.  In an attempt to avoid
> > > > changing log4j.properties for deployment, I created a
> > > > c:\opt\hpws\tomcat\logs directory on my Windows development
> > machine.
> > > > But now that .properties file doesn't work for me when I run
> > junit
> > > > tests
> > > > from the mapped network drive "G" where the source code lives.
> > > >
> > > > So... Do you have a separate log4j.properties for running tests?
> > How
> > > > do
> > > > you handle configuring log4j for tests?  (In the most automated
> > way
> > > > possible!)
> > > >
> > > > Thank you,
> > > > --
> > > > Wendy Smoak
> > > > Application Systems Analyst, Sr.
> > > > ASU IA Information Resources Management
> > > >
> > > >
> > > >
> > > >
> > ---------------------------------------------------------------------
> > > > 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
> > > >
> > >
> > >
> >
> >---------------------------------------------------------------------
> > >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
> >
>
>
> ---------------------------------------------------------------------
> 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