Can’t download server.log in UberJar

Hello,

when we run our applications as UberJar the server log download does not work. An app.log.zip is downloaded, but it is only 3 KB in size and cannot be opened.

However, the log file is displayed in the server log screen:

In the local.app.properties I have already experimented with the following settings. Unfortunately without success:

cuba.webHostName=aksm-cd.i
cuba.webPort=8080
cuba.dispatcherBaseUrl=http://aksm-cd.i:8080/remoting

Thank you very much for your help.

Greetings,
Andreas

Hi Andreas,

You can try to debug com.haulmont.cuba.web.controllers.LogDownloadController class to find out the what’s going on.

Hi @krivopustov,

I have the UberJar debugged, but when I click download it never jumps into the com.haulmont.cuba.web.controllers.LogDownloadController class. Apparently the URL for the call is not correct:

The UberJar is a single UberJar with context name /:

/bin/java -Dapp.home=/opt/agentes -jar /opt/agentes/aksm.jar -jettyConfPath jetty.xml -contextName /

Here is the file it downloaded as app.log.zip:

app.log.zip.txt (2,2 KB)

It’s a HTML file and not a ZIP file.

Which setting is wrong, or what do I have to set?

Greetings
Andreas

Hello,

I would be happy if someone here could help me.

Many thanks and greetings
Andreas

Hi,
I tried to build UberJar from this sample project: https://github.com/cuba-platform/sample-sales-cuba7

Then launched it with:

java -jar app.jar -contextName /

Downloading app.log from the ServerLog window worked fine.
So it’s something with your project, settings or something else.

Hi @albudarov ,

I download the project https://github.com/cuba-platform/sample-sales-cuba7 and build a UberJar with these settings:

2022-06-27 13_14_34-sample-sales

When I launch the application with java -jar app.jar -contextName / I cannot select any log file:

Have you set any settings in the local.app.properties?

Greetings,
Andreas

I’ve generated logback configuration:
image

I still do not get a log displayed.

Here is the generated uber-jar-lockback.xml:

<?xml version="1.0" encoding="UTF-8"?>

<configuration debug="true">

    <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>DEBUG</level>
        </filter>

        <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"/>
    </root>

    <!-- Begin CUBA -->

    <logger name="com.haulmont.cuba" level="DEBUG"/>

    <logger name="com.haulmont.cuba.core.sys" level="INFO"/>

    <logger name="com.haulmont.cuba.core.sys.CubaDefaultListableBeanFactory" level="WARN"/>
    
    <logger name="com.haulmont.cuba.core.app.scheduling" level="INFO"/>

    <logger name="com.haulmont.cuba.web.sys" level="INFO"/>

    <logger name="com.haulmont.cuba.portal" level="INFO"/>

    <logger name="com.haulmont.cuba.core.app.LockManager" level="INFO"/>

    <!-- End CUBA -->

    <logger name="eclipselink" level="WARN"/>
    
    <logger name="eclipselink.sql" level="INFO"/>

    <logger name="org.springframework" level="WARN"/>

    <logger name="org.activiti" level="INFO"/>
    
    <logger name="freemarker" level="INFO"/>

    <logger name="org.thymeleaf.TemplateEngine" level="INFO"/>

    <logger name="org.docx4j" level="WARN"/>
    
	<logger name="org.xlsx4j" level="WARN"/>

    <logger name="org.hibernate" level="WARN"/>

    <logger name="sun" level="INFO"/>

    <logger name="com.sun" level="INFO"/>

    <logger name="javax" level="INFO"/>

    <logger name="org.apache" level="INFO"/>

    <logger name="org.eclipse.jetty" level="INFO"/>

    <!-- Begin Perf4J  -->

    <logger name="org.perf4j.TimingLogger" level="OFF"/>

    <logger name="com.haulmont.cuba.gui.logging.UIPerformanceLogger" level="OFF"/>

    <!-- End Perf4J  -->

</configuration>

Mine generated logback file is here:

<?xml version="1.0" encoding="UTF-8"?>

