0

i am using logback 1.0.0 and my configuration is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
    <appender name="STDOUT"
            class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <charset>UTF-8</charset>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
        </encoder>
    </appender>


        <!--Daily rolling file appender -->
    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <File>logs\motivosity_logback.log</File> <!-- make sure you have permissions on this file -->   
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- daily rollover -->
            <FileNamePattern>logs\logFile.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy
                class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <!-- or whenever the file size reaches 100MB -->
                <maxFileSize>50MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
            <!-- keep 30 days' worth of history -->
            <maxHistory>30</maxHistory>
        </rollingPolicy>

        <encoder>
            <charset>UTF-8</charset>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
        </encoder>

    </appender>


    <logger name="com.myapp">
        <level value="debug" />
    </logger>

    <logger name="org.ocpsoft.rewrite.faces">
        <level value="debug" />
    </logger>

    <logger name="org.springframework.security.web.authentication">
        <level value="debug" />
    </logger>

    <logger name="org.apache">
        <level value="info" />
    </logger>

    <root>
        <level value="info" />
        <appender-ref ref="STDOUT" />
        <appender-ref ref="FILE" />
    </root>

</configuration>

it works fine locally, but on cloudbees when i open my home page

i can't see any logs in the papertrailapp

i use the log as follows:

private static Logger log = LoggerFactory.getLogger(MyBean.class);

if (log.isDebugEnabled()) {
            log.debug("INIT MyBean");
}

please advise why it's not working.

UPDATE:

  • standard sysouts works fine: System.out.println("INIT MyBean");
  • the class i want to log.debug at is in the package com.myapp.web.controllers and i have logger configured for com.myapp as follows:

but when i tried to sysout System.out.println("######## DEBUG ENABLED: " + log.isDebugEnabled()); it prints false, it means that debug is not enabled for this class, which is very weird.

  • another thing i tried log.info("@PostConstruct MyBean"); and it worked fine, i tried to change the root logging level to be debug, but still only info is logged.
Mahmoud Saleh
  • 33,303
  • 119
  • 337
  • 498

2 Answers2

2

You need to have it log to STDOUT or STDERR as appropriate: for example see:

file and stdout appenders in logback.xml

(might be some better ones out there) - that ensures logs can go to any subsystem and work clustered and when apps migrate.

Community
  • 1
  • 1
Michael Neale
  • 19,248
  • 19
  • 77
  • 109
0

turns out that my configuration is correct but it works only for info,error levels and debug level won't work.

Mahmoud Saleh
  • 33,303
  • 119
  • 337
  • 498