You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Pooja Pandey <Po...@asg.com.INVALID> on 2022/03/09 11:47:27 UTC

Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge

We are using PropertyConfigurator.configure(), but this doesn't work in log4j1.x bridge.



Please let me know if you have any idea on how to fix it.



Thanks,

Pooja


Re: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge

Posted by Gary Gregory <ga...@gmail.com>.
Except that it does in 2.17.2, the site is not up to date, sorry about
that. In this case, there might be a bug when reconfiguring log4j as
opposed to the initial configuration loaded.

Gary

On Wed, Mar 9, 2022, 10:46 Jason Wen <zh...@workday.com.invalid>
wrote:

> Hi Pooja,
>
> We faced the same problem that log4j1.x bridge does not support
> PropertyConfigurator API. See
> https://logging.apache.org/log4j/2.x/manual/migration.html
>
> #### Limitations of the Log4j 1.x bridge
>
> Applications can migrate by just using the bridge without further code
> changes, if they meet the following requirements:
> 1.    They must not access methods and classes internal to the Log4j 1.x
> implementation such as Appenders, LoggerRepository or Category's
> callAppenders method.
> 2.    They must not programmatically configure Log4j.
> 3.    They must not configure by calling the Log4j 1.x classes
> DOMConfigurator or PropertyConfigurator.
> Our solution is to use log4j2 api to implement what
> PropertyConfigurator.configure does.
>
> Thanks,
> Jason
>
> From: Gary Gregory <ga...@gmail.com>
> Date: Wednesday, March 9, 2022 at 5:13 AM
> To: Log4J Users List <lo...@logging.apache.org>
> Subject: [External Sender] Re: Alternative to PropertyConfigurator while
> migrating from log4j1.x to log4j1.x bridge
> Hello Pooja,
>
> Please describe exactly what is happening. The information provided in too
> vague. I take it from previous messages that you are using Log4j 2.17.2
> jars and that there are no Log4j 1 jars on your class path? A reproduced
> would be best, preferably as a failing test in a GitHub PR. Otherwise,
> there is no way for us to tell what your are doing.
>
> Ty,
> Gary
>
> On Wed, Mar 9, 2022, 06:47 Pooja Pandey <Po...@asg.com.invalid>
> wrote:
>
> > We are using PropertyConfigurator.configure(), but this doesn't work in
> > log4j1.x bridge.
> >
> >
> >
> > Please let me know if you have any idea on how to fix it.
> >
> >
> >
> > Thanks,
> >
> > Pooja
> >
> >
>

Re: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge

Posted by Jason Wen <zh...@workday.com.INVALID>.
Good to know it. Thanks!

From: Pooja Pandey <Po...@asg.com.INVALID>
Date: Thursday, March 10, 2022 at 10:47 AM
To: Log4J Users List <lo...@logging.apache.org>
Subject: Re: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge
Thank you, Jason.

Just an FYI, PropertyConfigurator.configure() in log4j 2.17.2 worked fine for my application.

Get Outlook for iOS<https://aka.ms/o0ukef>
________________________________
From: Jason Wen <zh...@workday.com.INVALID>
Sent: Thursday, March 10, 2022 10:24:53 AM
To: Log4J Users List <lo...@logging.apache.org>
Subject: Re: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge

*** External email: Verify sender before opening attachments or links ***


Here is our code snippet:


public void configure(URL configURL) {
  System.setProperty(ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY,
      configURL.toString());
  System.clearProperty(LOG4J1_MONITOR_INTERVAL);
  LoggerContext context = LoggerContext.getContext(false);
  context.setConfigLocation(null);
}

-Jason
From: Pooja Pandey <Po...@asg.com.INVALID>
Date: Wednesday, March 9, 2022 at 7:50 PM
To: Log4J Users List <lo...@logging.apache.org>
Subject: RE: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge
Hi Jason,

-> Our solution is to use log4j2 api to implement what PropertyConfigurator.configure does.

Can you please share the solution snippet for reference?

Thanks,
Pooja


