[ 
https://issues.apache.org/jira/browse/LOG4J2-3677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17780913#comment-17780913
 ] 

Volkan Yazici commented on LOG4J2-3677:
---------------------------------------

[~jiagao], I am not able to reproduce the problem you describe. Against 
{{log4j-core-2.21.1.jar}}, the following Java file

{code:java}
package ci.yazi.volkan.log4j;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.config.ConfigurationSource;
import org.apache.logging.log4j.core.config.DefaultConfiguration;

import java.net.URI;

public final class LOG4J2_3677 extends ConfigurationFactory {

    public static void main(String[] args) {
        System.setProperty("log4j2.configurationFactory", 
"ci.yazi.volkan.log4j.LOG4J2_3677");
        LogManager.getLogger().error("stuff happens");
    }

    @Override
    public Configuration getConfiguration(LoggerContext loggerContext, 
ConfigurationSource source) {
        System.out.println("creating config 1");
        return new DefaultConfiguration();
    }

    @Override
    public Configuration getConfiguration(LoggerContext loggerContext, String 
name, URI configLocation) {
        System.out.println("creating config 2");
        return new DefaultConfiguration();
    }

    @Override
    public Configuration getConfiguration(LoggerContext loggerContext, String 
name, URI configLocation, ClassLoader loader) {
        System.out.println("creating config 3");
        return new DefaultConfiguration();
    }

    @Override
    protected String[] getSupportedTypes() {
        return new String[] {"*"};
    }

}
{code}

produces this output:

{code}
creating config 2
09:59:47.613 [main] ERROR ci.yazi.volkan.log4j.LOG4J2_3677 - stuff happens
{code}

Would you mind trying against the most recent Log4j version, i.e., {{2.21.1}}, 
please? If it still doesn't work, I would appreciate it if you can share a 
simple code snippet demonstrating the issue.

> System property log4j2.configurationFactory doesn't work
> --------------------------------------------------------
>
>                 Key: LOG4J2-3677
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3677
>             Project: Log4j 2
>          Issue Type: Bug
>            Reporter: Jiazhou Gao
>            Assignee: Volkan Yazici
>            Priority: Major
>
> We followed the wiki 
> [https://logging.apache.org/log4j/2.x/manual/customconfig.html]and set 
> -Dlog4j2.configurationFactory=<our customized configuration factory> in Java 
> opts.
> It used to work but seems broken after log4j2 2.17.1. Our 
> configurationFactory never started
> Now, we have to use system property log4j.configurationFactory and set 
> -Dlog4j.configurationFactory=<our customized configuration factory> in Java 
> opts
> So it looks like a regression in log4j2 latest versions
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to