You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@logging.apache.org by "Kalcevich, Daniel" <dk...@firstam.com> on 2005/11/28 19:49:04 UTC

Two Loggers - overwriting files

Everyone,

 

I have an application that runs from a Web Interface as well as from a
command line state.  The problem I am having is that when the batch job
runs, that it truncates any data that is in the log file that the web
has been writing to.  I want the output from both places to be kept in a
single log file.  My log4j configuration looks like the following:

 

log4j.logger.batch.notifyAgents=INFO, notifyAgents

log4j.additivity.batch.notifyAgents=false

 

log4j.appender.notifyAgents=org.apache.log4j.DailyRollingFileAppender

log4j.appender.notifyAgents.File/logs/notifyAgents.log

log4j.appender.notifyAgents.Threshold=INFO

log4j.appender.notifyAgents.DatePattern='.'yyyy-MM-dd

log4j.appender.notifyAgents.append=true

log4j.appender.notifyAgents.layout=org.apache.log4j.PatternLayout

log4j.appender.notifyAgents.layout.ConversionPattern=%d [%t] %-5p %c ::
%m%n

 

And in the java code, I call the following to load the file from a
packaged jar file:

 

Properties props = new Properties();

URL log4jURL =
Thread.currentThread().getContextClassLoader().getResource(log4JFile ); 

props.load( log4jURL.openStream() );

PropertyConfigurator.configure(props);

 

Are there any properties that can be set to allow the batch job to run
and write to the file (if it already exists), rather than truncate whats
there and then write the data?  Any help is greatly appreciated.
Thanks.

 

Daniel

 


Re: Two Loggers - overwriting files

Posted by Andreas Fester <af...@apache.org>.
Kalcevich, Daniel wrote:
> Everyone,
> 
>  
> 
> I have an application that runs from a Web Interface as well as from a
> command line state.  The problem I am having is that when the batch job

Do the two applications run at the same time (i.e. does the batch job
run while the web application is also running), or do they run mutually
exclusive?
For the former, AFAIK it is not possible, because log4j does not
synchronize write access to the same file from within different VMs.

Regards,

	Andreas


Re: Two Loggers - overwriting files

Posted by Andreas Fester <af...@apache.org>.
Kalcevich, Daniel wrote:
> Everyone,
> 
>  
> 
> I have an application that runs from a Web Interface as well as from a
> command line state.  The problem I am having is that when the batch job

Do the two applications run at the same time (i.e. does the batch job
run while the web application is also running), or do they run mutually
exclusive?
For the former, AFAIK it is not possible, because log4j does not
synchronize write access to the same file from within different VMs.

Regards,

	Andreas


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