You could try using a custom repository selector that is keyed by thread. Log4j-1.3 has one keyed by JNDI. Others out there are keyed by ClassLoader, but that just leads to classloading issues. Look up in your favorite search engine or in the Log4j Wiki. The Log4j -sandbox used to have one that used JNDI and was compatible with Log4j 1.2, but since an equivalent one was added to Log4j 1.3 (albeit incompatible with Log4j 1.2), it was removed. It was tagged as something like 0.[1|2|3|4]alpha, so you might find it by looking at that tags in SVN if the conversion from CVS to SVN saved the tags.

Jake

At 11:16 AM 12/28/2006, you wrote:
>Hello. I think this question has been asked before, but not exactly with
>the same intentions.
>I have extended ConsoleAppender to log to a ScrollArea. This way:
>
>public class taAppender extends ConsoleAppender{
>        private JTextArea taLog=new JTextArea();
>        public JScrollPane ScrollTA= new JScrollPane(taLog,
>JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
>JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
>        private JScrollBar vbar = ScrollTA.getVerticalScrollBar();
>
>        public taAppender(){
>            System.out.println("constructor taAppender");
>        }
>
>        protected void subAppend(LoggingEvent event){
>            taLog.append(getLayout().format(event));
>            taLog.setCaretPosition( taLog.getDocument().getLength() );
>        }
>}
>
>The JScrollPane is public so it can referenced to add it to a JPane.
>Everything worked smoothly... until my boss decided "to multithread" the
>process.
>
>So now the app creates several threads on startup, and I want a
>taAppender per thread, every of them with it own ScrollTA, added to the
>main app JTabbedPane.
>
>The problem is that the taAppender is only instantiated once, and
>everytime I reference its scrollTA it is the one created the very first
>time.
>
>So my question is: How can I get a new instance of my appender, in a
>different logger per thread (to get as many loggers as threads) and be
>able to add these to main app panel?
>bear in mind that besides this thread independent taAppender, I will
>probably need a filelog per thread and a console shared log, too.
>
>I've been reading some clues about using ThreadLocal and/or
>LoggerFactory, but I have not been able to find any good example on the
>subject.
>
>Any advice will be greatly appreciated.
>Thanks in advance.
>
>
>--
>
>Un Saludo,
>Raúl Santiago Gómez
>Virtual Software S.L.
>[EMAIL PROTECTED]
>
>"El programador crea aplicaciones a prueba de tontos; Dios crea tontos
>a prueba de programadores"
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to