-----Original Message-----
From: Jason Wen <zh...@workday.com.INVALID>
Sent: Wednesday, March 9, 2022 9:16 PM
To: Log4J Users List <lo...@logging.apache.org>
Subject: Re: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge

*** External email: Verify sender before opening attachments or links ***


Hi Pooja,

We faced the same problem that log4j1.x bridge does not support PropertyConfigurator API. See https://logging.apache.org/log4j/2.x/manual/migration.html

#### Limitations of the Log4j 1.x bridge

Applications can migrate by just using the bridge without further code changes, if they meet the following requirements:
1.    They must not access methods and classes internal to the Log4j 1.x implementation such as Appenders, LoggerRepository or Category's callAppenders method.
2.    They must not programmatically configure Log4j.
3.    They must not configure by calling the Log4j 1.x classes DOMConfigurator or PropertyConfigurator.
Our solution is to use log4j2 api to implement what PropertyConfigurator.configure does.

Thanks,
Jason

From: Gary Gregory <ga...@gmail.com>
Date: Wednesday, March 9, 2022 at 5:13 AM
To: Log4J Users List <lo...@logging.apache.org>
Subject: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge Hello Pooja,

Please describe exactly what is happening. The information provided in too vague. I take it from previous messages that you are using Log4j 2.17.2 jars and that there are no Log4j 1 jars on your class path? A reproduced would be best, preferably as a failing test in a GitHub PR. Otherwise, there is no way for us to tell what your are doing.

Ty,
Gary

On Wed, Mar 9, 2022, 06:47 Pooja Pandey <Po...@asg.com.invalid>
wrote:

> We are using PropertyConfigurator.configure(), but this doesn't work
> in log4j1.x bridge.
>
>
>
> Please let me know if you have any idea on how to fix it.
>
>
>
> Thanks,
>
> Pooja
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

Re: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge

Posted by Pooja Pandey <Po...@asg.com.INVALID>.
Thank you, Jason.

Just an FYI, PropertyConfigurator.configure() in log4j 2.17.2 worked fine for my application.

Get Outlook for iOS<https://aka.ms/o0ukef>
________________________________
From: Jason Wen <zh...@workday.com.INVALID>
Sent: Thursday, March 10, 2022 10:24:53 AM
To: Log4J Users List <lo...@logging.apache.org>
Subject: Re: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge

*** External email: Verify sender before opening attachments or links ***


Here is our code snippet:


public void configure(URL configURL) {
  System.setProperty(ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY,
      configURL.toString());
  System.clearProperty(LOG4J1_MONITOR_INTERVAL);
  LoggerContext context = LoggerContext.getContext(false);
  context.setConfigLocation(null);
}

-Jason
From: Pooja Pandey <Po...@asg.com.INVALID>
Date: Wednesday, March 9, 2022 at 7:50 PM
To: Log4J Users List <lo...@logging.apache.org>
Subject: RE: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge
Hi Jason,

-> Our solution is to use log4j2 api to implement what PropertyConfigurator.configure does.

Can you please share the solution snippet for reference?

Thanks,
Pooja


-----Original Message-----
From: Jason Wen <zh...@workday.com.INVALID>
Sent: Wednesday, March 9, 2022 9:16 PM
To: Log4J Users List <lo...@logging.apache.org>
Subject: Re: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge

*** External email: Verify sender before opening attachments or links ***


Hi Pooja,

We faced the same problem that log4j1.x bridge does not support PropertyConfigurator API. See https://logging.apache.org/log4j/2.x/manual/migration.html

#### Limitations of the Log4j 1.x bridge

Applications can migrate by just using the bridge without further code changes, if they meet the following requirements:
1.    They must not access methods and classes internal to the Log4j 1.x implementation such as Appenders, LoggerRepository or Category's callAppenders method.
2.    They must not programmatically configure Log4j.
3.    They must not configure by calling the Log4j 1.x classes DOMConfigurator or PropertyConfigurator.
Our solution is to use log4j2 api to implement what PropertyConfigurator.configure does.

Thanks,
Jason

