🔴 The Error You're Seeing

Confirm this matches your console output. If it does, you're in the right place.

ERROR LOG2026-02-21 08:00:15.000 ERROR 8842 --- [ main] o.s.boot.SpringApplication : Application run failed ch.qos.logback.core.joran.spi.JoranException: Problem parsing XML document. at ch.qos.logback.core.joran.event.SaxEventRecorder.recordEvents(SaxEventRecorder.java:61) Caused by: org.xml.sax.SAXParseException: The element type "configuration" must be terminated by the matching end-tag "</configuration>". at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204)

⚡ Quick Fix Works 80% of the time

Check your logback-spring.xml for unclosed tags and fix the XML structure.

<!-- Ensure all tags are closed --> <configuration> <root level="INFO"/> </configuration> <!-- Missing this closing tag causes the error -->

🧠 Why this Happens

Tap to expand the deep technical explanation

Logback uses a SAX parser to read your `logback-spring.xml` file. The parser encountered malformed XML, such as a missing closing tag, overlapping tags, or an unescaped special character. The parser cannot build the document tree and aborts, crashing the Spring Boot startup.

The HITEC City Parking Spot Analogy:

It's like a parser trying to read a sentence where the periods are missing. 'The quick brown fox jumps over the lazy dog The dog barks'. The parser doesn't know where the first sentence ends, so it gives up.

🔁 How to Reproduce Confirm this is your error

Create `logback-spring.xml`. Add `<root level="INFO">` but forget to close it with `</root>`. Run the Spring Boot app.

🛠️ Solutions (5 Ways to Fix)

Solution 1✓ Most common cause

Fix unclosed XML tags

👉 Use this as the primary fix for SAXParseExceptions.

Ensure every opening tag has a matching closing tag, or is self-closing.

<!-- BAD: --> <appender name="STDOUT" class="..."> <encoder> <pattern>%msg%n</pattern> <!-- Missing </encoder> --> <!-- GOOD: --> <appender name="STDOUT" class="..."> <encoder> <pattern>%msg%n</pattern> </encoder> </appender>
Solution 2

Escape special characters

👉 Use this if your pattern contains `<`, `>`, or `&`.

XML parsers treat `<` as the start of a tag. If you need a literal `<` in your log pattern, you must escape it.

<!-- BAD: --> <pattern>%d{HH:mm:ss} %-5level %logger{36} - %msg%n</pattern> <!-- If you need < or >, use &lt; and &gt; --> <pattern>%d{HH:mm:ss} %-5level %logger{36} - %msg%n</pattern>
Solution 3

Remove BOM (Byte Order Mark)

👉 Use this if the XML looks correct but the parser still fails on line 1.

Some editors insert a hidden BOM character at the start of the file, which breaks the XML parser.

# Use a tool like `dos2unix` or IDE settings to save as UTF-8 without BOM dos2unix src/main/resources/logback-spring.xml
Solution 4

Validate XML in IDE

👉 Use this to find the exact line number of the error.

The `Caused by: SAXParseException` usually contains the line number. Use your IDE to jump to it and fix it.

// IntelliJ: Right-click logback-spring.xml -> Validate XML
Solution 5

Delete logback-spring.xml

👉 Use this if you don't need custom Logback configuration.

If you just want default logging, delete the file and Spring Boot will use its default ConsoleAppender.

rm src/main/resources/logback-spring.xml

📋 Version Notes

Spring Boot 2.x

Standard Logback Joran parsing.

Spring Boot 3.x

Identical behavior, but Spring Boot's FailureAnalyzer provides better error messages.

🛡️ How to Prevent This Next Time

Use an IDE like IntelliJ or VS Code that highlights XML syntax errors in real-time. Configure the IDE to validate XML files on save.