[logback-user] Logback file is empty

Charalambides, Chryssanthi Chryssa.Charalambides at wsp.com
Wed Aug 22 22:41:02 CEST 2018

Hello all,

I am trying to figure out why logback is not writing to a file. It creates the file okay, but it is not writing anything to it.

I have the following programmatic configuration in my java code. This just reads a properties file and sets system properties out of the logback values so they can be read from the configuration.xml file. It also configures the logger from logback_configuration.xml instead of the default logback.xml

    private static void initLogback() {
        Map<String,String> logbackProperties = new HashMap<>();

        PropertyDeluxe properties = RenoProperties.getProperties();
        for (String key : properties.getKeys())
           if (key.startsWith(RenoProperties.LOGBACK_PROPERTY_PREFIX))

        //set system properties out of the logback values so we can reference them from the configuration file
        for (String key : logbackProperties.keySet())

        //configure the logger from the logback_configuration.xml. Default is logback.xml
        LoggerContext lc = new LoggerContext();
        try {
            JoranConfigurator configurator = new JoranConfigurator();
        } catch (JoranException je) {

Here are the values defined in the property file. Where base.dir is passed in through the command line as "@@base.dir=C:/project_work/reno"

@@scenario.dir = base.dir/scenarios/scenario.name
@@_outputs.dir = scenario.dir/outputs

logback.config.file = base.dir/resource/code/java/logback_configuration.xml
logback.file.main = _outputs.dir/logs/java_main.log
logback.level = info

And here is the logback_configuration.xml

<configuration scan="true" debug="true">

  <appender name="FILE" class="ch.qos.logback.core.FileAppender">

    <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        %d{HH:mm:ss} [%-30.-30thread] %-5level %-25.25logger{25} - %msg%n

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        %d{HH:mm:ss} %green([%-5.-5thread]) %-5level %-25.25logger{25} - %msg%n

  <root level="${logback.level}">
    <appender-ref ref="FILE" />
    <appender-ref ref="STDOUT" />

I’ve looked everywhere and nothing really stands out.  Can anyone see what I’ve missed?

Thank you

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20180822/31152fad/attachment.html>

More information about the logback-user mailing list