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 Jacob Kjome <ho...@visi.com> on 2005/03/25 16:14:18 UTC

RE: Where to set exernal property referred to in log4j.properties

At 09:33 AM 3/25/2005 -0500, you wrote:
 >Thanks for the reply, James.  I agree with you that it wouldn't be
 >non-standard but since I don't maintain our tomcat implementation I was
 >looking to see if there might be another way.

Have you looked into using CATALINA_OPTS?  Just set said variable as an OS 
system property and provide any command line arguments you want.  Tomcat's 
scripts will pick this up and add it to the Tomcat startup script.  This 
means you can add custom command line args without having to change the 
Tomcat distribution at all.

You can also use a ServletContextListener to set up a system property, 
which you refer to the log4j config file, before manual configuration is 
performed.  Note that autoconfiguration probably would not work in this 
case since the system property will have been set *after* autoconfiguration 
has taken place.

 >
 >Maybe making the logs relative to catalina.home is the right idea.  I
 >suppose that my only concern though is that I'm using my primary log file by
 >both my web application and another external java application code.  I
 >mentioned this a couple days ago and someone suggested that sharing one log
 >file between two applications is a bad idea and that the logs would become
 >garbled.  Is that really so?  I thought that it was OK to share a log
 >between different JVMs since the log includes thread identifiers.
 >

As I understand it, the only time you need to worry about File contention 
is between two separate JVM's.  However, you will need to make sure that in 
one config file you don't set the FileAppender to append=true and 
append=false in another.  So, you might want to point at different files 
per application even if there is no thread level file contention.  You can 
still log you files relative to catalina.home (or catalina.base), since 
that is a JVM system variable that Tomcat provides for you automatically at 
startup.

Jake

 >I'm probably going to move the applications that are outside the web
 >application to a model whereby they are executed from URLs anyway so in the
 >future I suppose that risk will be mitigated.
 >
 >
 >-----Original Message-----
 >From: James Stauffer [mailto:stauffer.james@gmail.com]
 >Sent: Friday, March 25, 2005 8:38 AM
 >To: Log4J Users List; wnoto@openfinance.com
 >Subject: Re: Where to set exernal property referred to in log4j.properties
 >
 >On Fri, 25 Mar 2005 00:37:46 -0500, William Noto <wn...@openfinance.com>
 >wrote:
 >> My operations team is concerned about setting the property externally at
 >the
 >> user level when we start Tomcat because they do not want to run a
 >> non-standard implementation.
 >That is equivalent to setting an environement variable and wouldn't
 >make it a "non-standard implementation."
 >
 >>  I have tried a number of things that I thought
 >> might work including setting the property through the web.xml's
 >> context-param tag and setting it in the <context> at the server.xml level
 >> but always without success.
 >Can you just use a relative path or chose a path relative to
 >${catalina.home} ?
 >
 >--
 >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
 >
 >
 >
 >---------------------------------------------------------------------
 >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: Where to set exernal property referred to in log4j.properties

Posted by Scott Heaberlin <he...@gmail.com>.
Alternatively you could use a SocketAppender in one VM and
SocketReceiver (log4j  1.3) or a SocketNode (1.2.x) in the other to
receive logging events sent to the socket and log them as if they were
generated in the same VM.  These were added to log4j specifically for
this purpose, if I recall correctly.

-Scott Heaberlin

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


RE: Where to set exernal property referred to in log4j.properties

Posted by William Noto <wn...@openfinance.com>.
Thanks for the insights on why to avoid writing to the same file from
multiple JVMs, Andy - and for the properties suggestions Jake.  

-----Original Message-----
From: Andy McBride [mailto:andy.mcbride@dsl.pipex.com] 
Sent: Friday, March 25, 2005 11:00 AM
To: 'Log4J Users List'
Subject: RE: Where to set exernal property referred to in log4j.properties

Hi, 

>  >Maybe making the logs relative to catalina.home is the right idea.  I
>  >suppose that my only concern though is that I'm using my primary log
> file by
>  >both my web application and another external java application code.  I
>  >mentioned this a couple days ago and someone suggested that sharing one
> log
>  >file between two applications is a bad idea and that the logs would
> become
>  >garbled.  Is that really so?  I thought that it was OK to share a log
>  >between different JVMs since the log includes thread identifiers.
>  >
>
> As I understand it, the only time you need to worry about File contention
> is between two separate JVM's.  However, you will need to make sure that
> in
> one config file you don't set the FileAppender to append=true and
> append=false in another.  So, you might want to point at different files
> per application even if there is no thread level file contention.  You can
> still log you files relative to catalina.home (or catalina.base), since
> that is a JVM system variable that Tomcat provides for you automatically
> at
> startup.
> 

The fact that your config writes your thread names to the log files is
irrelevant.  If you have a two JVMs writing to the same file there is no
synchronisation between the two on file IO operations.  

If both apps try to write to the file at the same time, the best that will
happen is that one of the log records will not get written.  More likely
both logs records will get mangled together losing both log messages.  

Regards

Andy



---------------------------------------------------------------------
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: Where to set exernal property referred to in log4j.properties

Posted by Andy McBride <an...@dsl.pipex.com>.
Hi, 

>  >Maybe making the logs relative to catalina.home is the right idea.  I
>  >suppose that my only concern though is that I'm using my primary log
> file by
>  >both my web application and another external java application code.  I
>  >mentioned this a couple days ago and someone suggested that sharing one
> log
>  >file between two applications is a bad idea and that the logs would
> become
>  >garbled.  Is that really so?  I thought that it was OK to share a log
>  >between different JVMs since the log includes thread identifiers.
>  >
>
> As I understand it, the only time you need to worry about File contention
> is between two separate JVM's.  However, you will need to make sure that
> in
> one config file you don't set the FileAppender to append=true and
> append=false in another.  So, you might want to point at different files
> per application even if there is no thread level file contention.  You can
> still log you files relative to catalina.home (or catalina.base), since
> that is a JVM system variable that Tomcat provides for you automatically
> at
> startup.
> 

The fact that your config writes your thread names to the log files is
irrelevant.  If you have a two JVMs writing to the same file there is no
synchronisation between the two on file IO operations.  

If both apps try to write to the file at the same time, the best that will
happen is that one of the log records will not get written.  More likely
both logs records will get mangled together losing both log messages.  

Regards

Andy



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