> On Aug 26, 2022, at 1:45 PM, Joel Griffith <jgrif...@nd.edu> wrote:
> 
> 
> Its purpose is to change the output file of the Root Logger's FileAppender
> (we assume it has only one), or to add a new FileAppender to the Root
> Logger if one does not already exist.  I can eliminate this use of
> FileAppender.setFile() by rewriting the entire function for Log4j v2.  How
> changing a FileAppender's output file done in v2?  I cannot find any hint
> online.  I read some about Lookups, which someone mentioned, but the only
> page I found was all configuration, no code.
> 

The only way to change the output destination would be to create a new 
Appender with the new target file and replace the current appender with it.
The file attribute of a FileAppender in Log4j 2 is immutable. In the 
RollingFileAppender 
you cannot change the name of the target file but the file being written to is 
moved and a new file with the same name is created when a rollover occurs.

In order to have  the ability to change the file at any time locking would be 
required and Log4j 2 minimizes locking wherever it can.

But rather than just copying code and trying to figure out how to emulate it 
with Log4j 2 it would be better to figure out what the requirement is that is 
driving the need to change the file name and then ask how that requirement 
can be met.

Ralph



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

Reply via email to