No log4j2 configuration file found. Using default configuration: logging only errors to the console












38















$ java -Dlog4j.configuration=file:///path/to/your/log4j2.xml -jar /path/to/your/jar_file.jar


Written to the console, you get



ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.


But, it also looks like the configuration file has been found and was not parsable:



    log4j:WARN Continuable parsing error 2 and column 31
log4j:WARN Document root element "Configuration", must match DOCTYPE root "null".
log4j:WARN Continuable parsing error 2 and column 31
log4j:WARN Document is invalid: no grammar found.
log4j:ERROR DOM element is - not a <log4j:configuration> element.
log4j:WARN No appenders could be found for logger (kafka.utils.VerifiableProperties).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.









share|improve this question























  • make sure you don't have multiple log4j version on your build path.. it looks like on first line is about log4j 2.x and the last log4j:WARN and log4j:ERROR is made from log4j 1.x... they have different configurations..

    – Mike D3ViD Tyson
    Sep 14 '18 at 15:20


















38















$ java -Dlog4j.configuration=file:///path/to/your/log4j2.xml -jar /path/to/your/jar_file.jar


Written to the console, you get



ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.


But, it also looks like the configuration file has been found and was not parsable:



    log4j:WARN Continuable parsing error 2 and column 31
log4j:WARN Document root element "Configuration", must match DOCTYPE root "null".
log4j:WARN Continuable parsing error 2 and column 31
log4j:WARN Document is invalid: no grammar found.
log4j:ERROR DOM element is - not a <log4j:configuration> element.
log4j:WARN No appenders could be found for logger (kafka.utils.VerifiableProperties).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.









share|improve this question























  • make sure you don't have multiple log4j version on your build path.. it looks like on first line is about log4j 2.x and the last log4j:WARN and log4j:ERROR is made from log4j 1.x... they have different configurations..

    – Mike D3ViD Tyson
    Sep 14 '18 at 15:20
















38












38








38


5






$ java -Dlog4j.configuration=file:///path/to/your/log4j2.xml -jar /path/to/your/jar_file.jar


Written to the console, you get



ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.


But, it also looks like the configuration file has been found and was not parsable:



    log4j:WARN Continuable parsing error 2 and column 31
log4j:WARN Document root element "Configuration", must match DOCTYPE root "null".
log4j:WARN Continuable parsing error 2 and column 31
log4j:WARN Document is invalid: no grammar found.
log4j:ERROR DOM element is - not a <log4j:configuration> element.
log4j:WARN No appenders could be found for logger (kafka.utils.VerifiableProperties).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.









share|improve this question














$ java -Dlog4j.configuration=file:///path/to/your/log4j2.xml -jar /path/to/your/jar_file.jar


Written to the console, you get



ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.


But, it also looks like the configuration file has been found and was not parsable:



    log4j:WARN Continuable parsing error 2 and column 31
log4j:WARN Document root element "Configuration", must match DOCTYPE root "null".
log4j:WARN Continuable parsing error 2 and column 31
log4j:WARN Document is invalid: no grammar found.
log4j:ERROR DOM element is - not a <log4j:configuration> element.
log4j:WARN No appenders could be found for logger (kafka.utils.VerifiableProperties).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.






java log4j log4j2






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 17 '15 at 22:57









Jeff MaassJeff Maass

2,07411726




2,07411726













  • make sure you don't have multiple log4j version on your build path.. it looks like on first line is about log4j 2.x and the last log4j:WARN and log4j:ERROR is made from log4j 1.x... they have different configurations..

    – Mike D3ViD Tyson
    Sep 14 '18 at 15:20





















  • make sure you don't have multiple log4j version on your build path.. it looks like on first line is about log4j 2.x and the last log4j:WARN and log4j:ERROR is made from log4j 1.x... they have different configurations..

    – Mike D3ViD Tyson
    Sep 14 '18 at 15:20



















make sure you don't have multiple log4j version on your build path.. it looks like on first line is about log4j 2.x and the last log4j:WARN and log4j:ERROR is made from log4j 1.x... they have different configurations..

– Mike D3ViD Tyson
Sep 14 '18 at 15:20







make sure you don't have multiple log4j version on your build path.. it looks like on first line is about log4j 2.x and the last log4j:WARN and log4j:ERROR is made from log4j 1.x... they have different configurations..

– Mike D3ViD Tyson
Sep 14 '18 at 15:20














9 Answers
9






active

oldest

votes


















2














I have been dealing with this problem for a while. I have changed everything as described in this post and even thought error occured. In that case make sure that you clean the project when changing settings in .xml or .properties file.
In eclipse environment. Choose Project -> Clean






share|improve this answer



















  • 1





    excellent point. In my particular setup, a Maven -> Install does not remove previously created resource files. So, log4j2 config files may hang around even after dependencies have been changed.

    – Jeff Maass
    Dec 1 '16 at 17:23






  • 2





    Below answer is the right answer.. Not this..

    – LPD
    Apr 7 '17 at 13:48






  • 1





    @LPD Please read answer correctly. It has been said that if non of those anwsers are helpfull, problem can be caused by cached files. Note that same problem may have different causes. So there may not be only one solution. As in this case.

    – Phatee P
    Apr 7 '17 at 14:31











  • In my case, I had filtering enabled in my pom file under build/resource. I had to add an include clause for XML files. If anyone is still having this issue, you might want to check that as well.

    – enissay
    Nov 13 '17 at 10:14



















47














Problem 1



ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.


Solution 1



To work with version 2 of log4j aka "log4j2"



-Dlog4j.configuration=


should read



-Dlog4j.configurationFile=



  • 1.2 manual: http://logging.apache.org/log4j/1.2/manual.html

  • 2.x manual: http://logging.apache.org/log4j/2.x/manual/configuration.html


Problem 2



log4j:WARN ....


Solution 2



In your project, uninclude the log4j-1.2 jar and instead, include the log4j-1.2-api-2.1.jar. I wasn't sure how exactly to exclude the log4j 1.2. I knew that what dependency of my project was requiring it. So, with some reading, I excluded a bunch of stuff.



<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
<version>0.8.2.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.log4j</groupId>
<artifactId>log4j-core</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>


I am not sure which of the exclusions did the trick. Separately, I included a dependency to the 1.2 api which bridges to 2.x.



<!--
http://logging.apache.org/log4j/2.0/manual/migration.html
http://logging.apache.org/log4j/2.0/maven-artifacts.html
Log4j 1.x API Bridge
If existing components use Log4j 1.x and you want to have this logging
routed to Log4j 2, then remove any log4j 1.x dependencies and add the
following.
-->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>2.2</version>
</dependency>


Now, the 1.2 logs which were only going to the console actually flow to our 2.x appenders.






share|improve this answer





















  • 1





    Looks like you already found the answer. Be aware that the log4j:WARN output is produced by a log4j-1.2 jar that is on the classpath. You may want to remove that jar from the classpath, and instead use the log4j-1.2-api-2.1.jar (the 1.2 bridge that is part of log4j2). See also logging.apache.org/log4j/2.x/faq.html#which_jars

    – Remko Popma
    Feb 18 '15 at 1:00











  • Hey, @RemkoPopma I discovered that you contribute to the API. ;-)

    – Paul Vargas
    Feb 18 '15 at 1:47











  • I do my best. Haven't had time recently though... If you feel like helping out, contributions are welcome!

    – Remko Popma
    Feb 18 '15 at 5:46











  • @MaasSql, is this issue resolved now or are your still experiencing issues?

    – Remko Popma
    Feb 19 '15 at 1:51











  • @RemkoPopma, your comments make sense, however, I am very new to Java / Maven, so I don't know how to substitute the bridge api for log4j-1.2.

    – Jeff Maass
    Feb 19 '15 at 19:11



















9














If you don't have the fortune of the log4j-1.2.jar on your classpath as Renko points out in his comment, you will only see the message no log4j2 configuration file found.



