Hi Brian,
I'm not even going to ask why you want to do that. ;-}
I don't know if your proposal will work, and I don't know for sure that this
will
work either (but it seems like it *should*). If you specify a file appender in
your config file, before your loop get that Appender from the root logger. then
inside the loop you could change the name of the file that you log to with that
Appender. Then you could log as much or as little as you want to each file. You
might even store the original file name before looping, and restore it
afterwards.
Dave
"McCarty, Brian"
<[EMAIL PROTECTED] To:
<[EMAIL PROTECTED]>
saa.com> cc:
Subject: A "FileAppender" that
creates new file for each write...
11/17/2004 05:49
PM
Please respond
to "Log4J Users
List"
I need the ability to create a new file that contains a single logging
entry. I was going to write a utility to open a new file with a name
something like "prefix + counter +.txt" each time, but because I like
log4j and it would give me the flexibility of not having to use a file
(but JMS or Socket for example) was seeing if there was an appender
already available that could help me.
Basically I am going to be in a iterating over a collection in a loop
where each entry needs to go to a new file:
for(Iterator iter = messages.iterator(); iter.hasNext(); ) {
String s = (String) iter.next();
...ex. log.info(s);
}
Can I tell the appender in my log4j.properties file to use variables
names like: log4j.appender.LOG.file=logFile_${id}.txt. Where the ${id}
could be passed by the logging statement?
This is a main() application that doesn't use threads so I shouldn't
have to worry about 2 threads trying to write to the same file name at
the same time.
Thanks in advance for any suggestions.
This message contains information from Equifax Inc. which may be confidential
and
privileged. If you are not an intended recipient, please refrain from any
disclosure, copying, distribution or use of this information and note that such
actions are prohibited. If you have received this transmission in error, please
notify by e-mail [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]