<commit_before><?xml version="1.0"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<document>
    <properties>
        <title>Configuring Log4j2</title>
        <author email="<EMAIL>"><NAME></author>
    </properties>

    <body>
      <section name="Configuration">
        <p>Inserting log requests into the application code requires a fair
          amount of planning and effort. Observation shows that approximately 4
          percent of code is dedicated to logging. Consequently, even moderately
          sized applications will have thousands of logging statements embedded
          within their code.  Given their number, it becomes imperative to
          manage these log statements without the need to modify them manually.
        </p>
        <p>
          Configuration of Log4j2 can be accomplished in 1 of 4 ways:
          <ol>
            <li>Through a configuration file written in XML or JSON.</li>
            <li>Programmatically, by creating a ConfigurationFactory and Configuration implementation.</li>
            <li>Programmatically, by calling the APIs exposed in the Configuration interface to add
              components to the default configuration.</li>
            <li>Programmatically, by calling methods on the internal Logger class.</li>
          </ol>
        </p>
        <p>
          This page focuses primarily on configuring Log4j through a configuration file. Information on
          programmatically configuring Log4j can be found at <a href="./extending.html">Extending Log4j2</a>.
        </p>
        <p>
          Note that unlike Log4j 1.x, the public Log4j2 API does not expose methods to add, modify or remove
          appenders and filters or manipulate the configuration in any way.
        </p>
        <a name="AutomaticConfiguration"/>
        <subsection name="Automatic Configuration">
          <p>
            Log4j has the ability to automatically configure itself during initialization.
            When Log4j starts it will locate all the ConfigurationFactory plugins and arrange then in weighted
            order from highest to lowest. As delivered, Log4j contains two ConfigurationFactory implementations,
            one for JSON and one for XML.
            <ol>
              <li>Log4j will inspect the "log4j.configurationFile" system property and, if set,  will attempt to
                load the configuration using the <code>ConfigurationFactory</code> that matches the file
                extension.</li>
              <li>If no system property is set the JSON ConfigurationFactory will look for log4j-test.json or
                log4j-test.jsn in the classpath.</li>
              <li>If no such file is found the XML ConfigurationFactory will look for log4j-test.xml in the
                classpath.</li>
              <li>If a test file cannot be located the JSON ConfigurationFactory will look for log4j.json or log4j.jsn
                on the classpath.</li>
              <li>If a JSON file cannot be located the XML ConfigurationFactory will try to locate
                log4j.xml on the classpath.</li>
              <li>If no configuration file could be located the <code>DefaultConfiguration</code> will
                be used. This will cause logging output to go to the console.</li>
            </ol>
          </p>
          <p>An example application named <code>MyApp</code> that uses log4j can be used to illustrate how
            this is done.
          </p><commit_msg>fixed docs: the name of the configuration file is log4j2.xml, not log4j.xml (same for test)<commit_after><?xml version="1.0"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<document>
    <properties>
        <title>Configuring Log4j2</title>
        <author email="<EMAIL>"><NAME></author>
    </properties>

    <body>
      <section name="Configuration">
        <p>Inserting log requests into the application code requires a fair
          amount of planning and effort. Observation shows that approximately 4
          percent of code is dedicated to logging. Consequently, even moderately
          sized applications will have thousands of logging statements embedded
          within their code.  Given their number, it becomes imperative to
          manage these log statements without the need to modify them manually.
        </p>
        <p>
          Configuration of Log4j2 can be accomplished in 1 of 4 ways:
          <ol>
            <li>Through a configuration file written in XML or JSON.</li>
            <li>Programmatically, by creating a ConfigurationFactory and Configuration implementation.</li>
            <li>Programmatically, by calling the APIs exposed in the Configuration interface to add
              components to the default configuration.</li>
            <li>Programmatically, by calling methods on the internal Logger class.</li>
          </ol>
        </p>
        <p>
          This page focuses primarily on configuring Log4j through a configuration file. Information on
          programmatically configuring Log4j can be found at <a href="./extending.html">Extending Log4j2</a>.
        </p>
        <p>
          Note that unlike Log4j 1.x, the public Log4j2 API does not expose methods to add, modify or remove
          appenders and filters or manipulate the configuration in any way.
        </p>
        <a name="AutomaticConfiguration"/>
        <subsection name="Automatic Configuration">
          <p>
            Log4j has the ability to automatically configure itself during initialization.
            When Log4j starts it will locate all the ConfigurationFactory plugins and arrange then in weighted
            order from highest to lowest. As delivered, Log4j contains two ConfigurationFactory implementations,
            one for JSON and one for XML.
            <ol>
              <li>Log4j will inspect the "log4j.configurationFile" system property and, if set,  will attempt to
                load the configuration using the <code>ConfigurationFactory</code> that matches the file
                extension.</li>
              <li>If no system property is set the JSON ConfigurationFactory will look for log4j-test.json or
                log4j-test.jsn in the classpath.</li>
              <li>If no such file is found the XML ConfigurationFactory will look for log4j2-test.xml in the
                classpath.</li>
              <li>If a test file cannot be located the JSON ConfigurationFactory will look for log4j.json or log4j.jsn
                on the classpath.</li>
              <li>If a JSON file cannot be located the XML ConfigurationFactory will try to locate
                log4j2.xml on the classpath.</li>
              <li>If no configuration file could be located the <code>DefaultConfiguration</code> will
                be used. This will cause logging output to go to the console.</li>
            </ol>
          </p>
          <p>An example application named <code>MyApp</code> that uses log4j can be used to illustrate how
            this is done.
          </p>
{'fraction_non_alphanumeric': 0.059248891999066945, 'fraction_numerical': 0.00828084907860975, 'mean_word_length': 2.420422816114878, 'pattern_counts': {'":': 0, '<': 121, '<?xml version=': 2, '>': 121, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7472322', 'n_tokens_mistral': 2014, 'n_tokens_neox': 1963, 'n_words': 989}