This is a problem if there is an error in your configuration file, as you will not be told where the problem lies upon start-up.



For instance if you have a log4j2.yaml file which log4j2 fails to process, because for example, you have not configured a YAML parser for your project, or your config is simply incorrect. You will encounter the no log4j2 configuration file found message, with no further information. This is the case even if you have a valid log4j2.xml file, as log4j2 will only attempt to process the first configuration file it finds.



I've found the best way to debug the problem is to explicitly state the configuration file you wish to use as per the command line argument mentioned above.



-Dlog4j.configurationFile=


Hopefully this will help you pinpoint if the issue is actually caused by your classloader not finding the log4j2 configuration file or something else in your configuration.



Update



You can also use the below property to change the default level of the status logger to get further information:



-Dorg.apache.logging.log4j.simplelog.StatusLogger.level=<level>





share|improve this answer


























  • There is a debug flag, but it is not well documented: - Until a configuration is found, status logger level can be controlled with system property org.apache.logging.log4j.simplelog.StatusLogger.level. - After a configuration is found, status logger level can be controlled in the configuration file with the "status" attribute, for example: <Configuration status="trace">.

    – Remko Popma
    Feb 19 '15 at 3:40











  • @RemkoPopma thanks - I actually tried that flat earlier as per the documentation. However there it's stated as log4j2.StatusLogger.level which doesn't work. The property you mentioned does work.

    – Conor Svensson
    Feb 19 '15 at 7:25













  • Yes the docs are confusing. Partly because the StatusLogger behaviour changes during configuration. I'll improve the docs as proposed here: issues.apache.org/jira/browse/LOG4J2-955

    – Remko Popma
    Feb 19 '15 at 7:29



















4














I use hive jdbc in a java maven project and have the same issues.



My method is to add a log4j2.xml file under src/main/java/resources





import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MyClassName {
private static final Logger LOG = LoggerFactory.getLogger(MyClassName.class);
}


log4j2.xml



<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="<your_package_name>.<your_class_name>" level="debug">
<AppenderRef ref="Console"/>
</Logger>
<Root level="WARN">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>





