logback.xml not logging to Console or File - Getting error “Element type ”configuration“ must be...












0















I have followed multiple links on SO and other sources on the internet and modified my logback.xml but it is still not working. Please help.



I have a web application in Maven using Java 1.7 and Spring 4.3.13.RELEASE.



logback.xml under src/main/resources



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration>
<configuration>
<property name="log.folder" value="/logs" />
<property name="log.activity.fileName" value="myapp.log" />
<property name="log.file.maxsize" value="90MB" />

<appender name="CONSOLELOGGER" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.err"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>

<appender name="MYLOGGER" class="org.apache.log4j.RollingFileAppender">
<File>${log.folder}/${log.activity.fileName}</File>
<encoder>
<pattern>%d %-5p [%c] %msg %n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${log.folder}/${log.activity.fileName}.%d{YYYY-MM-dd}-%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>${log.file.maxsize}</maxFileSize>
<!-- keep 30 days' worth of history -->
<!-- <maxHistory>30</maxHistory> -->
</timeBasedFileNamingAndTriggeringPolicy>
<param name="locationInfo" value="true" />
</rollingPolicy>
</appender>

<logger name="org.mypackage" level="info">
<appender-ref ref="MYLOGGER"/>
</logger>

<root>
<level value="ERROR" />
<appender-ref ref="CONSOLELOGGER" />
<appender-ref ref="MYLOGGER" />
</root>

</configuration>


servlet.xml contains



 <context:property-placeholder location="classpath:logback.xml" ignore-unresolvable="true"/>


Pom has



<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.3</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.11.1</version>
</dependency>


Complete error:



Caused by: org.xml.sax.SAXParseException: Element type "configuration" must be declared.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)









share|improve this question























  • why do you need <!DOCTYPE configuration>? have you tried to remove it?

    – uli
    Nov 21 '18 at 0:15











  • yes without <!DOCTYPE configuration> I get the error org.xml.sax.SAXParseException: Document root element "configuration", must match DOCTYPE root "null".

    – sva
    Nov 21 '18 at 0:27











  • your log-back appender config doesn't seem correct as you are using appender class from log4j. you can refer this logback.qos.ch/manual/appenders.html

    – lucid
    Nov 21 '18 at 6:38











  • @lucid I updated with logback classes but got the error "Element type "configuration" must be declared." I updated the log4j classes to ch.qos.logback.core.rolling.RollingFileAppender and ch.qos.logback.core.ConsoleAppender.

    – sva
    Nov 23 '18 at 18:13
















0















I have followed multiple links on SO and other sources on the internet and modified my logback.xml but it is still not working. Please help.



I have a web application in Maven using Java 1.7 and Spring 4.3.13.RELEASE.



logback.xml under src/main/resources



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration>
<configuration>
<property name="log.folder" value="/logs" />
<property name="log.activity.fileName" value="myapp.log" />
<property name="log.file.maxsize" value="90MB" />

<appender name="CONSOLELOGGER" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.err"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>

<appender name="MYLOGGER" class="org.apache.log4j.RollingFileAppender">
<File>${log.folder}/${log.activity.fileName}</File>
<encoder>
<pattern>%d %-5p [%c] %msg %n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${log.folder}/${log.activity.fileName}.%d{YYYY-MM-dd}-%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>${log.file.maxsize}</maxFileSize>
<!-- keep 30 days' worth of history -->
<!-- <maxHistory>30</maxHistory> -->
</timeBasedFileNamingAndTriggeringPolicy>
<param name="locationInfo" value="true" />
</rollingPolicy>
</appender>

<logger name="org.mypackage" level="info">
<appender-ref ref="MYLOGGER"/>
</logger>

<root>
<level value="ERROR" />
<appender-ref ref="CONSOLELOGGER" />
<appender-ref ref="MYLOGGER" />
</root>

</configuration>


servlet.xml contains



 <context:property-placeholder location="classpath:logback.xml" ignore-unresolvable="true"/>


Pom has



<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.3</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.11.1</version>
</dependency>


Complete error:



Caused by: org.xml.sax.SAXParseException: Element type "configuration" must be declared.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)









share|improve this question























  • why do you need <!DOCTYPE configuration>? have you tried to remove it?

    – uli
    Nov 21 '18 at 0:15











  • yes without <!DOCTYPE configuration> I get the error org.xml.sax.SAXParseException: Document root element "configuration", must match DOCTYPE root "null".

    – sva
    Nov 21 '18 at 0:27











  • your log-back appender config doesn't seem correct as you are using appender class from log4j. you can refer this logback.qos.ch/manual/appenders.html

    – lucid
    Nov 21 '18 at 6:38











  • @lucid I updated with logback classes but got the error "Element type "configuration" must be declared." I updated the log4j classes to ch.qos.logback.core.rolling.RollingFileAppender and ch.qos.logback.core.ConsoleAppender.

    – sva
    Nov 23 '18 at 18:13














0












0








0








I have followed multiple links on SO and other sources on the internet and modified my logback.xml but it is still not working. Please help.



I have a web application in Maven using Java 1.7 and Spring 4.3.13.RELEASE.



logback.xml under src/main/resources



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration>
<configuration>
<property name="log.folder" value="/logs" />
<property name="log.activity.fileName" value="myapp.log" />
<property name="log.file.maxsize" value="90MB" />

<appender name="CONSOLELOGGER" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.err"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>

<appender name="MYLOGGER" class="org.apache.log4j.RollingFileAppender">
<File>${log.folder}/${log.activity.fileName}</File>
<encoder>
<pattern>%d %-5p [%c] %msg %n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${log.folder}/${log.activity.fileName}.%d{YYYY-MM-dd}-%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>${log.file.maxsize}</maxFileSize>
<!-- keep 30 days' worth of history -->
<!-- <maxHistory>30</maxHistory> -->
</timeBasedFileNamingAndTriggeringPolicy>
<param name="locationInfo" value="true" />
</rollingPolicy>
</appender>

