Hey all,

Am trying to write a brief test in which I create a logback file appender and have it append something to a file.

Java Code:
@Test
    public void testFileAppender() throws IOException {

        final ch.qos.logback.classic.Logger root = rootContext();
        root.detachAndStopAllAppenders();
        final FileAppender fileAppender = new FileAppender();
        final LoggerContext context = rootContext().getLoggerContext();
        fileAppender.setContext(context);
        final File tempFile = File.createTempFile("logTest", ".log");
        tempFile.deleteOnExit();
        fileAppender.setFile(tempFile.getCanonicalPath());

        assertTrue(tempFile.exists());
        assertEquals(0, tempFile.length());

        final ThresholdFilter filter = new ThresholdFilter();
        filter.setLevel(Level.ALL.toString());

        fileAppender.addFilter(filter);

        final PatternLayoutEncoder encoder = new PatternLayoutEncoder();
        encoder.setContext(context);
        encoder.start();
        fileAppender.setEncoder(encoder);
        fileAppender.setPrudent(false);
        filter.start();

        fileAppender.start();
        fileAppender.addError("FileWriteTest");
        root.addAppender(fileAppender);
        root.error("root error");
        fileAppender.stop();
        FileReader read = new FileReader(tempFile);
        BufferedReader reader = new BufferedReader(read);
        System.out.println("File contains: " + reader.readLine());
        assertEquals(0, tempFile.length());
    }
unfortunately though the file is consistently created, it is also consistently either empty or contains only the line: #logback.classic pattern: null
which is not what i've told to be printed and not what I expect. I've pretty much taken the appender code from an example so I don't understand the problem. I have a logback-test.xml file which contains only

[CODE]<configuration>

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>myApp.log</file>

<encoder>
<pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
</encoder>
</appender>


<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>but the point of what I'm doing is that I want to be able to write an appender which will always implement its contents regardless of whether or not there is a config file and what may be in it. Is that possible?

Thanks for any help in advance.