From: Gary Gregory <ga...@gmail.com>
Date: Wednesday, March 9, 2022 at 5:13 AM
To: Log4J Users List <lo...@logging.apache.org>
Subject: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge Hello Pooja,

Please describe exactly what is happening. The information provided in too vague. I take it from previous messages that you are using Log4j 2.17.2 jars and that there are no Log4j 1 jars on your class path? A reproduced would be best, preferably as a failing test in a GitHub PR. Otherwise, there is no way for us to tell what your are doing.

Ty,
Gary

On Wed, Mar 9, 2022, 06:47 Pooja Pandey <Po...@asg.com.invalid>
wrote:

> We are using PropertyConfigurator.configure(), but this doesn't work
> in log4j1.x bridge.
>
>
>
> Please let me know if you have any idea on how to fix it.
>
>
>
> Thanks,
>
> Pooja
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

Re: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge

Posted by Jason Wen <zh...@workday.com.INVALID>.
Here is our code snippet:


public void configure(URL configURL) {
  System.setProperty(ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY,
      configURL.toString());
  System.clearProperty(LOG4J1_MONITOR_INTERVAL);
  LoggerContext context = LoggerContext.getContext(false);
  context.setConfigLocation(null);
}

-Jason
From: Pooja Pandey <Po...@asg.com.INVALID>
Date: Wednesday, March 9, 2022 at 7:50 PM
To: Log4J Users List <lo...@logging.apache.org>
Subject: RE: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge
Hi Jason,

-> Our solution is to use log4j2 api to implement what PropertyConfigurator.configure does.

Can you please share the solution snippet for reference?

Thanks,
Pooja


-----Original Message-----
From: Jason Wen <zh...@workday.com.INVALID>
Sent: Wednesday, March 9, 2022 9:16 PM
To: Log4J Users List <lo...@logging.apache.org>
Subject: Re: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge

*** External email: Verify sender before opening attachments or links ***


Hi Pooja,

We faced the same problem that log4j1.x bridge does not support PropertyConfigurator API. See https://logging.apache.org/log4j/2.x/manual/migration.html

#### Limitations of the Log4j 1.x bridge

Applications can migrate by just using the bridge without further code changes, if they meet the following requirements:
1.    They must not access methods and classes internal to the Log4j 1.x implementation such as Appenders, LoggerRepository or Category's callAppenders method.
2.    They must not programmatically configure Log4j.
3.    They must not configure by calling the Log4j 1.x classes DOMConfigurator or PropertyConfigurator.
Our solution is to use log4j2 api to implement what PropertyConfigurator.configure does.

Thanks,
Jason

From: Gary Gregory <ga...@gmail.com>
Date: Wednesday, March 9, 2022 at 5:13 AM
To: Log4J Users List <lo...@logging.apache.org>
Subject: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge Hello Pooja,

Please describe exactly what is happening. The information provided in too vague. I take it from previous messages that you are using Log4j 2.17.2 jars and that there are no Log4j 1 jars on your class path? A reproduced would be best, preferably as a failing test in a GitHub PR. Otherwise, there is no way for us to tell what your are doing.

Ty,
Gary

On Wed, Mar 9, 2022, 06:47 Pooja Pandey <Po...@asg.com.invalid>
wrote:

> We are using PropertyConfigurator.configure(), but this doesn't work
> in log4j1.x bridge.
>
>
>
> Please let me know if you have any idea on how to fix it.
>
>
>
> Thanks,
>
> Pooja
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

RE: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge

Posted by Pooja Pandey <Po...@asg.com.INVALID>.
Hi Jason,

-> Our solution is to use log4j2 api to implement what PropertyConfigurator.configure does.

Can you please share the solution snippet for reference?

Thanks,
Pooja


-----Original Message-----
From: Jason Wen <zh...@workday.com.INVALID> 
Sent: Wednesday, March 9, 2022 9:16 PM
To: Log4J Users List <lo...@logging.apache.org>
Subject: Re: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge

*** External email: Verify sender before opening attachments or links ***


Hi Pooja,

