Logback FileAppender - is the log file empty?

In the project, I have the following in the classpath:

Bundle-ClassPath: .,
 lib/logback-classic.jar,
 lib/logback-core.jar,
 lib/slf4j-api.jar

and the following in build.properties:

bin.includes = META-INF/,\
               .,\
               plugin.xml,\
               lib/logback-classic.jar,\
               lib/logback-core.jar,\
               lib/slf4j-api.jar,\
               logback.xml

In the root, I also have a logback.xml file containing:

<!--   <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> -->
<!--     <layout class="ch.qos.logback.classic.PatternLayout"> -->
<!--       <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n -->
<!--       </Pattern> -->
<!--     </layout> -->
<!--   </appender> -->
  <root level="debug">
    <appender-ref ref="STDOUT" />
  </root>
  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <File>logs\\logfile.log</File>
    <Append>true</Append>
    <layout class="ch.qos.logback.classic.PatternLayout">
      <Pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n
      </Pattern>
    </layout>
  </appender>
</configuration>

In the class that starts at startup, I:

  private static final Logger logger = LoggerFactory.getLogger(Application.class.getName());
  public Object start(IApplicationContext context) {
    logger.debug("debug string");
    logger.warn("warn string");
    logger.error("error string");

When I create and run my application, the log files \ logfile.log are created in the root of my application, but its empty. If I use ConsoleAppender and turn on the console, it works fine.

Why is logback not written to the log file when using FileAppender?

+5
source share
1 answer

You tried to add the appender-ref file for root in logback.xml, as shown below:

<root level="debug">
   <appender-ref ref="STDOUT" />
   <appender-ref ref="FILE" />
</root>
+7
source