Anmeldung im Frühjahr
Dec 10 2020
Ich habe eine Spring-Boot-Anwendung, und nach dem Start sehen wir normalerweise die folgende Ausgabe an die Konsole
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.0)
1283 [main] INFO org.springframework.boot.web.embedded.tomcat.TomcatWebServer - Tomcat started on port(s): 8080 (http) with context path
usw...
Ich brauche diese Protokollausgabe:
1283 [main] INFO org.springframework.boot.web.embedded.tomcat.TomcatWebServer - Tomcat started on port(s): 8080 (http) with context path
und füge es mit slf4j in die Datei ein
Ich habe eine application.properties mit den Einstellungen von slf4j
logging.level.root=INFO
logging.level.org.spring.upskill = INFO
logging.level.org.springframework.web = INFO
logging.file.name = app.log
Aber ich bekomme keine vollständige Ausgabe der Datei. Nur Antworten auf meine GetMappings
Zum Beispiel
[2020-12-10 14:31:53.381] - 19960 INFO [main] --- org.apache.catalina.core.StandardService: Starting service [Tomcat]
[2020-12-10 14:31:53.385] - 19960 INFO [main] --- org.apache.catalina.core.StandardEngine: Starting Servlet engine: [Apache Tomcat/9.0.39]
[2020-12-10 14:31:53.432] - 19960 INFO [main] --- org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]: Initializing Spring embedded WebApplicationContext
Wie mache ich das?
Vielen Dank!
Antworten
Saptarshi Dec 10 2020 at 16:14
Ich gehe davon aus, dass Sie appender.rolling.policies.startup.type = OnStartupTriggeringPolicy in den Eigenschaften verwenden oder die Datei log4j2.xml aktualisieren können, um Folgendes in Appenders -> RollingRandomAccessFile aufzunehmen
<Policies>
<!-- Starts a new log on tomcat start -->
<OnStartupTriggeringPolicy />
<!-- Starts a new file when size reaches threshold -->
<SizeBasedTriggeringPolicy size="100 MB" />
<!-- causes a rollover once the date/time pattern no longer applies to
the active file
<TimeBasedTriggeringPolicy /> -->
</Policies>