<logger name="org.mypackage" level="info">
<appender-ref ref="MYLOGGER"/>
</logger>

<root>
<level value="ERROR" />
<appender-ref ref="CONSOLELOGGER" />
<appender-ref ref="MYLOGGER" />
</root>

</configuration>


servlet.xml contains



 <context:property-placeholder location="classpath:logback.xml" ignore-unresolvable="true"/>


Pom has



<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.3</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.11.1</version>
</dependency>


Complete error:



Caused by: org.xml.sax.SAXParseException: Element type "configuration" must be declared.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)









share|improve this question














I have followed multiple links on SO and other sources on the internet and modified my logback.xml but it is still not working. Please help.



I have a web application in Maven using Java 1.7 and Spring 4.3.13.RELEASE.



logback.xml under src/main/resources



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration>
<configuration>
<property name="log.folder" value="/logs" />
<property name="log.activity.fileName" value="myapp.log" />
<property name="log.file.maxsize" value="90MB" />

<appender name="CONSOLELOGGER" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.err"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>

<appender name="MYLOGGER" class="org.apache.log4j.RollingFileAppender">
<File>${log.folder}/${log.activity.fileName}</File>
<encoder>
<pattern>%d %-5p [%c] %msg %n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${log.folder}/${log.activity.fileName}.%d{YYYY-MM-dd}-%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>${log.file.maxsize}</maxFileSize>
<!-- keep 30 days' worth of history -->
<!-- <maxHistory>30</maxHistory> -->
</timeBasedFileNamingAndTriggeringPolicy>
<param name="locationInfo" value="true" />
</rollingPolicy>
</appender>

<logger name="org.mypackage" level="info">
<appender-ref ref="MYLOGGER"/>
</logger>

<root>
<level value="ERROR" />
<appender-ref ref="CONSOLELOGGER" />
<appender-ref ref="MYLOGGER" />
</root>

</configuration>


servlet.xml contains



 <context:property-placeholder location="classpath:logback.xml" ignore-unresolvable="true"/>


Pom has



<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.3</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.11.1</version>
</dependency>


Complete error:



Caused by: org.xml.sax.SAXParseException: Element type "configuration" must be declared.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)






java spring logback






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 22:50









svasva

125




125













  • why do you need <!DOCTYPE configuration>? have you tried to remove it?

    – uli
    Nov 21 '18 at 0:15











  • yes without <!DOCTYPE configuration> I get the error org.xml.sax.SAXParseException: Document root element "configuration", must match DOCTYPE root "null".

    – sva
    Nov 21 '18 at 0:27











  • your log-back appender config doesn't seem correct as you are using appender class from log4j. you can refer this logback.qos.ch/manual/appenders.html

    – lucid
    Nov 21 '18 at 6:38











  • @lucid I updated with logback classes but got the error "Element type "configuration" must be declared." I updated the log4j classes to ch.qos.logback.core.rolling.RollingFileAppender and ch.qos.logback.core.ConsoleAppender.

    – sva
    Nov 23 '18 at 18:13



















  • why do you need <!DOCTYPE configuration>? have you tried to remove it?

    – uli
    Nov 21 '18 at 0:15











  • yes without <!DOCTYPE configuration> I get the error org.xml.sax.SAXParseException: Document root element "configuration", must match DOCTYPE root "null".

    – sva
    Nov 21 '18 at 0:27











  • your log-back appender config doesn't seem correct as you are using appender class from log4j. you can refer this logback.qos.ch/manual/appenders.html

    – lucid
    Nov 21 '18 at 6:38











  • @lucid I updated with logback classes but got the error "Element type "configuration" must be declared." I updated the log4j classes to ch.qos.logback.core.rolling.RollingFileAppender and ch.qos.logback.core.ConsoleAppender.

    – sva
    Nov 23 '18 at 18:13

















why do you need <!DOCTYPE configuration>? have you tried to remove it?

– uli
Nov 21 '18 at 0:15





why do you need <!DOCTYPE configuration>? have you tried to remove it?

– uli
Nov 21 '18 at 0:15













yes without <!DOCTYPE configuration> I get the error org.xml.sax.SAXParseException: Document root element "configuration", must match DOCTYPE root "null".

– sva
Nov 21 '18 at 0:27





yes without <!DOCTYPE configuration> I get the error org.xml.sax.SAXParseException: Document root element "configuration", must match DOCTYPE root "null".

– sva
Nov 21 '18 at 0:27













your log-back appender config doesn't seem correct as you are using appender class from log4j. you can refer this logback.qos.ch/manual/appenders.html

– lucid
Nov 21 '18 at 6:38





your log-back appender config doesn't seem correct as you are using appender class from log4j. you can refer this logback.qos.ch/manual/appenders.html

– lucid
Nov 21 '18 at 6:38













@lucid I updated with logback classes but got the error "Element type "configuration" must be declared." I updated the log4j classes to ch.qos.logback.core.rolling.RollingFileAppender and ch.qos.logback.core.ConsoleAppender.

– sva
Nov 23 '18 at 18:13





@lucid I updated with logback classes but got the error "Element type "configuration" must be declared." I updated the log4j classes to ch.qos.logback.core.rolling.RollingFileAppender and ch.qos.logback.core.ConsoleAppender.

– sva
Nov 23 '18 at 18:13












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402768%2flogback-xml-not-logging-to-console-or-file-getting-error-element-type-config%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402768%2flogback-xml-not-logging-to-console-or-file-getting-error-element-type-config%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents