Log files not not loading in production

Hi,
This is my UbberJar config:

task buildUberJar(type: CubaUberJarBuilding) {
logbackConfigurationFile = ‘etc/uber-jar-logback.xml’
singleJar = true
coreJettyEnvPath = ‘modules/core/web/META-INF/jetty-env.xml’
appProperties = [‘cuba.automaticDatabaseUpdate’ : true, ‘cuba.logDir’ : ‘/var/log/cuba’, ‘cuba.fileStorageDir’ : ‘/mnt/share/appfiles’]
}

the cuba.logDir is configured to /var/log/cuba

When I log in to the docker machine there are no logs inside, Also, in CUBA UI the files list is empty.
for now, this is the only way to see logs in production: docker logs crm --tail

Thaks

As far as I know, cuba.logDir is only for viewing logs in Server Log screen. For logging setup you should configure your etc/uber-jar-logback.xml file. See Logback documentation.

See also Log Directory - CUBA Platform. Developer’s Manual

P.S. Please use code blocks, it is hard to read it.

Hi,
If you take a look at my post you will see that I have logback config. The config is not specifing the path.
logDir should tell sl4j where to save the log files.
Thanks

In this case logs will not be written to files at all. You have to define log dir location and a new appender in logback.xml:

    <property name="logDir" value="/var/log/application"/>

    <appender name="File" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${logDir}/app.log</file>

        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>DEBUG</level>
        </filter>

        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- daily rollover -->
            <fileNamePattern>${logDir}/app.%d{yyyy-MM-dd}.log</fileNamePattern>
            <!-- keep 30 days' worth of history -->
            <maxHistory>30</maxHistory>
            <cleanHistoryOnStart>true</cleanHistoryOnStart>
        </rollingPolicy>

        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread%X{cubaApp}%X{cubaUser}] %logger - %msg%n</pattern>
        </encoder>
    </appender>

    <root>
        <appender-ref ref="Console"/>
        <appender-ref ref="File"/>
    </root>

See the complete example in the framework sources: https://github.com/cuba-platform/cuba-gradle-plugin/blob/master/src/main/resources/tomcat/conf/logback.xml

Also, you can follow the documentation, it explains how to set up logging for Docker environment: Deployment with Docker - CUBA Platform. Developer’s Manual

1 Like