<configuration debug="false" packagingData="true">

    <property name="logDir" value="${app.home}/logs"/>

    <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>

    <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>

        <encoder>
            <pattern>%d{HH:mm:ss.SSS} %-5level %-40logger{36}- %msg%n</pattern>
        </encoder>
    </appender>

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

    <!-- Begin CUBA -->

    <logger name="com.haulmont.cuba" level="DEBUG"/>

    <logger name="com.haulmont.cuba.core.sys" level="INFO"/>

    <logger name="com.haulmont.cuba.core.sys.CubaDefaultListableBeanFactory" level="WARN"/>
    
    <logger name="com.haulmont.cuba.core.app.scheduling" level="INFO"/>

    <logger name="com.haulmont.cuba.web.sys" level="INFO"/>

    <logger name="com.haulmont.cuba.portal" level="INFO"/>

    <logger name="com.haulmont.restapi.sys" level="INFO"/>

    <logger name="com.haulmont.cuba.core.app.LockManager" level="INFO"/>

    <!-- End CUBA -->

    <logger name="eclipselink" level="WARN"/>

    <logger name="eclipselink.sql" level="INFO"/>

    <logger name="org.springframework" level="WARN"/>

    <logger name="com.vaadin" level="WARN"/>

    <logger name="org.atmosphere" level="WARN"/>

    <logger name="org.activiti" level="INFO"/>

    <logger name="org.jgroups" level="INFO"/>
    
    <logger name="freemarker" level="INFO"/>

    <logger name="org.thymeleaf.TemplateEngine" level="INFO"/>

    <logger name="com.zaxxer.hikari" level="INFO"/>

    <logger name="org.docx4j" level="WARN"/>
    
	<logger name="org.xlsx4j" level="WARN"/>

    <logger name="org.apache.fop.apps.FOUserAgent" level="WARN"/>

    <logger name="org.hibernate" level="WARN"/>

    <logger name="sun" level="INFO"/>

    <logger name="com.sun" level="INFO"/>

    <logger name="javax" level="INFO"/>

    <logger name="org.apache" level="INFO"/>

    <logger name="org.eclipse.jetty" level="INFO"/>

    <logger name="org.docx4j.utils.ResourceUtils" level="ERROR"/>

    <logger name="org.docx4j.Docx4jProperties" level="ERROR"/>

    <logger name="org.xlsx4j.jaxb.Context" level="ERROR"/>

    <logger name="org.docx4j.utils.XSLTUtils" level="ERROR"/>

    <logger name="org.docx4j.jaxb.JaxbValidationEventHandler" level="ERROR"/>

    <logger name="org.docx4j.TraversalUtil" level="ERROR"/>

    <logger name="org.docx4j.fonts" level="ERROR"/>

    <!-- Begin Perf4J  -->

    <appender name="PerfStatFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${logDir}/perfstat.log</file>
        <append>true</append>

        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${logDir}/perfstat.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>30</maxHistory>
            <cleanHistoryOnStart>true</cleanHistoryOnStart>
        </rollingPolicy>

        <encoder>
            <pattern>%msg%n</pattern>
        </encoder>
    </appender>

    <appender name="CoalescingStatistics" class="org.perf4j.logback.AsyncCoalescingStatisticsAppender">
        <param name="TimeSlice" value="60000"/>
        <appender-ref ref="PerfStatFile"/>
    </appender>

    <appender name="UIPerfStatFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${logDir}/perfstat-ui.log</file>
        <append>true</append>

        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${logDir}/perfstat-ui.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>30</maxHistory>
            <cleanHistoryOnStart>true</cleanHistoryOnStart>
        </rollingPolicy>

        <encoder>
            <pattern>%msg%n</pattern>
        </encoder>
    </appender>

    <appender name="UICoalescingStatistics" class="org.perf4j.logback.AsyncCoalescingStatisticsAppender">
        <param name="TimeSlice" value="120000"/>
        <appender-ref ref="UIPerfStatFile"/>
    </appender>

    <logger name="org.perf4j.TimingLogger" additivity="false" level="INFO">
        <appender-ref ref="CoalescingStatistics"/>
    </logger>

    <logger name="com.haulmont.cuba.gui.logging.UIPerformanceLogger" additivity="false" level="INFO">
        <appender-ref ref="UICoalescingStatistics"/>
    </logger>

    <!-- End Perf4J  -->

</configuration>

Maybe you are using obsolete Studio version?

I’m using IntelliJ 2022.1.3 with CUBA Plugin 15.9-213

2022-06-28 09_51_50-About IntelliJ IDEA

2022-06-28 09_52_11-Settings

Is this perhaps a bug in the plugin?

Hello @albudarov ,

I have now solved the problem by extending the screen LogDownloadOptionsWindow and accessing the bean LogControl directly in the download methods:

AgentesLogDownloadOptionsWindow.java:

public class AgentesLogDownloadOptionsWindow extends LogDownloadOptionsWindow {

    @Inject
    private LogControl logControl;

    @Inject
    private ExportDisplay exportDisplay;

    @Override
    public void init(Map<String, Object> params) {
        super.init(params);
        remoteContextBox.setVisible(false);
    }

    @Override
    public void downloadTail() {
        try {
            final File logFile = logControl.getLogFile(logFileName);
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            LogArchiver.writeArchivedLogTailToStream(logFile, outputStream);
            final ByteArrayDataProvider byteArrayDataProvider = new ByteArrayDataProvider(outputStream.toByteArray());
            final String exportFileName = FilenameUtils.removeExtension(logFileName) + ".zip";
            exportDisplay.show(byteArrayDataProvider, exportFileName,  ExportFormat.ZIP);

        } catch (LogFileNotFoundException | IOException e) {
            throw new IllegalStateException(e);
        }
    }

    @Override
    public void downloadFull() {
        try {
            final File logFile = logControl.getLogFile(logFileName);
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            LogArchiver.writeArchivedLogToStream(logFile, outputStream);
            final ByteArrayDataProvider byteArrayDataProvider = new ByteArrayDataProvider(outputStream.toByteArray());
            final String exportFileName = FilenameUtils.removeExtension(logFileName) + ".zip";
            exportDisplay.show(byteArrayDataProvider, exportFileName,  ExportFormat.ZIP);

        } catch (LogFileNotFoundException | IOException e) {
            throw new IllegalStateException(e);
        }
    }
}

web-screens.xml:

<screen-config xmlns="http://schemas.haulmont.com/cuba/screens.xsd">
    <screen id="serverLogDownloadOptionsDialog"
            template="de/agentes/ksm/web/screens/administration/serverlog/agentes-log-download-options.xml"/>
</screen-config>

Greetings
Andreas