[
https://issues.apache.org/jira/browse/LOG4J2-1944?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16061501#comment-16061501
]
Weian Deng commented on LOG4J2-1944:
------------------------------------
[~phymbert] Attached is a simple test app
It has only one class called App.java
{code}
package org.apache.log4j2.sample;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
Logger logger = LoggerFactory.getLogger(App.class);
System.out.println( "Hello World!" );
logger.error("Hello");
}
}
{code}
with the following dependencies in pom.xml
{code}
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.6.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
{code}
Running the app produces the following console outputs
{code}
ERROR StatusLogger No log4j2 configuration file found. Using default
configuration: logging only errors to the console.
Hello World!
14:03:31.179 [main] ERROR org.apache.log4j2.sample.App - Hello
{code}
It is a log4j2 feature that if no configuration file is provided, log4j2 will
log only errors to the console. Then using log4j2 without any configuration
file is ok if this default behavior fits the users need. Then why we
categorize this "No log4j2 configuration file found" as an Error? should it
better be a "WARN" message?
> Should suppress message "ERROR No log4j2 configuration file found..." when
> programmatic API is used to config log4j.
> --------------------------------------------------------------------------------------------------------------------
>
> Key: LOG4J2-1944
> URL: https://issues.apache.org/jira/browse/LOG4J2-1944
> Project: Log4j 2
> Issue Type: Bug
> Components: Configurators
> Affects Versions: 2.6.2
> Reporter: Weian Deng
> Priority: Minor
> Attachments: LOG4J2_1944.zip
>
>
> Log4j can be configured through log4j's configuration API. There are cases
> that an organization want to control the log4j configuration through the
> configuration API and discourage the use of config file. The error message
> {code}
> ERROR No log4j2 configuration file found. Using default configuration:
> logging only errors to the console.
> {code}
> is misleading.
> Can this be downgraded to WARN message, or provide a way to suppress it?
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)