简体   繁体   中英

Why spring boot application does not start fully after adding logging?

Collegues, this is part of my pom:

<dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter</artifactId>
                    <version>1.2.5.RELEASE</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j</artifactId>
            <version>1.2.5.RELEASE</version>
        </dependency>

this is my \\src\\main\\resources\\log4j.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

    <!-- Appenders -->
    <appender name="console" class="org.apache.log4j.ConsoleAppender">
        <param name="Target" value="System.out" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-5p: [%d{MMM-dd HH:mm:ss,SSS}] %c{3} - %m%n" />
        </layout>
    </appender>


    <!-- File Appender -->
    <appender name="file" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="C:/LOGS/spring-ws.log"/>
        <param name="MaxFileSize" value="10000KB"/>
        <param name="MaxBackupIndex" value="20"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-5p: [%d{MMM-dd HH:mm:ss,SSS}] %c{3} - %m%n" />
        </layout>
    </appender>

   <logger name="org.springframework.ws.server.MessageTracing.received">
    <level value="TRACE"/>
    <appender-ref ref="console"/> 
    <appender-ref ref="file"/>
   </logger> 


   <logger name="org.springframework.ws.server.MessageTracing.sent">
    <level value="TRACE"/> 
    <appender-ref ref="console"/>
    <appender-ref ref="file"/>
   </logger>

</log4j:configuration>

After

mvn package spring-boot:repackage

and

java -jar target/app-ws.jar

I receive only

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.2.5.RELEASE)

and nothing more.

Also application create C:/LOGS/spring-ws.log, but it is empty.

Why spring boot application does not start?

The problem was solved by adding into log4j.xml next looger:

 <logger name="org.springframework.boot">
        <level value="trace"/>
        <appender-ref ref="console"/>
        <appender-ref ref="file"/>
 </logger>

Hope this will help to somebody.

You can add a property in application.properties as:

logging.level.root=INFO

This will show sufficient amount of info to let you know about mappings and basic application info. Other logging levels that you may use are(source: logging ):

Level Description

  • FATAL : Severe errors that cause premature termination. Expect these to be immediately visible on a status console.
  • ERROR : Other runtime errors or unexpected conditions. Expect these to be immediately visible on a status console.
  • WARNING
  • INFO Interesting runtime events (startup/shutdown). Expect these to be immediately visible on a console, so be conservative and keep to a minimum.
  • DEBUG detailed information on the flow through the system. Expect these to be written to logs only.
  • TRACE more detailed information. Expect these to be written to logs only.

Probabilly you missed this

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM