Logback configuration is coming as null

I am using logback 1.2.3. I am passing the logback configuration as -Dlogback.configurationFile=$SERVICE_PATH/restapilayer.logback.xml My restapilayer.logback.xml looks like below <?xml version="1.0" encoding="UTF-8"?><configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern> %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n </Pattern> </layout> </appender> <root level="DEBUG"> <appender-ref ref="STDOUT" /> </root> </configuration> In my logs also I am seeing the configuration file being loaded. 16:25:32,564 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml] at [file:/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml]16:25:32,705 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set16:25:32,706 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]16:25:32,716 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]16:25:32,798 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - This appender no longer admits a layout as a sub-component, set an encoder instead.16:25:32,798 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.16:25:32,798 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details16:25:32,799 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG16:25:32,799 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]16:25:32,800 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.16:25:32,801 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@76707e36 - Registering current configuration as safe fallback point 2018-01-12 16:25:32 [main] INFO com.vnera.common.utils.CommonUtils - adding uncaught exception handler hook... log4j: Default initialization of overridden by log4j.defaultInitOverrideproperty. log4j:WARN No appenders could be found for logger (org.jboss.logging). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. INFO [2018-01-12 16:25:34] o.e.j.u.log:[?:?:?] - [main] - Logging initialized @1909ms Then while trying to log I am seeing the logback configuration as null and it seems logback is running with default config INFO [2018-01-12 16:25:34] c.v.r.c.v.r.VneraBackendService:[?:?:?] - [main] - Logback used _null_ as the configuration file_ I am using the below code to get the logback config logger.debug("Testing Debug logging");LoggerContext loggerContext = ((ch.qos.logback.classic.Logger)logger).getLoggerContext(); URL mainURL = ConfigurationWatchListUtil.getMainWatchURL(loggerContext);System.out.println(mainURL);// or even logger.info("Logback used '{}' as the configuration file.", mainURL); Can someone let me know what is going wrong? How can I debug this issue?

try reviewing your class path. You seem to have log4j on there. You should use either logback, or log4j, but not both.
On 12 Jan 2018, at 17:00, Debraj Manna <subharaj.manna@gmail.com> wrote:
I am using logback 1.2.3. I am passing the logback configuration as -Dlogback.configurationFile=$SERVICE_PATH/restapilayer.logback.xml
My restapilayer.logback.xml looks like below
<?xml version="1.0" encoding="UTF-8"?> <configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern> %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n </Pattern> </layout> </appender>
<root level="DEBUG"> <appender-ref ref="STDOUT" /> </root>
</configuration> In my logs also I am seeing the configuration file being loaded.
16:25:32,564 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml] at [file:/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml] 16:25:32,705 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set 16:25:32,706 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender] 16:25:32,716 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT] 16:25:32,798 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - This appender no longer admits a layout as a sub-component, set an encoder instead. 16:25:32,798 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder. 16:25:32,798 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder <http://logback.qos.ch/codes.html#layoutInsteadOfEncoder> for details 16:25:32,799 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG 16:25:32,799 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT] 16:25:32,800 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. 16:25:32,801 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@76707e36 - Registering current configuration as safe fallback point
2018-01-12 16:25:32 [main] INFO com.vnera.common.utils.CommonUtils - adding uncaught exception handler hook... log4j: Default initialization of overridden by log4j.defaultInitOverrideproperty. log4j:WARN No appenders could be found for logger (org.jboss.logging). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig <http://logging.apache.org/log4j/1.2/faq.html#noconfig> for more info. INFO [2018-01-12 16:25:34] o.e.j.u.log:[?:?:?] - [main] - Logging initialized @1909ms Then while trying to log I am seeing the logback configuration as null and it seems logback is running with default config
INFO [2018-01-12 16:25:34] c.v.r.c.v.r.VneraBackendService:[?:?:?] - [main] - Logback used _null_ as the configuration file_ I am using the below code to get the logback config
logger.debug("Testing Debug logging"); LoggerContext loggerContext = ((ch.qos.logback.classic.Logger)logger).getLoggerContext(); URL mainURL = ConfigurationWatchListUtil.getMainWatchURL(loggerContext); System.out.println(mainURL); // or even logger.info("Logback used '{}' as the configuration file.", mainURL); Can someone let me know what is going wrong? How can I debug this issue?
_______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Correct restapilayer.logback.xml <?xml version="1.0" encoding="UTF-8"?><configuration debug="true"> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <encoder> %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n </encoder> </layout> </appender> <root level="DEBUG"> <appender-ref ref="STDOUT" /> </root> </configuration> Logs 18:58:45,418 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml] at [file:/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml]18:58:45,608 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]18:58:45,611 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE]18:58:45,617 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property18:58:45,645 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG18:58:45,645 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to Logger[ROOT]18:58:45,646 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.18:58:45,646 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@614ddd49 - Registering current configuration as safe fallback point INFO [2018-01-12 18:58:45] c.v.c.u.CommonUtils:[c.v.c.u.CommonUtils:addDefaultExceptionHandler:1876] - [main][CommonUtils.java:1876] - adding uncaught exception handler hook... log4j: Default initialization of overridden by log4j.defaultInitOverrideproperty. log4j:WARN No appenders could be found for logger (org.jboss.logging). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. INFO [2018-01-12 18:58:47] o.e.j.u.log:[?:?:?] - [main] - Logging initialized @2260ms Can someone let me know why my logback config is not getting picked? On Fri, Jan 12, 2018 at 10:30 PM, Debraj Manna <subharaj.manna@gmail.com> wrote:
I am using logback 1.2.3. I am passing the logback configuration as -Dlogback.configurationFile=$SERVICE_PATH/restapilayer.logback.xml
My restapilayer.logback.xml looks like below
<?xml version="1.0" encoding="UTF-8"?><configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern> %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n </Pattern> </layout> </appender>
<root level="DEBUG"> <appender-ref ref="STDOUT" /> </root> </configuration>
In my logs also I am seeing the configuration file being loaded.
16:25:32,564 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml] at [file:/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml]16:25:32,705 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set16:25:32,706 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]16:25:32,716 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]16:25:32,798 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - This appender no longer admits a layout as a sub-component, set an encoder instead.16:25:32,798 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.16:25:32,798 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details16:25:32,799 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG16:25:32,799 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]16:25:32,800 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.16:25:32,801 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@76707e36 - Registering current configuration as safe fallback point 2018-01-12 16:25:32 [main] INFO com.vnera.common.utils.CommonUtils - adding uncaught exception handler hook... log4j: Default initialization of overridden by log4j.defaultInitOverrideproperty. log4j:WARN No appenders could be found for logger (org.jboss.logging). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. INFO [2018-01-12 16:25:34] o.e.j.u.log:[?:?:?] - [main] - Logging initialized @1909ms
Then while trying to log I am seeing the logback configuration as null and it seems logback is running with default config
INFO [2018-01-12 16:25:34] c.v.r.c.v.r.VneraBackendService:[?:?:?] - [main] - Logback used _null_ as the configuration file_
I am using the below code to get the logback config
logger.debug("Testing Debug logging");LoggerContext loggerContext = ((ch.qos.logback.classic.Logger)logger).getLoggerContext(); URL mainURL = ConfigurationWatchListUtil.getMainWatchURL(loggerContext);System.out.println(mainURL);// or even logger.info("Logback used '{}' as the configuration file.", mainURL);
Can someone let me know what is going wrong? How can I debug this issue?

I am having a multi module maven project. In some of the modules I want to use log4j and in some log back. Is it possible to do so? On 13-Jan-2018 12:33 AM, "Debraj Manna" <subharaj.manna@gmail.com> wrote:
Correct restapilayer.logback.xml
<?xml version="1.0" encoding="UTF-8"?><configuration debug="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <encoder> %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n </encoder> </layout> </appender>
<root level="DEBUG"> <appender-ref ref="STDOUT" /> </root> </configuration>
Logs
18:58:45,418 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml] at [file:/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml]18:58:45,608 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]18:58:45,611 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE]18:58:45,617 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property18:58:45,645 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG18:58:45,645 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to Logger[ROOT]18:58:45,646 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.18:58:45,646
...

Anyone any thoughts? Actually we are thinking of migrating to log back from log4j. So we want to try logback in one module first. We have quite a few custom Appenders and layouts in log4j. So we want to do the migration module by module. But the current issue that I am getting is preventing me from using logback in one module and log4j in other modules in the multi module maven project. On 13-Jan-2018 9:22 AM, "Debraj Manna" <subharaj.manna@gmail.com> wrote:
I am having a multi module maven project. In some of the modules I want to use log4j and in some log back. Is it possible to do so?
On 13-Jan-2018 12:33 AM, "Debraj Manna" <subharaj.manna@gmail.com> wrote:
Correct restapilayer.logback.xml
<?xml version="1.0" encoding="UTF-8"?><configuration debug="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <encoder> %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n </encoder> </layout> </appender>
<root level="DEBUG"> <appender-ref ref="STDOUT" /> </root> </configuration>
Logs
18:58:45,418 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml] at [file:/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml]18:58:45,608 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]18:58:45,611 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE]18:58:45,617 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property18:58:45,645 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG18:58:45,645 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to Logger[ROOT]18:58:45
...

I have changes my config file like below <configuration debug="true"> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <Target>System.out</Target> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <root level="DEBUG"> <appender-ref ref="STDOUT" /> </root> </configuration> Removed log4j from path. I am also attaching mvn dependency:tree But still log config file coming as null 10:51:42,695 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml] at [file:/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml]10:51:42,860 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]10:51:42,863 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]10:51:42,869 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property10:51:42,894 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG10:51:42,895 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]10:51:42,895 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.10:51:42,896 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@3fd7a715 - Registering current configuration as safe fallback point2018-01-13 10:51:42 [main] INFO com.vnera.common.utils.CommonUtils - adding uncaught exception handler hook... INFO [2018-01-13 10:51:44] o.e.j.u.log:[?:?:?] - [main] - Logging initialized @1792ms INFO [2018-01-12 16:25:34] c.v.r.c.v.r.VneraBackendService:[?:?:?] - [main] - Logback used _null_ as the configuration file_

This has been answered in stackoverflow https://stackoverflow.com/questions/48230672/logback-configuration-is-coming... On Sat, Jan 13, 2018 at 4:32 PM, Debraj Manna <subharaj.manna@gmail.com> wrote:
I have changes my config file like below
<configuration debug="true"> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <Target>System.out</Target> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <root level="DEBUG"> <appender-ref ref="STDOUT" /> </root> </configuration>
Removed log4j from path. I am also attaching mvn dependency:tree
But still log config file coming as null
10:51:42,695 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml] at [file:/home/ubuntu/build-target/restapilayer/restapilayer.logback.xml]10:51:42,860 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]10:51:42,863 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]10:51:42,869 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property10:51:42,894 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG10:51:42,895 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]10:51:42,895 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.10:51:42,896 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@3fd7a715 - Registering current configuration as safe fallback point2018-01-13 10:51:42 [main] INFO com.vnera.common.utils.CommonUtils - adding uncaught exception handler hook... INFO [2018-01-13 10:51:44] o.e.j.u.log:[?:?:?] - [main] - Logging initialized @1792ms
INFO [2018-01-12 16:25:34] c.v.r.c.v.r.VneraBackendService:[?:?:?] - [main] - Logback used _null_ as the configuration file_
participants (2)
-
David Roussel
-
Debraj Manna