We faced the same problem that log4j1.x bridge does not support PropertyConfigurator API. See https://logging.apache.org/log4j/2.x/manual/migration.html

#### Limitations of the Log4j 1.x bridge

Applications can migrate by just using the bridge without further code changes, if they meet the following requirements:
1.    They must not access methods and classes internal to the Log4j 1.x implementation such as Appenders, LoggerRepository or Category's callAppenders method.
2.    They must not programmatically configure Log4j.
3.    They must not configure by calling the Log4j 1.x classes DOMConfigurator or PropertyConfigurator.
Our solution is to use log4j2 api to implement what PropertyConfigurator.configure does.

Thanks,
Jason

From: Gary Gregory <ga...@gmail.com>
Date: Wednesday, March 9, 2022 at 5:13 AM
To: Log4J Users List <lo...@logging.apache.org>
Subject: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge Hello Pooja,

Please describe exactly what is happening. The information provided in too vague. I take it from previous messages that you are using Log4j 2.17.2 jars and that there are no Log4j 1 jars on your class path? A reproduced would be best, preferably as a failing test in a GitHub PR. Otherwise, there is no way for us to tell what your are doing.

Ty,
Gary

On Wed, Mar 9, 2022, 06:47 Pooja Pandey <Po...@asg.com.invalid>
wrote:

> We are using PropertyConfigurator.configure(), but this doesn't work 
> in log4j1.x bridge.
>
>
>
> Please let me know if you have any idea on how to fix it.
>
>
>
> Thanks,
>
> Pooja
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge

Posted by Jason Wen <zh...@workday.com.INVALID>.
Hi Pooja,

We faced the same problem that log4j1.x bridge does not support PropertyConfigurator API. See https://logging.apache.org/log4j/2.x/manual/migration.html

#### Limitations of the Log4j 1.x bridge

Applications can migrate by just using the bridge without further code changes, if they meet the following requirements:
1.    They must not access methods and classes internal to the Log4j 1.x implementation such as Appenders, LoggerRepository or Category's callAppenders method.
2.    They must not programmatically configure Log4j.
3.    They must not configure by calling the Log4j 1.x classes DOMConfigurator or PropertyConfigurator.
Our solution is to use log4j2 api to implement what PropertyConfigurator.configure does.

Thanks,
Jason

From: Gary Gregory <ga...@gmail.com>
Date: Wednesday, March 9, 2022 at 5:13 AM
To: Log4J Users List <lo...@logging.apache.org>
Subject: [External Sender] Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge
Hello Pooja,

Please describe exactly what is happening. The information provided in too
vague. I take it from previous messages that you are using Log4j 2.17.2
jars and that there are no Log4j 1 jars on your class path? A reproduced
would be best, preferably as a failing test in a GitHub PR. Otherwise,
there is no way for us to tell what your are doing.

Ty,
Gary

On Wed, Mar 9, 2022, 06:47 Pooja Pandey <Po...@asg.com.invalid>
wrote:

> We are using PropertyConfigurator.configure(), but this doesn't work in
> log4j1.x bridge.
>
>
>
> Please let me know if you have any idea on how to fix it.
>
>
>
> Thanks,
>
> Pooja
>
>

Re: Alternative to PropertyConfigurator while migrating from log4j1.x to log4j1.x bridge

Posted by Gary Gregory <ga...@gmail.com>.
Hello Pooja,

Please describe exactly what is happening. The information provided in too
vague. I take it from previous messages that you are using Log4j 2.17.2
jars and that there are no Log4j 1 jars on your class path? A reproduced
would be best, preferably as a failing test in a GitHub PR. Otherwise,
there is no way for us to tell what your are doing.

Ty,
Gary

On Wed, Mar 9, 2022, 06:47 Pooja Pandey <Po...@asg.com.invalid>
wrote:

> We are using PropertyConfigurator.configure(), but this doesn't work in
> log4j1.x bridge.
>
>
>
> Please let me know if you have any idea on how to fix it.
>
>
>
> Thanks,
>
> Pooja
>
>