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.