Hi all,
I'm switching my first java desktop application from log4j to logback, 
mainly because we neede a reliable DailyRollingFileAppender, and we were 
told the log4j implementation is not.
So far all ok, we simply changed the Logger declaration and all worked 
well.
The problem is our custom TextAreaAppender we are currently using to log 
the events to a text area in the application. The log4j implementation is 
very simple:

public class TextAreaAppender extends WriterAppender {

    static private JTextArea jTextArea = null;
    public static void setTextArea(JTextArea jTextArea) {
        TextAreaAppender.jTextArea = jTextArea;
    }

    /**
     * Format and then append the loggingEvent to the stored JTextArea.
     */
    public void append(LoggingEvent loggingEvent) {
        if (layout != null) {
            final String message = layout.format(loggingEvent);
            StringBuilder sb = new StringBuilder();
            if (loggingEvent.getThrowableInformation() != null) {
                String[] stackTrace = loggingEvent.getThrowableStrRep();
                for (String s : stackTrace) {
                    sb.append(s);
                    sb.append(Layout.LINE_SEP);
                }
            }
            final String stackTrace = sb.toString();

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    if (jTextArea != null) {
                        jTextArea.append(message);
                        if (!stackTrace.isEmpty()) {
                            jTextArea.append(stackTrace);
                        }
                    }
                }
            });
        }
    }
}

I worked a couple of day but did not manage to get a logback version of 
this appender to work. Do you have any sample code available?

thanks in advance
Maurizio


Questa e-mail ed i suoi allegati sono ad uso esclusivo di coloro ai quali è 
indirizzata e potrebbe contenere informazioni riservate, la cui diffusione, 
copia e/o distribuzione è proibita. Qualora riceveste questo messaggio per 
errore, scusandoci per l'accaduto, Vi preghiamo di avvertirci immediatamente, 
distruggendo quanto ricevuto. 
_______________________________________________
Logback-user mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/logback-user

Reply via email to