Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log file not getting generated after migrating to java 17 #852

Open
ravadisagarrao opened this issue Aug 26, 2024 Discussed in #848 · 12 comments
Open

log file not getting generated after migrating to java 17 #852

ravadisagarrao opened this issue Aug 26, 2024 Discussed in #848 · 12 comments

Comments

@ravadisagarrao
Copy link

ravadisagarrao commented Aug 26, 2024

After upgraded our application from java 8 to Java 17 log file is not getting generated with logback version 1.3.14

When searched in google found that 1.3.14 supports till Java 8, so added latest logback version 1.5.7 in pom.xml but still log file is not getting generated.

Could someone please review below logback.xml config file and let me know whether am I missing something?
`

<contextName>cmd-cxp-api</contextName>
<jmxConfigurator />
%d{HH:mm:ss.SSS} [%thread] %-5level %X{tenant.id} %logger{36} - %msg%n
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${log.file.location}/emcd_server.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <!-- daily rollover -->
        <fileNamePattern>${log.file.location}/emcd_server.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
        <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <!-- or whenever the file size reaches 10MB -->
            <maxFileSize>10MB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
        <!-- keep 30 days' worth of history -->
        <maxHistory>30</maxHistory>
    </rollingPolicy>
    <encoder>
        <pattern>%date %level %X{tenant.id} [%thread] %logger{10} [%file:%line] %msg%n</pattern>
    </encoder>
</appender>

<logger name="com.xxx.mobile">
    <level value="TRACE" />
</logger>

<logger name="org.springframework">
    <level value="TRACE" />
</logger>

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

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

`

@ceki
Copy link
Member

ceki commented Aug 26, 2024

@ravadisagarrao Please add a status listener as shown below and report back the results here.

<configuration attributes_if_any...>
   <!-- Recommendation: place status listeners towards the the top of the configuration file -->
   <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />

   <!-- ... the rest of the configuration file -->

</configuration>```

@ravadisagarrao
Copy link
Author

ravadisagarrao commented Aug 26, 2024

@ceki , Thanks for quick turn around, tried above status listener but still not able to generate log file.

@ceki
Copy link
Member

ceki commented Aug 26, 2024

@ravadisagarrao Can you include the resulting status output?

@ravadisagarrao
Copy link
Author

Verified in Tomee startup logs, status output is not found. Do let me know if you need any more info.

@ceki
Copy link
Member

ceki commented Aug 27, 2024

@ravadisagarrao It looks like your logback.xml configuration file is not picked up at all.

Adding the "logback.statusListenerClass" system property with "java -Dlogback.statusListenerClass=stdout" might help see the status messages.

However, this assumes that slf4j finds logback. Are you using slf4j and if so which version?

@ravadisagarrao
Copy link
Author

@ceki, I have set as below in setenv.bat file.

set CATALINA_OPTS=%CATALINA_OPTS% "-Dpassport.properties.dir.cmd=C:\emcd"
set java "-Dlogback.statusListenerClass=stdout"

is this correct? If yes still not seeing status messages. If NO could you please let me know how and where can i add it.

And I am using slf4j version:2.0.13

@ceki
Copy link
Member

ceki commented Aug 27, 2024

Try

set CATALINA_OPTS=%CATALINA_OPTS% "-Dlogback.statusListenerClass=stdout -Dpassport.properties.dir.cmd=C:\emcd"

Also, what is the output of SLF4J? Search for lines starting with SLF4J(x) on stdout, x being any of the letters D,I,W or E.

I suggest upgrading to slf4j version 2.0.16 and adding the following to CATALINA_OPTS

-Dslf4j.internal.verbosity=DEBUG

@ravadisagarrao
Copy link
Author

ravadisagarrao commented Aug 27, 2024

  1. Yes added system properties as suggested.
  2. Searched with SLF4J but nothing found but when I removed slf4j jar from tomee lib folder it complained below in logs.
    "SLF4J: No SLF4J providers were found." and after adding slf4j jar this error is gone.
  3. Also upgraded to slf4j version 2.0.16 and added set CATALINA_OPTS=%CATALINA_OPTS% "-Dslf4j.internal.verbosity=DEBUG"
    but still no luck.
    FYI, please find the tomee startup log file attached.
    catalina.2024-08-27.log

@ceki
Copy link
Member

ceki commented Aug 27, 2024

Are you trying to use slf4j/logback for TomEE or for web-application's logging? Where are you placing slf4j and logback jar files? Is it in your application's EAR/WAR file or in TomEE's lib folder?

Also if you are using slf4j 2.0.16, then I recommend using the latest logback version.

@ravadisagarrao
Copy link
Author

We are using logback for web app's logging. We placed logback jar files inside WAR file and SLF4j-api is placed in both WAR and Tomee lib folder.
Yes using slf4j 2.0.16, I am already on logback latest version 1.5.7

@ceki
Copy link
Member

ceki commented Aug 27, 2024

There is no need to place slf4j-api.jar in TomEE's lib folder if logback jar files are not next to it. At this stage, I would thus recommend removing slf4j-api.jar file from TomEE's lib folder.

However, it is quite strange that no messages are emitted by SLF4J.

@ravadisagarrao
Copy link
Author

ravadisagarrao commented Aug 28, 2024

Finally, its working now. After freshly checking out code and rebuilt with upgraded dependencies (logback 1.5.7 and slf4j 2.0.16) able to generate loggers.

Thank you very much for your time in troubleshooting. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@ceki @ravadisagarrao and others