share|improve this answer

































    2














    i had same problem, but i noticed that i have no log4j2.xml in my project after reading on the net about this problem, so i copied the related code in a notepad and reverted the notepad file to xml and add to my project under the folder resources. it works for me.



    <?xml version="1.0" encoding="UTF-8"?>
    <Configuration status="WARN">
    <Appenders>
    <Console name="Console" target="SYSTEM_OUT">
    <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
    </Appenders>
    <Loggers>
    <Root level="DEBUG">
    <AppenderRef ref="Console"/>
    </Root>
    </Loggers>
    </Configuration>





    share|improve this answer































      1














      In my case I am using the log4j2 Json file log4j2.json in the classpath of my gradle project and I got the same error.



      The solution here was to add dependency for JSON handling to my gradle dependencies.



      compile group:"com.fasterxml.jackson.core", name:"jackson-core", version:'2.8.4'
      compile group:"com.fasterxml.jackson.core", name:"jackson-databind", version:'2.8.4'
      compile group:"com.fasterxml.jackson.core", name:"jackson-annotations", version:'2.8.4'


      See also documentation of log4j2:




      The JSON support uses the Jackson Data Processor to parse the JSON
      files. These dependencies must be added to a project that wants to use
      JSON for configuration:







      share|improve this answer































        1














        I am getting this error because log4j2 file got deleted from my src folder



        Simply add xml file under src folder






        <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
        </Console>

        <RollingFile name="RollingFile" filename="logs/B2CATA-hybrid.log"
        filepattern="${logPath}/%d{yyyyMMddHHmmss}-fargo.log">
        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
        <Policies>
        <SizeBasedTriggeringPolicy size="100 MB" />
        </Policies>
        <DefaultRolloverStrategy max="20" />
        </RollingFile>

        </Appenders>
        <Loggers>
        <Logger name="com.pragiti." level="trace" />
        <Root level="info">
        <AppenderRef ref="Console" />
        <AppenderRef ref="RollingFile" />
        </Root>
        </Loggers>







        share|improve this answer































          0














          Stuffs I check,



          1) Check that there're no oder log4j versions.



          mvn dependency:tree | grep log
          [INFO] +- com.prayagupd:log-service:jar:1.0:compile
          [INFO] +- org.apache.logging.log4j:log4j-api:jar:2.6.2:compile
          [INFO] +- org.apache.logging.log4j:log4j-core:jar:2.6.2:compile
          [INFO] | - commons-logging:commons-logging:jar:1.1.1:compile


          2) make sure I'm setting log4j2.json properly, which is done with -Dlog4j.configurationFile=???



          val logConfig: PropertiesConfiguration = new PropertiesConfiguration("application.properties")
          System.setProperty("log4j.configurationFile", logConfig.getString("log4j.config.file"))
          println("log4j.configurationFile :: " + System.getProperty("log4j.configurationFile"))


          or



          Configurator.initialize(null, logConfig.getString("log4j.config.file"));


          3) Most funny check is for parser for log4j2.json. Thanks log4j team for not providing parser within the API.



          <dependency>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
          <version>2.4.0</version>
          </dependency>


          This might throw an exception if can not find the json parser



          [Fatal Error] log4j2.json:1:1: Content is not allowed in prolog.





          share|improve this answer

































            0














            I have solve this problem by configuring the build path. Here are the steps that I followed:
            In eclipse.




            1. create a folder and save the logj4 file in it.

            2. Write click in the folder created and go to Build path.

            3. Click on Add folder

            4. Choose the folder created.

            5. Click ok and Apply and close.


            Now you should be able to run






            share|improve this answer























              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%2f28572783%2fno-log4j2-configuration-file-found-using-default-configuration-logging-only-er%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              9 Answers
              9






              active

              oldest

              votes








              9 Answers
              9






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2














              I have been dealing with this problem for a while. I have changed everything as described in this post and even thought error occured. In that case make sure that you clean the project when changing settings in .xml or .properties file.
              In eclipse environment. Choose Project -> Clean






              share|improve this answer



















              • 1





                excellent point. In my particular setup, a Maven -> Install does not remove previously created resource files. So, log4j2 config files may hang around even after dependencies have been changed.

                – Jeff Maass
                Dec 1 '16 at 17:23






              • 2





                Below answer is the right answer.. Not this..

                – LPD
                Apr 7 '17 at 13:48






              • 1





                @LPD Please read answer correctly. It has been said that if non of those anwsers are helpfull, problem can be caused by cached files. Note that same problem may have different causes. So there may not be only one solution. As in this case.

                – Phatee P
                Apr 7 '17 at 14:31











              • In my case, I had filtering enabled in my pom file under build/resource. I had to add an include clause for XML files. If anyone is still having this issue, you might want to check that as well.

                – enissay
                Nov 13 '17 at 10:14
















              2














              I have been dealing with this problem for a while. I have changed everything as described in this post and even thought error occured. In that case make sure that you clean the project when changing settings in .xml or .properties file.
              In eclipse environment. Choose Project -> Clean






              share|improve this answer



















              • 1





                excellent point. In my particular setup, a Maven -> Install does not remove previously created resource files. So, log4j2 config files may hang around even after dependencies have been changed.

                – Jeff Maass
                Dec 1 '16 at 17:23






              • 2





                Below answer is the right answer.. Not this..

                – LPD
                Apr 7 '17 at 13:48






              • 1





                @LPD Please read answer correctly. It has been said that if non of those anwsers are helpfull, problem can be caused by cached files. Note that same problem may have different causes. So there may not be only one solution. As in this case.

                – Phatee P
                Apr 7 '17 at 14:31











              • In my case, I had filtering enabled in my pom file under build/resource. I had to add an include clause for XML files. If anyone is still having this issue, you might want to check that as well.

                – enissay
                Nov 13 '17 at 10:14














              2












              2








              2







              I have been dealing with this problem for a while. I have changed everything as described in this post and even thought error occured. In that case make sure that you clean the project when changing settings in .xml or .properties file.
              In eclipse environment. Choose Project -> Clean






              share|improve this answer













              I have been dealing with this problem for a while. I have changed everything as described in this post and even thought error occured. In that case make sure that you clean the project when changing settings in .xml or .properties file.
              In eclipse environment. Choose Project -> Clean







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jul 12 '16 at 10:28









              Phatee PPhatee P

              64411225




              64411225








              • 1





                excellent point. In my particular setup, a Maven -> Install does not remove previously created resource files. So, log4j2 config files may hang around even after dependencies have been changed.

                – Jeff Maass
                Dec 1 '16 at 17:23






              • 2





                Below answer is the right answer.. Not this..

                – LPD
                Apr 7 '17 at 13:48






              • 1





                @LPD Please read answer correctly. It has been said that if non of those anwsers are helpfull, problem can be caused by cached files. Note that same problem may have different causes. So there may not be only one solution. As in this case.

                – Phatee P
                Apr 7 '17 at 14:31











              • In my case, I had filtering enabled in my pom file under build/resource. I had to add an include clause for XML files. If anyone is still having this issue, you might want to check that as well.

                – enissay
                Nov 13 '17 at 10:14














              • 1





                excellent point. In my particular setup, a Maven -> Install does not remove previously created resource files. So, log4j2 config files may hang around even after dependencies have been changed.

                – Jeff Maass
                Dec 1 '16 at 17:23






              • 2





                Below answer is the right answer.. Not this..

                – LPD
                Apr 7 '17 at 13:48






              • 1





                @LPD Please read answer correctly. It has been said that if non of those anwsers are helpfull, problem can be caused by cached files. Note that same problem may have different causes. So there may not be only one solution. As in this case.

                – Phatee P
                Apr 7 '17 at 14:31











              • In my case, I had filtering enabled in my pom file under build/resource. I had to add an include clause for XML files. If anyone is still having this issue, you might want to check that as well.

                – enissay
                Nov 13 '17 at 10:14








              1




              1





              excellent point. In my particular setup, a Maven -> Install does not remove previously created resource files. So, log4j2 config files may hang around even after dependencies have been changed.

              – Jeff Maass
              Dec 1 '16 at 17:23





              excellent point. In my particular setup, a Maven -> Install does not remove previously created resource files. So, log4j2 config files may hang around even after dependencies have been changed.

              – Jeff Maass
              Dec 1 '16 at 17:23




              2




              2





              Below answer is the right answer.. Not this..

              – LPD
              Apr 7 '17 at 13:48





              Below answer is the right answer.. Not this..

              – LPD
              Apr 7 '17 at 13:48




              1




              1





              @LPD Please read answer correctly. It has been said that if non of those anwsers are helpfull, problem can be caused by cached files. Note that same problem may have different causes. So there may not be only one solution. As in this case.

              – Phatee P
              Apr 7 '17 at 14:31





              @LPD Please read answer correctly. It has been said that if non of those anwsers are helpfull, problem can be caused by cached files. Note that same problem may have different causes. So there may not be only one solution. As in this case.

              – Phatee P
              Apr 7 '17 at 14:31













              In my case, I had filtering enabled in my pom file under build/resource. I had to add an include clause for XML files. If anyone is still having this issue, you might want to check that as well.

              – enissay
              Nov 13 '17 at 10:14





              In my case, I had filtering enabled in my pom file under build/resource. I had to add an include clause for XML files. If anyone is still having this issue, you might want to check that as well.

              – enissay
              Nov 13 '17 at 10:14













              47














              Problem 1



              ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.


              Solution 1



              To work with version 2 of log4j aka "log4j2"



              -Dlog4j.configuration=


              should read



              -Dlog4j.configurationFile=



              • 1.2 manual: http://logging.apache.org/log4j/1.2/manual.html

              • 2.x manual: http://logging.apache.org/log4j/2.x/manual/configuration.html


              Problem 2



              log4j:WARN ....


              Solution 2



              In your project, uninclude the log4j-1.2 jar and instead, include the log4j-1.2-api-2.1.jar. I wasn't sure how exactly to exclude the log4j 1.2. I knew that what dependency of my project was requiring it. So, with some reading, I excluded a bunch of stuff.



              <dependency>
              <groupId>org.apache.kafka</groupId>
              <artifactId>kafka_2.10</artifactId>
              <version>0.8.2.0</version>
              <exclusions>
              <exclusion>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              </exclusion>
              <exclusion>
              <groupId>org.apache.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              </exclusion>
              <exclusion>
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
              </exclusion>
              </exclusions>
              </dependency>


              I am not sure which of the exclusions did the trick. Separately, I included a dependency to the 1.2 api which bridges to 2.x.



              <!--
              http://logging.apache.org/log4j/2.0/manual/migration.html
              http://logging.apache.org/log4j/2.0/maven-artifacts.html
              Log4j 1.x API Bridge
              If existing components use Log4j 1.x and you want to have this logging
              routed to Log4j 2, then remove any log4j 1.x dependencies and add the
              following.
              -->
              <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-1.2-api</artifactId>
              <version>2.2</version>
              </dependency>


              Now, the 1.2 logs which were only going to the console actually flow to our 2.x appenders.






              share|improve this answer





















              • 1





                Looks like you already found the answer. Be aware that the log4j:WARN output is produced by a log4j-1.2 jar that is on the classpath. You may want to remove that jar from the classpath, and instead use the log4j-1.2-api-2.1.jar (the 1.2 bridge that is part of log4j2). See also logging.apache.org/log4j/2.x/faq.html#which_jars

                – Remko Popma
                Feb 18 '15 at 1:00











              • Hey, @RemkoPopma I discovered that you contribute to the API. ;-)

                – Paul Vargas
                Feb 18 '15 at 1:47











              • I do my best. Haven't had time recently though... If you feel like helping out, contributions are welcome!

                – Remko Popma
                Feb 18 '15 at 5:46











              • @MaasSql, is this issue resolved now or are your still experiencing issues?

                – Remko Popma
                Feb 19 '15 at 1:51











              • @RemkoPopma, your comments make sense, however, I am very new to Java / Maven, so I don't know how to substitute the bridge api for log4j-1.2.

                – Jeff Maass
                Feb 19 '15 at 19:11
















              47














              Problem 1



              ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.


              Solution 1



              To work with version 2 of log4j aka "log4j2"



              -Dlog4j.configuration=


              should read



              -Dlog4j.configurationFile=



              • 1.2 manual: http://logging.apache.org/log4j/1.2/manual.html

              • 2.x manual: http://logging.apache.org/log4j/2.x/manual/configuration.html


              Problem 2



              log4j:WARN ....


              Solution 2



              In your project, uninclude the log4j-1.2 jar and instead, include the log4j-1.2-api-2.1.jar. I wasn't sure how exactly to exclude the log4j 1.2. I knew that what dependency of my project was requiring it. So, with some reading, I excluded a bunch of stuff.



              <dependency>
              <groupId>org.apache.kafka</groupId>
              <artifactId>kafka_2.10</artifactId>
              <version>0.8.2.0</version>
              <exclusions>
              <exclusion>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              </exclusion>
              <exclusion>
              <groupId>org.apache.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              </exclusion>
              <exclusion>
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
              </exclusion>
              </exclusions>
              </dependency>


              I am not sure which of the exclusions did the trick. Separately, I included a dependency to the 1.2 api which bridges to 2.x.



              <!--
              http://logging.apache.org/log4j/2.0/manual/migration.html
              http://logging.apache.org/log4j/2.0/maven-artifacts.html
              Log4j 1.x API Bridge
              If existing components use Log4j 1.x and you want to have this logging
              routed to Log4j 2, then remove any log4j 1.x dependencies and add the
              following.
              -->
              <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-1.2-api</artifactId>
              <version>2.2</version>
              </dependency>


              Now, the 1.2 logs which were only going to the console actually flow to our 2.x appenders.






              share|improve this answer





















              • 1





                Looks like you already found the answer. Be aware that the log4j:WARN output is produced by a log4j-1.2 jar that is on the classpath. You may want to remove that jar from the classpath, and instead use the log4j-1.2-api-2.1.jar (the 1.2 bridge that is part of log4j2). See also logging.apache.org/log4j/2.x/faq.html#which_jars

                – Remko Popma
                Feb 18 '15 at 1:00











              • Hey, @RemkoPopma I discovered that you contribute to the API. ;-)

                – Paul Vargas
                Feb 18 '15 at 1:47











              • I do my best. Haven't had time recently though... If you feel like helping out, contributions are welcome!

                – Remko Popma
                Feb 18 '15 at 5:46











              • @MaasSql, is this issue resolved now or are your still experiencing issues?

                – Remko Popma
                Feb 19 '15 at 1:51











              • @RemkoPopma, your comments make sense, however, I am very new to Java / Maven, so I don't know how to substitute the bridge api for log4j-1.2.

                – Jeff Maass
                Feb 19 '15 at 19:11














              47












              47








              47







              Problem 1



              ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.


              Solution 1



              To work with version 2 of log4j aka "log4j2"



              -Dlog4j.configuration=


              should read



              -Dlog4j.configurationFile=



              • 1.2 manual: http://logging.apache.org/log4j/1.2/manual.html

              • 2.x manual: http://logging.apache.org/log4j/2.x/manual/configuration.html


              Problem 2



              log4j:WARN ....


              Solution 2



              In your project, uninclude the log4j-1.2 jar and instead, include the log4j-1.2-api-2.1.jar. I wasn't sure how exactly to exclude the log4j 1.2. I knew that what dependency of my project was requiring it. So, with some reading, I excluded a bunch of stuff.



              <dependency>
              <groupId>org.apache.kafka</groupId>
              <artifactId>kafka_2.10</artifactId>
              <version>0.8.2.0</version>
              <exclusions>
              <exclusion>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              </exclusion>
              <exclusion>
              <groupId>org.apache.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              </exclusion>
              <exclusion>
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
              </exclusion>
              </exclusions>
              </dependency>


              I am not sure which of the exclusions did the trick. Separately, I included a dependency to the 1.2 api which bridges to 2.x.



              <!--
              http://logging.apache.org/log4j/2.0/manual/migration.html
              http://logging.apache.org/log4j/2.0/maven-artifacts.html
              Log4j 1.x API Bridge
              If existing components use Log4j 1.x and you want to have this logging
              routed to Log4j 2, then remove any log4j 1.x dependencies and add the
              following.
              -->
              <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-1.2-api</artifactId>
              <version>2.2</version>
              </dependency>


              Now, the 1.2 logs which were only going to the console actually flow to our 2.x appenders.






              share|improve this answer















              Problem 1



              ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.


              Solution 1



              To work with version 2 of log4j aka "log4j2"



              -Dlog4j.configuration=


              should read



              -Dlog4j.configurationFile=



              • 1.2 manual: http://logging.apache.org/log4j/1.2/manual.html

              • 2.x manual: http://logging.apache.org/log4j/2.x/manual/configuration.html


              Problem 2



              log4j:WARN ....


              Solution 2



              In your project, uninclude the log4j-1.2 jar and instead, include the log4j-1.2-api-2.1.jar. I wasn't sure how exactly to exclude the log4j 1.2. I knew that what dependency of my project was requiring it. So, with some reading, I excluded a bunch of stuff.



              <dependency>
              <groupId>org.apache.kafka</groupId>
              <artifactId>kafka_2.10</artifactId>
              <version>0.8.2.0</version>
              <exclusions>
              <exclusion>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              </exclusion>
              <exclusion>
              <groupId>org.apache.log4j</groupId>
              <artifactId>log4j-core</artifactId>
              </exclusion>
              <exclusion>
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
              </exclusion>
              </exclusions>
              </dependency>


              I am not sure which of the exclusions did the trick. Separately, I included a dependency to the 1.2 api which bridges to 2.x.



              <!--
              http://logging.apache.org/log4j/2.0/manual/migration.html
              http://logging.apache.org/log4j/2.0/maven-artifacts.html
              Log4j 1.x API Bridge
              If existing components use Log4j 1.x and you want to have this logging
              routed to Log4j 2, then remove any log4j 1.x dependencies and add the
              following.
              -->
              <dependency>
              <groupId>org.apache.logging.log4j</groupId>
              <artifactId>log4j-1.2-api</artifactId>
              <version>2.2</version>
              </dependency>


              Now, the 1.2 logs which were only going to the console actually flow to our 2.x appenders.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Nov 11 '15 at 18:18









              Mr. Polywhirl

              16.5k84886




              16.5k84886










              answered Feb 17 '15 at 22:57









              Jeff MaassJeff Maass

              2,07411726




              2,07411726








              • 1





                Looks like you already found the answer. Be aware that the log4j:WARN output is produced by a log4j-1.2 jar that is on the classpath. You may want to remove that jar from the classpath, and instead use the log4j-1.2-api-2.1.jar (the 1.2 bridge that is part of log4j2). See also logging.apache.org/log4j/2.x/faq.html#which_jars

                – Remko Popma
                Feb 18 '15 at 1:00











              • Hey, @RemkoPopma I discovered that you contribute to the API. ;-)

                – Paul Vargas
                Feb 18 '15 at 1:47











              • I do my best. Haven't had time recently though... If you feel like helping out, contributions are welcome!

                – Remko Popma
                Feb 18 '15 at 5:46











              • @MaasSql, is this issue resolved now or are your still experiencing issues?

                – Remko Popma
                Feb 19 '15 at 1:51











              • @RemkoPopma, your comments make sense, however, I am very new to Java / Maven, so I don't know how to substitute the bridge api for log4j-1.2.

                – Jeff Maass
                Feb 19 '15 at 19:11














              • 1





                Looks like you already found the answer. Be aware that the log4j:WARN output is produced by a log4j-1.2 jar that is on the classpath. You may want to remove that jar from the classpath, and instead use the log4j-1.2-api-2.1.jar (the 1.2 bridge that is part of log4j2). See also logging.apache.org/log4j/2.x/faq.html#which_jars

                – Remko Popma
                Feb 18 '15 at 1:00











              • Hey, @RemkoPopma I discovered that you contribute to the API. ;-)

                – Paul Vargas
                Feb 18 '15 at 1:47











              • I do my best. Haven't had time recently though... If you feel like helping out, contributions are welcome!

                – Remko Popma
                Feb 18 '15 at 5:46











              • @MaasSql, is this issue resolved now or are your still experiencing issues?

                – Remko Popma
                Feb 19 '15 at 1:51











              • @RemkoPopma, your comments make sense, however, I am very new to Java / Maven, so I don't know how to substitute the bridge api for log4j-1.2.

                – Jeff Maass
                Feb 19 '15 at 19:11








              1




              1





              Looks like you already found the answer. Be aware that the log4j:WARN output is produced by a log4j-1.2 jar that is on the classpath. You may want to remove that jar from the classpath, and instead use the log4j-1.2-api-2.1.jar (the 1.2 bridge that is part of log4j2). See also logging.apache.org/log4j/2.x/faq.html#which_jars

              – Remko Popma
              Feb 18 '15 at 1:00





              Looks like you already found the answer. Be aware that the log4j:WARN output is produced by a log4j-1.2 jar that is on the classpath. You may want to remove that jar from the classpath, and instead use the log4j-1.2-api-2.1.jar (the 1.2 bridge that is part of log4j2). See also logging.apache.org/log4j/2.x/faq.html#which_jars

              – Remko Popma
              Feb 18 '15 at 1:00













              Hey, @RemkoPopma I discovered that you contribute to the API. ;-)

              – Paul Vargas
              Feb 18 '15 at 1:47





              Hey, @RemkoPopma I discovered that you contribute to the API. ;-)

              – Paul Vargas
              Feb 18 '15 at 1:47













              I do my best. Haven't had time recently though... If you feel like helping out, contributions are welcome!

              – Remko Popma
              Feb 18 '15 at 5:46





              I do my best. Haven't had time recently though... If you feel like helping out, contributions are welcome!

              – Remko Popma
              Feb 18 '15 at 5:46













              @MaasSql, is this issue resolved now or are your still experiencing issues?

              – Remko Popma
              Feb 19 '15 at 1:51





              @MaasSql, is this issue resolved now or are your still experiencing issues?

              – Remko Popma
              Feb 19 '15 at 1:51













              @RemkoPopma, your comments make sense, however, I am very new to Java / Maven, so I don't know how to substitute the bridge api for log4j-1.2.

              – Jeff Maass
              Feb 19 '15 at 19:11





              @RemkoPopma, your comments make sense, however, I am very new to Java / Maven, so I don't know how to substitute the bridge api for log4j-1.2.

              – Jeff Maass
              Feb 19 '15 at 19:11











              9














              If you don't have the fortune of the log4j-1.2.jar on your classpath as Renko points out in his comment, you will only see the message no log4j2 configuration file found.



              This is a problem if there is an error in your configuration file, as you will not be told where the problem lies upon start-up.



              For instance if you have a log4j2.yaml file which log4j2 fails to process, because for example, you have not configured a YAML parser for your project, or your config is simply incorrect. You will encounter the no log4j2 configuration file found message, with no further information. This is the case even if you have a valid log4j2.xml file, as log4j2 will only attempt to process the first configuration file it finds.



              I've found the best way to debug the problem is to explicitly state the configuration file you wish to use as per the command line argument mentioned above.



              -Dlog4j.configurationFile=


              Hopefully this will help you pinpoint if the issue is actually caused by your classloader not finding the log4j2 configuration file or something else in your configuration.



              Update



              You can also use the below property to change the default level of the status logger to get further information:



              -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=<level>





              share|improve this answer


























              • There is a debug flag, but it is not well documented: - Until a configuration is found, status logger level can be controlled with system property org.apache.logging.log4j.simplelog.StatusLogger.level. - After a configuration is found, status logger level can be controlled in the configuration file with the "status" attribute, for example: <Configuration status="trace">.

                – Remko Popma
                Feb 19 '15 at 3:40











              • @RemkoPopma thanks - I actually tried that flat earlier as per the documentation. However there it's stated as log4j2.StatusLogger.level which doesn't work. The property you mentioned does work.

                – Conor Svensson
                Feb 19 '15 at 7:25













              • Yes the docs are confusing. Partly because the StatusLogger behaviour changes during configuration. I'll improve the docs as proposed here: issues.apache.org/jira/browse/LOG4J2-955

                – Remko Popma
                Feb 19 '15 at 7:29
















              9














              If you don't have the fortune of the log4j-1.2.jar on your classpath as Renko points out in his comment, you will only see the message no log4j2 configuration file found.



              This is a problem if there is an error in your configuration file, as you will not be told where the problem lies upon start-up.



              For instance if you have a log4j2.yaml file which log4j2 fails to process, because for example, you have not configured a YAML parser for your project, or your config is simply incorrect. You will encounter the no log4j2 configuration file found message, with no further information. This is the case even if you have a valid log4j2.xml file, as log4j2 will only attempt to process the first configuration file it finds.



              I've found the best way to debug the problem is to explicitly state the configuration file you wish to use as per the command line argument mentioned above.



              -Dlog4j.configurationFile=


              Hopefully this will help you pinpoint if the issue is actually caused by your classloader not finding the log4j2 configuration file or something else in your configuration.



              Update



              You can also use the below property to change the default level of the status logger to get further information:



              -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=<level>





              share|improve this answer


























              • There is a debug flag, but it is not well documented: - Until a configuration is found, status logger level can be controlled with system property org.apache.logging.log4j.simplelog.StatusLogger.level. - After a configuration is found, status logger level can be controlled in the configuration file with the "status" attribute, for example: <Configuration status="trace">.

                – Remko Popma
                Feb 19 '15 at 3:40











              • @RemkoPopma thanks - I actually tried that flat earlier as per the documentation. However there it's stated as log4j2.StatusLogger.level which doesn't work. The property you mentioned does work.

                – Conor Svensson
                Feb 19 '15 at 7:25













              • Yes the docs are confusing. Partly because the StatusLogger behaviour changes during configuration. I'll improve the docs as proposed here: issues.apache.org/jira/browse/LOG4J2-955

                – Remko Popma
                Feb 19 '15 at 7:29














              9












              9








              9







              If you don't have the fortune of the log4j-1.2.jar on your classpath as Renko points out in his comment, you will only see the message no log4j2 configuration file found.



              This is a problem if there is an error in your configuration file, as you will not be told where the problem lies upon start-up.



              For instance if you have a log4j2.yaml file which log4j2 fails to process, because for example, you have not configured a YAML parser for your project, or your config is simply incorrect. You will encounter the no log4j2 configuration file found message, with no further information. This is the case even if you have a valid log4j2.xml file, as log4j2 will only attempt to process the first configuration file it finds.



              I've found the best way to debug the problem is to explicitly state the configuration file you wish to use as per the command line argument mentioned above.



              -Dlog4j.configurationFile=


              Hopefully this will help you pinpoint if the issue is actually caused by your classloader not finding the log4j2 configuration file or something else in your configuration.



              Update



              You can also use the below property to change the default level of the status logger to get further information:



              -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=<level>





              share|improve this answer















              If you don't have the fortune of the log4j-1.2.jar on your classpath as Renko points out in his comment, you will only see the message no log4j2 configuration file found.



              This is a problem if there is an error in your configuration file, as you will not be told where the problem lies upon start-up.



              For instance if you have a log4j2.yaml file which log4j2 fails to process, because for example, you have not configured a YAML parser for your project, or your config is simply incorrect. You will encounter the no log4j2 configuration file found message, with no further information. This is the case even if you have a valid log4j2.xml file, as log4j2 will only attempt to process the first configuration file it finds.



              I've found the best way to debug the problem is to explicitly state the configuration file you wish to use as per the command line argument mentioned above.



              -Dlog4j.configurationFile=


              Hopefully this will help you pinpoint if the issue is actually caused by your classloader not finding the log4j2 configuration file or something else in your configuration.



              Update



              You can also use the below property to change the default level of the status logger to get further information:



              -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=<level>






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited May 23 '17 at 12:18









              Community

              11




              11










              answered Feb 18 '15 at 23:15









              Conor SvenssonConor Svensson

              768813




              768813













              • There is a debug flag, but it is not well documented: - Until a configuration is found, status logger level can be controlled with system property org.apache.logging.log4j.simplelog.StatusLogger.level. - After a configuration is found, status logger level can be controlled in the configuration file with the "status" attribute, for example: <Configuration status="trace">.

                – Remko Popma
                Feb 19 '15 at 3:40











              • @RemkoPopma thanks - I actually tried that flat earlier as per the documentation. However there it's stated as log4j2.StatusLogger.level which doesn't work. The property you mentioned does work.

                – Conor Svensson
                Feb 19 '15 at 7:25













              • Yes the docs are confusing. Partly because the StatusLogger behaviour changes during configuration. I'll improve the docs as proposed here: issues.apache.org/jira/browse/LOG4J2-955

                – Remko Popma
                Feb 19 '15 at 7:29



















              • There is a debug flag, but it is not well documented: - Until a configuration is found, status logger level can be controlled with system property org.apache.logging.log4j.simplelog.StatusLogger.level. - After a configuration is found, status logger level can be controlled in the configuration file with the "status" attribute, for example: <Configuration status="trace">.

                – Remko Popma
                Feb 19 '15 at 3:40











              • @RemkoPopma thanks - I actually tried that flat earlier as per the documentation. However there it's stated as log4j2.StatusLogger.level which doesn't work. The property you mentioned does work.

                – Conor Svensson
                Feb 19 '15 at 7:25













              • Yes the docs are confusing. Partly because the StatusLogger behaviour changes during configuration. I'll improve the docs as proposed here: issues.apache.org/jira/browse/LOG4J2-955

                – Remko Popma
                Feb 19 '15 at 7:29

















              There is a debug flag, but it is not well documented: - Until a configuration is found, status logger level can be controlled with system property org.apache.logging.log4j.simplelog.StatusLogger.level. - After a configuration is found, status logger level can be controlled in the configuration file with the "status" attribute, for example: <Configuration status="trace">.

              – Remko Popma
              Feb 19 '15 at 3:40





              There is a debug flag, but it is not well documented: - Until a configuration is found, status logger level can be controlled with system property org.apache.logging.log4j.simplelog.StatusLogger.level. - After a configuration is found, status logger level can be controlled in the configuration file with the "status" attribute, for example: <Configuration status="trace">.

              – Remko Popma
              Feb 19 '15 at 3:40













              @RemkoPopma thanks - I actually tried that flat earlier as per the documentation. However there it's stated as log4j2.StatusLogger.level which doesn't work. The property you mentioned does work.

              – Conor Svensson
              Feb 19 '15 at 7:25







              @RemkoPopma thanks - I actually tried that flat earlier as per the documentation. However there it's stated as log4j2.StatusLogger.level which doesn't work. The property you mentioned does work.

              – Conor Svensson
              Feb 19 '15 at 7:25















              Yes the docs are confusing. Partly because the StatusLogger behaviour changes during configuration. I'll improve the docs as proposed here: issues.apache.org/jira/browse/LOG4J2-955

              – Remko Popma
              Feb 19 '15 at 7:29





              Yes the docs are confusing. Partly because the StatusLogger behaviour changes during configuration. I'll improve the docs as proposed here: issues.apache.org/jira/browse/LOG4J2-955

              – Remko Popma
              Feb 19 '15 at 7:29











              4














              I use hive jdbc in a java maven project and have the same issues.



              My method is to add a log4j2.xml file under src/main/java/resources





              import org.slf4j.Logger;
              import org.slf4j.LoggerFactory;

              public class MyClassName {
              private static final Logger LOG = LoggerFactory.getLogger(MyClassName.class);
              }


              log4j2.xml



              <?xml version="1.0" encoding="UTF-8"?>
              <Configuration status="WARN">
              <Appenders>
              <Console name="Console" target="SYSTEM_OUT">
              <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
              </Console>
              </Appenders>
              <Loggers>
              <Logger name="<your_package_name>.<your_class_name>" level="debug">
              <AppenderRef ref="Console"/>
              </Logger>
              <Root level="WARN">
              <AppenderRef ref="Console"/>
              </Root>
              </Loggers>
              </Configuration>





              share|improve this answer






























                4














                I use hive jdbc in a java maven project and have the same issues.



                My method is to add a log4j2.xml file under src/main/java/resources





                import org.slf4j.Logger;
                import org.slf4j.LoggerFactory;

                public class MyClassName {
                private static final Logger LOG = LoggerFactory.getLogger(MyClassName.class);
                }


                log4j2.xml



                <?xml version="1.0" encoding="UTF-8"?>
                <Configuration status="WARN">
                <Appenders>
                <Console name="Console" target="SYSTEM_OUT">
                <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
                </Console>
                </Appenders>
                <Loggers>
                <Logger name="<your_package_name>.<your_class_name>" level="debug">
                <AppenderRef ref="Console"/>
                </Logger>
                <Root level="WARN">
                <AppenderRef ref="Console"/>
                </Root>
                </Loggers>
                </Configuration>





                share|improve this answer




























                  4












                  4








                  4







                  I use hive jdbc in a java maven project and have the same issues.



                  My method is to add a log4j2.xml file under src/main/java/resources





                  import org.slf4j.Logger;
                  import org.slf4j.LoggerFactory;

                  public class MyClassName {
                  private static final Logger LOG = LoggerFactory.getLogger(MyClassName.class);
                  }


                  log4j2.xml



                  <?xml version="1.0" encoding="UTF-8"?>
                  <Configuration status="WARN">
                  <Appenders>
                  <Console name="Console" target="SYSTEM_OUT">
                  <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
                  </Console>
                  </Appenders>
                  <Loggers>
                  <Logger name="<your_package_name>.<your_class_name>" level="debug">
                  <AppenderRef ref="Console"/>
                  </Logger>
                  <Root level="WARN">
                  <AppenderRef ref="Console"/>
                  </Root>
                  </Loggers>
                  </Configuration>





                  share|improve this answer















                  I use hive jdbc in a java maven project and have the same issues.



                  My method is to add a log4j2.xml file under src/main/java/resources





                  import org.slf4j.Logger;
                  import org.slf4j.LoggerFactory;

                  public class MyClassName {
                  private static final Logger LOG = LoggerFactory.getLogger(MyClassName.class);
                  }


                  log4j2.xml



                  <?xml version="1.0" encoding="UTF-8"?>
                  <Configuration status="WARN">
                  <Appenders>
                  <Console name="Console" target="SYSTEM_OUT">
                  <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
                  </Console>
                  </Appenders>
                  <Loggers>
                  <Logger name="<your_package_name>.<your_class_name>" level="debug">
                  <AppenderRef ref="Console"/>
                  </Logger>
                  <Root level="WARN">
                  <AppenderRef ref="Console"/>
                  </Root>
                  </Loggers>
                  </Configuration>






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Feb 22 '18 at 23:33

























                  answered Feb 15 '18 at 18:08









                  LuQQiuLuQQiu

                  493




                  493























                      2














                      i had same problem, but i noticed that i have no log4j2.xml in my project after reading on the net about this problem, so i copied the related code in a notepad and reverted the notepad file to xml and add to my project under the folder resources. it works for me.



                      <?xml version="1.0" encoding="UTF-8"?>
                      <Configuration status="WARN">
                      <Appenders>
                      <Console name="Console" target="SYSTEM_OUT">
                      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
                      </Console>
                      </Appenders>
                      <Loggers>
                      <Root level="DEBUG">
                      <AppenderRef ref="Console"/>
                      </Root>
                      </Loggers>
                      </Configuration>





                      share|improve this answer




























                        2














                        i had same problem, but i noticed that i have no log4j2.xml in my project after reading on the net about this problem, so i copied the related code in a notepad and reverted the notepad file to xml and add to my project under the folder resources. it works for me.



                        <?xml version="1.0" encoding="UTF-8"?>
                        <Configuration status="WARN">
                        <Appenders>
                        <Console name="Console" target="SYSTEM_OUT">
                        <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
                        </Console>
                        </Appenders>
                        <Loggers>
                        <Root level="DEBUG">
                        <AppenderRef ref="Console"/>
                        </Root>
                        </Loggers>
                        </Configuration>





                        share|improve this answer


























                          2












                          2








                          2







                          i had same problem, but i noticed that i have no log4j2.xml in my project after reading on the net about this problem, so i copied the related code in a notepad and reverted the notepad file to xml and add to my project under the folder resources. it works for me.



                          <?xml version="1.0" encoding="UTF-8"?>
                          <Configuration status="WARN">
                          <Appenders>
                          <Console name="Console" target="SYSTEM_OUT">
                          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
                          </Console>
                          </Appenders>
                          <Loggers>
                          <Root level="DEBUG">
                          <AppenderRef ref="Console"/>
                          </Root>
                          </Loggers>
                          </Configuration>





                          share|improve this answer













                          i had same problem, but i noticed that i have no log4j2.xml in my project after reading on the net about this problem, so i copied the related code in a notepad and reverted the notepad file to xml and add to my project under the folder resources. it works for me.



                          <?xml version="1.0" encoding="UTF-8"?>
                          <Configuration status="WARN">
                          <Appenders>
                          <Console name="Console" target="SYSTEM_OUT">
                          <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
                          </Console>
                          </Appenders>
                          <Loggers>
                          <Root level="DEBUG">
                          <AppenderRef ref="Console"/>
                          </Root>
                          </Loggers>
                          </Configuration>






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Aug 3 '18 at 12:19









                          kykbrkykbr

                          8719




                          8719























                              1














                              In my case I am using the log4j2 Json file log4j2.json in the classpath of my gradle project and I got the same error.



                              The solution here was to add dependency for JSON handling to my gradle dependencies.



                              compile group:"com.fasterxml.jackson.core", name:"jackson-core", version:'2.8.4'
                              compile group:"com.fasterxml.jackson.core", name:"jackson-databind", version:'2.8.4'
                              compile group:"com.fasterxml.jackson.core", name:"jackson-annotations", version:'2.8.4'


                              See also documentation of log4j2:




                              The JSON support uses the Jackson Data Processor to parse the JSON
                              files. These dependencies must be added to a project that wants to use
                              JSON for configuration:







                              share|improve this answer




























                                1














                                In my case I am using the log4j2 Json file log4j2.json in the classpath of my gradle project and I got the same error.



                                The solution here was to add dependency for JSON handling to my gradle dependencies.



                                compile group:"com.fasterxml.jackson.core", name:"jackson-core", version:'2.8.4'
                                compile group:"com.fasterxml.jackson.core", name:"jackson-databind", version:'2.8.4'
                                compile group:"com.fasterxml.jackson.core", name:"jackson-annotations", version:'2.8.4'


                                See also documentation of log4j2:




                                The JSON support uses the Jackson Data Processor to parse the JSON
                                files. These dependencies must be added to a project that wants to use
                                JSON for configuration:







                                share|improve this answer


























                                  1












                                  1








                                  1







                                  In my case I am using the log4j2 Json file log4j2.json in the classpath of my gradle project and I got the same error.



                                  The solution here was to add dependency for JSON handling to my gradle dependencies.



                                  compile group:"com.fasterxml.jackson.core", name:"jackson-core", version:'2.8.4'
                                  compile group:"com.fasterxml.jackson.core", name:"jackson-databind", version:'2.8.4'
                                  compile group:"com.fasterxml.jackson.core", name:"jackson-annotations", version:'2.8.4'


                                  See also documentation of log4j2:




                                  The JSON support uses the Jackson Data Processor to parse the JSON
                                  files. These dependencies must be added to a project that wants to use
                                  JSON for configuration:







                                  share|improve this answer













                                  In my case I am using the log4j2 Json file log4j2.json in the classpath of my gradle project and I got the same error.



                                  The solution here was to add dependency for JSON handling to my gradle dependencies.



                                  compile group:"com.fasterxml.jackson.core", name:"jackson-core", version:'2.8.4'
                                  compile group:"com.fasterxml.jackson.core", name:"jackson-databind", version:'2.8.4'
                                  compile group:"com.fasterxml.jackson.core", name:"jackson-annotations", version:'2.8.4'


                                  See also documentation of log4j2:




                                  The JSON support uses the Jackson Data Processor to parse the JSON
                                  files. These dependencies must be added to a project that wants to use
                                  JSON for configuration:








                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Nov 4 '16 at 11:38









                                  HIGH6HIGH6

                                  18.2k95867




                                  18.2k95867























                                      1














                                      I am getting this error because log4j2 file got deleted from my src folder



                                      Simply add xml file under src folder






                                      <Appenders>
                                      <Console name="Console" target="SYSTEM_OUT">
                                      <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
                                      </Console>

                                      <RollingFile name="RollingFile" filename="logs/B2CATA-hybrid.log"
                                      filepattern="${logPath}/%d{yyyyMMddHHmmss}-fargo.log">
                                      <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
                                      <Policies>
                                      <SizeBasedTriggeringPolicy size="100 MB" />
                                      </Policies>
                                      <DefaultRolloverStrategy max="20" />
                                      </RollingFile>

                                      </Appenders>
                                      <Loggers>
                                      <Logger name="com.pragiti." level="trace" />
                                      <Root level="info">
                                      <AppenderRef ref="Console" />
                                      <AppenderRef ref="RollingFile" />
                                      </Root>
                                      </Loggers>







                                      share|improve this answer




























                                        1














                                        I am getting this error because log4j2 file got deleted from my src folder



                                        Simply add xml file under src folder






                                        <Appenders>
                                        <Console name="Console" target="SYSTEM_OUT">
                                        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
                                        </Console>

                                        <RollingFile name="RollingFile" filename="logs/B2CATA-hybrid.log"
                                        filepattern="${logPath}/%d{yyyyMMddHHmmss}-fargo.log">
                                        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
                                        <Policies>
                                        <SizeBasedTriggeringPolicy size="100 MB" />
                                        </Policies>
                                        <DefaultRolloverStrategy max="20" />
                                        </RollingFile>

                                        </Appenders>
                                        <Loggers>
                                        <Logger name="com.pragiti." level="trace" />
                                        <Root level="info">
                                        <AppenderRef ref="Console" />
                                        <AppenderRef ref="RollingFile" />
                                        </Root>
                                        </Loggers>







                                        share|improve this answer


























                                          1












                                          1








                                          1







                                          I am getting this error because log4j2 file got deleted from my src folder



                                          Simply add xml file under src folder






                                          <Appenders>
                                          <Console name="Console" target="SYSTEM_OUT">
                                          <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
                                          </Console>

                                          <RollingFile name="RollingFile" filename="logs/B2CATA-hybrid.log"
                                          filepattern="${logPath}/%d{yyyyMMddHHmmss}-fargo.log">
                                          <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
                                          <Policies>
                                          <SizeBasedTriggeringPolicy size="100 MB" />
                                          </Policies>
                                          <DefaultRolloverStrategy max="20" />
                                          </RollingFile>

                                          </Appenders>
                                          <Loggers>
                                          <Logger name="com.pragiti." level="trace" />
                                          <Root level="info">
                                          <AppenderRef ref="Console" />
                                          <AppenderRef ref="RollingFile" />
                                          </Root>
                                          </Loggers>







                                          share|improve this answer













                                          I am getting this error because log4j2 file got deleted from my src folder



                                          Simply add xml file under src folder






                                          <Appenders>
                                          <Console name="Console" target="SYSTEM_OUT">
                                          <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
                                          </Console>

                                          <RollingFile name="RollingFile" filename="logs/B2CATA-hybrid.log"
                                          filepattern="${logPath}/%d{yyyyMMddHHmmss}-fargo.log">
                                          <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
                                          <Policies>
                                          <SizeBasedTriggeringPolicy size="100 MB" />
                                          </Policies>
                                          <DefaultRolloverStrategy max="20" />
                                          </RollingFile>

                                          </Appenders>
                                          <Loggers>
                                          <Logger name="com.pragiti." level="trace" />
                                          <Root level="info">
                                          <AppenderRef ref="Console" />
                                          <AppenderRef ref="RollingFile" />
                                          </Root>
                                          </Loggers>








                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered May 9 '18 at 12:23









                                          komal sarodekomal sarode

                                          111




                                          111























                                              0














                                              Stuffs I check,



                                              1) Check that there're no oder log4j versions.



                                              mvn dependency:tree | grep log
                                              [INFO] +- com.prayagupd:log-service:jar:1.0:compile
                                              [INFO] +- org.apache.logging.log4j:log4j-api:jar:2.6.2:compile
                                              [INFO] +- org.apache.logging.log4j:log4j-core:jar:2.6.2:compile
                                              [INFO] | - commons-logging:commons-logging:jar:1.1.1:compile


                                              2) make sure I'm setting log4j2.json properly, which is done with -Dlog4j.configurationFile=???



                                              val logConfig: PropertiesConfiguration = new PropertiesConfiguration("application.properties")
                                              System.setProperty("log4j.configurationFile", logConfig.getString("log4j.config.file"))
                                              println("log4j.configurationFile :: " + System.getProperty("log4j.configurationFile"))


                                              or



                                              Configurator.initialize(null, logConfig.getString("log4j.config.file"));


                                              3) Most funny check is for parser for log4j2.json. Thanks log4j team for not providing parser within the API.



                                              <dependency>
                                              <groupId>com.fasterxml.jackson.core</groupId>
                                              <artifactId>jackson-databind</artifactId>
                                              <version>2.4.0</version>
                                              </dependency>


                                              This might throw an exception if can not find the json parser



                                              [Fatal Error] log4j2.json:1:1: Content is not allowed in prolog.





                                              share|improve this answer






























                                                0














                                                Stuffs I check,



                                                1) Check that there're no oder log4j versions.



                                                mvn dependency:tree | grep log
                                                [INFO] +- com.prayagupd:log-service:jar:1.0:compile
                                                [INFO] +- org.apache.logging.log4j:log4j-api:jar:2.6.2:compile
                                                [INFO] +- org.apache.logging.log4j:log4j-core:jar:2.6.2:compile
                                                [INFO] | - commons-logging:commons-logging:jar:1.1.1:compile


                                                2) make sure I'm setting log4j2.json properly, which is done with -Dlog4j.configurationFile=???



                                                val logConfig: PropertiesConfiguration = new PropertiesConfiguration("application.properties")
                                                System.setProperty("log4j.configurationFile", logConfig.getString("log4j.config.file"))
                                                println("log4j.configurationFile :: " + System.getProperty("log4j.configurationFile"))


                                                or



                                                Configurator.initialize(null, logConfig.getString("log4j.config.file"));


                                                3) Most funny check is for parser for log4j2.json. Thanks log4j team for not providing parser within the API.



                                                <dependency>
                                                <groupId>com.fasterxml.jackson.core</groupId>
                                                <artifactId>jackson-databind</artifactId>
                                                <version>2.4.0</version>
                                                </dependency>


                                                This might throw an exception if can not find the json parser



                                                [Fatal Error] log4j2.json:1:1: Content is not allowed in prolog.





                                                share|improve this answer




























                                                  0












                                                  0








                                                  0







                                                  Stuffs I check,



                                                  1) Check that there're no oder log4j versions.



                                                  mvn dependency:tree | grep log
                                                  [INFO] +- com.prayagupd:log-service:jar:1.0:compile
                                                  [INFO] +- org.apache.logging.log4j:log4j-api:jar:2.6.2:compile
                                                  [INFO] +- org.apache.logging.log4j:log4j-core:jar:2.6.2:compile
                                                  [INFO] | - commons-logging:commons-logging:jar:1.1.1:compile


                                                  2) make sure I'm setting log4j2.json properly, which is done with -Dlog4j.configurationFile=???



                                                  val logConfig: PropertiesConfiguration = new PropertiesConfiguration("application.properties")
                                                  System.setProperty("log4j.configurationFile", logConfig.getString("log4j.config.file"))
                                                  println("log4j.configurationFile :: " + System.getProperty("log4j.configurationFile"))


                                                  or



                                                  Configurator.initialize(null, logConfig.getString("log4j.config.file"));


                                                  3) Most funny check is for parser for log4j2.json. Thanks log4j team for not providing parser within the API.



                                                  <dependency>
                                                  <groupId>com.fasterxml.jackson.core</groupId>
                                                  <artifactId>jackson-databind</artifactId>
                                                  <version>2.4.0</version>
                                                  </dependency>


                                                  This might throw an exception if can not find the json parser



                                                  [Fatal Error] log4j2.json:1:1: Content is not allowed in prolog.





                                                  share|improve this answer















                                                  Stuffs I check,



                                                  1) Check that there're no oder log4j versions.



                                                  mvn dependency:tree | grep log
                                                  [INFO] +- com.prayagupd:log-service:jar:1.0:compile
                                                  [INFO] +- org.apache.logging.log4j:log4j-api:jar:2.6.2:compile
                                                  [INFO] +- org.apache.logging.log4j:log4j-core:jar:2.6.2:compile
                                                  [INFO] | - commons-logging:commons-logging:jar:1.1.1:compile


                                                  2) make sure I'm setting log4j2.json properly, which is done with -Dlog4j.configurationFile=???



                                                  val logConfig: PropertiesConfiguration = new PropertiesConfiguration("application.properties")
                                                  System.setProperty("log4j.configurationFile", logConfig.getString("log4j.config.file"))
                                                  println("log4j.configurationFile :: " + System.getProperty("log4j.configurationFile"))


                                                  or



                                                  Configurator.initialize(null, logConfig.getString("log4j.config.file"));


                                                  3) Most funny check is for parser for log4j2.json. Thanks log4j team for not providing parser within the API.



                                                  <dependency>
                                                  <groupId>com.fasterxml.jackson.core</groupId>
                                                  <artifactId>jackson-databind</artifactId>
                                                  <version>2.4.0</version>
                                                  </dependency>


                                                  This might throw an exception if can not find the json parser



                                                  [Fatal Error] log4j2.json:1:1: Content is not allowed in prolog.






                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited Nov 25 '16 at 18:30

























                                                  answered Nov 21 '16 at 7:58









                                                  prayagupdprayagupd

                                                  19.7k890138




                                                  19.7k890138























                                                      0














                                                      I have solve this problem by configuring the build path. Here are the steps that I followed:
                                                      In eclipse.




                                                      1. create a folder and save the logj4 file in it.

                                                      2. Write click in the folder created and go to Build path.

                                                      3. Click on Add folder

                                                      4. Choose the folder created.

                                                      5. Click ok and Apply and close.


                                                      Now you should be able to run






                                                      share|improve this answer




























                                                        0














                                                        I have solve this problem by configuring the build path. Here are the steps that I followed:
                                                        In eclipse.




                                                        1. create a folder and save the logj4 file in it.

                                                        2. Write click in the folder created and go to Build path.

                                                        3. Click on Add folder

                                                        4. Choose the folder created.

                                                        5. Click ok and Apply and close.


                                                        Now you should be able to run






                                                        share|improve this answer


























                                                          0












                                                          0








                                                          0







                                                          I have solve this problem by configuring the build path. Here are the steps that I followed:
                                                          In eclipse.




                                                          1. create a folder and save the logj4 file in it.

                                                          2. Write click in the folder created and go to Build path.

                                                          3. Click on Add folder

                                                          4. Choose the folder created.

                                                          5. Click ok and Apply and close.


                                                          Now you should be able to run






                                                          share|improve this answer













                                                          I have solve this problem by configuring the build path. Here are the steps that I followed:
                                                          In eclipse.




                                                          1. create a folder and save the logj4 file in it.

                                                          2. Write click in the folder created and go to Build path.

                                                          3. Click on Add folder

                                                          4. Choose the folder created.

                                                          5. Click ok and Apply and close.


                                                          Now you should be able to run







                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered Dec 6 '17 at 10:20









                                                          Alex SantosAlex Santos

                                                          93




                                                          93






























                                                              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%2f28572783%2fno-log4j2-configuration-file-found-using-default-configuration-logging-only-er%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

                                                              To store a contact into the json file from server.js file using a class in NodeJS

                                                              Redirect URL with Chrome Remote Debugging Android Devices

                                                              Dieringhausen