Problem with log4j2.configurationFile. Using log4j2.properties with custom file name.

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with log4j2.configurationFile. Using log4j2.properties with custom file name.

Leo R
Dear Log4j Team,
 
First of all, thanks for your work. I am Leo, an Spanish web developer that need some help.
 
I am migrating one of our project from slf4j v. 1.7.21 to log4j v.2.11.1 and I have this problem:
 
-In my web project, we need to have the log4j.configurationFile with a particular name: Particular_web_app_log4j2.properties (example name)
 
We cannot set the default log4j2.properties, log4j2.xml, etc in our repository.
In slf4j we solved this situation with this code. (with this, all sl4j configuration is loaded from our custom log4j.properties):
 
      URL log4jURL = Loader.getResource(Log4javaFileName);
      if (log4jURL == null) {
            throw new Exception();
      }
      PropertyConfigurator.configure(log4jURL);
 
In log4j2 this method is deprecated and I found some alternatives, but any of them worked.
Solution one:
Set this property in my first line of code:
System.setProperty("log4j.configurationFile",Log4java2FileName);
               It not works in my Websphere Application Server because log4j2 try to charge before my first web app line of code.
Solution two:
                                using java -D option which sets a system property on server start.
                                It not works in my Websphere Application Server because it is an application server with other applications and we share the node, this change can affect to other apps.
Solution three:
Using an recharge of properties from custom XML properties:
InputStream log4javaFile = getClass().getClassLoader().getResourceAsStream(Log4java2FileName);
            ConfigurationSource configuration = newConfigurationSource(log4javaFile);
Configurator.initialize(null, configuration);
It not works in my project because a regret to include this code in my InitContext (first point of code), this change only affect in some class, not in all context. (I have different servlets in my application and there are not affected by this change)
 
Question:
                Is there an easy alternative for adjusting the properties file? (some like slf4j configuration)

I would be very grateful if you could help me because I can not find a solution and I would like to be able to use the new log4j2.
Best regards!
Reply | Threaded
Open this post in threaded view
|

Re: Problem with log4j2.configurationFile. Using log4j2.properties with custom file name.

Ralph Goers
From what you are describing I would set log4jConfiguration in your web application’s web.xml as a context parameter. See http://logging.apache.org/log4j/2.x/manual/webapp.html <http://logging.apache.org/log4j/2.x/manual/webapp.html>.

Ralph


> On Dec 5, 2018, at 7:54 AM, paginas <[hidden email]> wrote:
>
> Dear Log4j Team,
>
> First of all, thanks for your work. I am Leo, an Spanish web developer that need some help.
>
> I am migrating one of our project from slf4j v. 1.7.21 to log4j v.2.11.1 and I have this problem:
>
> -In my web project, we need to have the log4j.configurationFile with a particular name: Particular_web_app_log4j2.properties (example name)
>
> We cannot set the default log4j2.properties, log4j2.xml, etc in our repository.
> In slf4j we solved this situation with this code. (with this, all sl4j configuration is loaded from our custom log4j.properties):
>
>      URL log4jURL = Loader.getResource(Log4javaFileName);
>      if (log4jURL == null) {
>            throw new Exception();
>      }
>      PropertyConfigurator.configure(log4jURL);
>
> In log4j2 this method is deprecated and I found some alternatives, but any of them worked.
> Solution one:
> Set this property in my first line of code:
> System.setProperty("log4j.configurationFile",Log4java2FileName);
>               It not works in my Websphere Application Server because log4j2 try to charge before my first web app line of code.
> Solution two:
>                                using java -D option which sets a system property on server start.
>                                It not works in my Websphere Application Server because it is an application server with other applications and we share the node, this change can affect to other apps.
> Solution three:
> Using an recharge of properties from custom XML properties:
> InputStream log4javaFile = getClass().getClassLoader().getResourceAsStream(Log4java2FileName);
>            ConfigurationSource configuration = newConfigurationSource(log4javaFile);
> Configurator.initialize(null, configuration);
> It not works in my project because a regret to include this code in my InitContext (first point of code), this change only affect in some class, not in all context. (I have different servlets in my application and there are not affected by this change)
>
> Question:
>                Is there an easy alternative for adjusting the properties file? (some like slf4j configuration)
>
> I would be very grateful if you could help me because I can not find a solution and I would like to be able to use the new log4j2.
> Best regards!

Reply | Threaded
Open this post in threaded view
|

Re: Problem with log4j2.configurationFile. Using log4j2.properties with custom file name.

Ralph Goers
Even simpler. Just name the file "log4j2-name.xml” where “name” is the name of the web application.

Ralph

> On Dec 5, 2018, at 8:23 AM, Ralph Goers <[hidden email]> wrote:
>
> From what you are describing I would set log4jConfiguration in your web application’s web.xml as a context parameter. See http://logging.apache.org/log4j/2.x/manual/webapp.html <http://logging.apache.org/log4j/2.x/manual/webapp.html>.
>
> Ralph
>
>
>> On Dec 5, 2018, at 7:54 AM, paginas <[hidden email] <mailto:[hidden email]>> wrote:
>>
>> Dear Log4j Team,
>>
>> First of all, thanks for your work. I am Leo, an Spanish web developer that need some help.
>>
>> I am migrating one of our project from slf4j v. 1.7.21 to log4j v.2.11.1 and I have this problem:
>>
>> -In my web project, we need to have the log4j.configurationFile with a particular name: Particular_web_app_log4j2.properties (example name)
>>
>> We cannot set the default log4j2.properties, log4j2.xml, etc in our repository.
>> In slf4j we solved this situation with this code. (with this, all sl4j configuration is loaded from our custom log4j.properties):
>>
>>      URL log4jURL = Loader.getResource(Log4javaFileName);
>>      if (log4jURL == null) {
>>            throw new Exception();
>>      }
>>      PropertyConfigurator.configure(log4jURL);
>>
>> In log4j2 this method is deprecated and I found some alternatives, but any of them worked.
>> Solution one:
>> Set this property in my first line of code:
>> System.setProperty("log4j.configurationFile",Log4java2FileName);
>>               It not works in my Websphere Application Server because log4j2 try to charge before my first web app line of code.
>> Solution two:
>>                                using java -D option which sets a system property on server start.
>>                                It not works in my Websphere Application Server because it is an application server with other applications and we share the node, this change can affect to other apps.
>> Solution three:
>> Using an recharge of properties from custom XML properties:
>> InputStream log4javaFile = getClass().getClassLoader().getResourceAsStream(Log4java2FileName);
>>            ConfigurationSource configuration = newConfigurationSource(log4javaFile);
>> Configurator.initialize(null, configuration);
>> It not works in my project because a regret to include this code in my InitContext (first point of code), this change only affect in some class, not in all context. (I have different servlets in my application and there are not affected by this change)
>>
>> Question:
>>                Is there an easy alternative for adjusting the properties file? (some like slf4j configuration)
>>
>> I would be very grateful if you could help me because I can not find a solution and I would like to be able to use the new log4j2.
>> Best regards!
>

Reply | Threaded
Open this post in threaded view
|

Re: Problem with log4j2.configurationFile. Using log4j2.properties with custom file name.

Leo R
I added in my web.xml
<context-param>
        <param-name>log4jConfiguration</param-name>
        <param-value>file:///C:/ <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>name <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/ <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>src <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/particularName/ <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>configuracion <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/ <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>entorno <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/ <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>conf <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>-especial-name-log4j2.properties <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E></ <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>param-value <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>
    </context-param>
 
And my application not works

Could you give more support please?

> El 5 dic 2018, a las 16:27, Ralph Goers <[hidden email]> escribió:
>
> Even simpler. Just name the file "log4j2-name.xml” where “name” is the name of the web application.
>
> Ralph
>
>> On Dec 5, 2018, at 8:23 AM, Ralph Goers <[hidden email]> wrote:
>>
>> From what you are describing I would set log4jConfiguration in your web application’s web.xml as a context parameter. See http://logging.apache.org/log4j/2.x/manual/webapp.html <http://logging.apache.org/log4j/2.x/manual/webapp.html>.
>>
>> Ralph
>>
>>
>>> On Dec 5, 2018, at 7:54 AM, paginas <[hidden email] <mailto:[hidden email]>> wrote:
>>>
>>> Dear Log4j Team,
>>>
>>> First of all, thanks for your work. I am Leo, an Spanish web developer that need some help.
>>>
>>> I am migrating one of our project from slf4j v. 1.7.21 to log4j v.2.11.1 and I have this problem:
>>>
>>> -In my web project, we need to have the log4j.configurationFile with a particular name: Particular_web_app_log4j2.properties (example name)
>>>
>>> We cannot set the default log4j2.properties, log4j2.xml, etc in our repository.
>>> In slf4j we solved this situation with this code. (with this, all sl4j configuration is loaded from our custom log4j.properties):
>>>
>>>     URL log4jURL = Loader.getResource(Log4javaFileName);
>>>     if (log4jURL == null) {
>>>           throw new Exception();
>>>     }
>>>     PropertyConfigurator.configure(log4jURL);
>>>
>>> In log4j2 this method is deprecated and I found some alternatives, but any of them worked.
>>> Solution one:
>>> Set this property in my first line of code:
>>> System.setProperty("log4j.configurationFile",Log4java2FileName);
>>>              It not works in my Websphere Application Server because log4j2 try to charge before my first web app line of code.
>>> Solution two:
>>>                               using java -D option which sets a system property on server start.
>>>                               It not works in my Websphere Application Server because it is an application server with other applications and we share the node, this change can affect to other apps.
>>> Solution three:
>>> Using an recharge of properties from custom XML properties:
>>> InputStream log4javaFile = getClass().getClassLoader().getResourceAsStream(Log4java2FileName);
>>>           ConfigurationSource configuration = newConfigurationSource(log4javaFile);
>>> Configurator.initialize(null, configuration);
>>> It not works in my project because a regret to include this code in my InitContext (first point of code), this change only affect in some class, not in all context. (I have different servlets in my application and there are not affected by this change)
>>>
>>> Question:
>>>               Is there an easy alternative for adjusting the properties file? (some like slf4j configuration)
>>>
>>> I would be very grateful if you could help me because I can not find a solution and I would like to be able to use the new log4j2.
>>> Best regards!
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Problem with log4j2.configurationFile. Using log4j2.properties with custom file name.

Matt Sicker
Are you including log4j-web in your war as well?

On Wed, 5 Dec 2018 at 10:43, paginas <[hidden email]> wrote:

> I added in my web.xml
> <context-param>
>         <param-name>log4jConfiguration</param-name>
>         <param-value>file:///C:/
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>name
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>src
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/particularName/
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>configuracion
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>entorno
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>conf
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>-especial-name-log4j2.properties
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E></
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>param-value
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>>
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>
>     </context-param>
>
> And my application not works
>
> Could you give more support please?
>
> > El 5 dic 2018, a las 16:27, Ralph Goers <[hidden email]>
> escribió:
> >
> > Even simpler. Just name the file "log4j2-name.xml” where “name” is the
> name of the web application.
> >
> > Ralph
> >
> >> On Dec 5, 2018, at 8:23 AM, Ralph Goers <[hidden email]>
> wrote:
> >>
> >> From what you are describing I would set log4jConfiguration in your web
> application’s web.xml as a context parameter. See
> http://logging.apache.org/log4j/2.x/manual/webapp.html <
> http://logging.apache.org/log4j/2.x/manual/webapp.html>.
> >>
> >> Ralph
> >>
> >>
> >>> On Dec 5, 2018, at 7:54 AM, paginas <[hidden email]
> <mailto:[hidden email]>> wrote:
> >>>
> >>> Dear Log4j Team,
> >>>
> >>> First of all, thanks for your work. I am Leo, an Spanish web developer
> that need some help.
> >>>
> >>> I am migrating one of our project from slf4j v. 1.7.21 to log4j
> v.2.11.1 and I have this problem:
> >>>
> >>> -In my web project, we need to have the log4j.configurationFile with a
> particular name: Particular_web_app_log4j2.properties (example name)
> >>>
> >>> We cannot set the default log4j2.properties, log4j2.xml, etc in our
> repository.
> >>> In slf4j we solved this situation with this code. (with this, all sl4j
> configuration is loaded from our custom log4j.properties):
> >>>
> >>>     URL log4jURL = Loader.getResource(Log4javaFileName);
> >>>     if (log4jURL == null) {
> >>>           throw new Exception();
> >>>     }
> >>>     PropertyConfigurator.configure(log4jURL);
> >>>
> >>> In log4j2 this method is deprecated and I found some alternatives, but
> any of them worked.
> >>> Solution one:
> >>> Set this property in my first line of code:
> >>> System.setProperty("log4j.configurationFile",Log4java2FileName);
> >>>              It not works in my Websphere Application Server because
> log4j2 try to charge before my first web app line of code.
> >>> Solution two:
> >>>                               using java -D option which sets a system
> property on server start.
> >>>                               It not works in my Websphere Application
> Server because it is an application server with other applications and we
> share the node, this change can affect to other apps.
> >>> Solution three:
> >>> Using an recharge of properties from custom XML properties:
> >>> InputStream log4javaFile =
> getClass().getClassLoader().getResourceAsStream(Log4java2FileName);
> >>>           ConfigurationSource configuration =
> newConfigurationSource(log4javaFile);
> >>> Configurator.initialize(null, configuration);
> >>> It not works in my project because a regret to include this code in my
> InitContext (first point of code), this change only affect in some class,
> not in all context. (I have different servlets in my application and there
> are not affected by this change)
> >>>
> >>> Question:
> >>>               Is there an easy alternative for adjusting the
> properties file? (some like slf4j configuration)
> >>>
> >>> I would be very grateful if you could help me because I can not find a
> solution and I would like to be able to use the new log4j2.
> >>> Best regards!
> >>
> >
>
>

--
Matt Sicker <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Problem with log4j2.configurationFile. Using log4j2.properties with custom file name.

Leo R
Hi!
Yes i included core, api and web.
I tested:
log4j2-name.xml ->not found
Property on web.xml -> not found
Could you give more ideas please?

El El mié, 5 dic 2018 a las 23:28, Matt Sicker <[hidden email]> escribió:

> Are you including log4j-web in your war as well?
>
> On Wed, 5 Dec 2018 at 10:43, paginas <[hidden email]> wrote:
>
> > I added in my web.xml
> > <context-param>
> >         <param-name>log4jConfiguration</param-name>
> >         <param-value>file:///C:/
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>name
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>src
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/particularName/
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>configuracion
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>entorno
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>conf
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>-especial-name-log4j2.properties
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E></
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>param-value
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>>
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>
> >     </context-param>
> >
> > And my application not works
> >
> > Could you give more support please?
> >
> > > El 5 dic 2018, a las 16:27, Ralph Goers <[hidden email]>
> > escribió:
> > >
> > > Even simpler. Just name the file "log4j2-name.xml” where “name” is the
> > name of the web application.
> > >
> > > Ralph
> > >
> > >> On Dec 5, 2018, at 8:23 AM, Ralph Goers <[hidden email]>
> > wrote:
> > >>
> > >> From what you are describing I would set log4jConfiguration in your
> web
> > application’s web.xml as a context parameter. See
> > http://logging.apache.org/log4j/2.x/manual/webapp.html <
> > http://logging.apache.org/log4j/2.x/manual/webapp.html>.
> > >>
> > >> Ralph
> > >>
> > >>
> > >>> On Dec 5, 2018, at 7:54 AM, paginas <[hidden email]
> > <mailto:[hidden email]>> wrote:
> > >>>
> > >>> Dear Log4j Team,
> > >>>
> > >>> First of all, thanks for your work. I am Leo, an Spanish web
> developer
> > that need some help.
> > >>>
> > >>> I am migrating one of our project from slf4j v. 1.7.21 to log4j
> > v.2.11.1 and I have this problem:
> > >>>
> > >>> -In my web project, we need to have the log4j.configurationFile with
> a
> > particular name: Particular_web_app_log4j2.properties (example name)
> > >>>
> > >>> We cannot set the default log4j2.properties, log4j2.xml, etc in our
> > repository.
> > >>> In slf4j we solved this situation with this code. (with this, all
> sl4j
> > configuration is loaded from our custom log4j.properties):
> > >>>
> > >>>     URL log4jURL = Loader.getResource(Log4javaFileName);
> > >>>     if (log4jURL == null) {
> > >>>           throw new Exception();
> > >>>     }
> > >>>     PropertyConfigurator.configure(log4jURL);
> > >>>
> > >>> In log4j2 this method is deprecated and I found some alternatives,
> but
> > any of them worked.
> > >>> Solution one:
> > >>> Set this property in my first line of code:
> > >>> System.setProperty("log4j.configurationFile",Log4java2FileName);
> > >>>              It not works in my Websphere Application Server because
> > log4j2 try to charge before my first web app line of code.
> > >>> Solution two:
> > >>>                               using java -D option which sets a
> system
> > property on server start.
> > >>>                               It not works in my Websphere
> Application
> > Server because it is an application server with other applications and we
> > share the node, this change can affect to other apps.
> > >>> Solution three:
> > >>> Using an recharge of properties from custom XML properties:
> > >>> InputStream log4javaFile =
> > getClass().getClassLoader().getResourceAsStream(Log4java2FileName);
> > >>>           ConfigurationSource configuration =
> > newConfigurationSource(log4javaFile);
> > >>> Configurator.initialize(null, configuration);
> > >>> It not works in my project because a regret to include this code in
> my
> > InitContext (first point of code), this change only affect in some class,
> > not in all context. (I have different servlets in my application and
> there
> > are not affected by this change)
> > >>>
> > >>> Question:
> > >>>               Is there an easy alternative for adjusting the
> > properties file? (some like slf4j configuration)
> > >>>
> > >>> I would be very grateful if you could help me because I can not find
> a
> > solution and I would like to be able to use the new log4j2.
> > >>> Best regards!
> > >>
> > >
> >
> >
>
> --
> Matt Sicker <[hidden email]>
>
Reply | Threaded
Open this post in threaded view
|

Re: Problem with log4j2.configurationFile. Using log4j2.properties with custom file name.

Matt Sicker
Could you define the system property "log4j2.debug" and include the debug
log info?

On Fri, 7 Dec 2018 at 02:59, Leo R <[hidden email]> wrote:

> Hi!
> Yes i included core, api and web.
> I tested:
> log4j2-name.xml ->not found
> Property on web.xml -> not found
> Could you give more ideas please?
>
> El El mié, 5 dic 2018 a las 23:28, Matt Sicker <[hidden email]>
> escribió:
>
> > Are you including log4j-web in your war as well?
> >
> > On Wed, 5 Dec 2018 at 10:43, paginas <[hidden email]> wrote:
> >
> > > I added in my web.xml
> > > <context-param>
> > >         <param-name>log4jConfiguration</param-name>
> > >         <param-value>file:///C:/
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>name
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>src
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/particularName/
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>configuracion
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>entorno
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>conf
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>-especial-name-log4j2.properties
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E></
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>param-value
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>>
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>
> > >     </context-param>
> > >
> > > And my application not works
> > >
> > > Could you give more support please?
> > >
> > > > El 5 dic 2018, a las 16:27, Ralph Goers <[hidden email]>
> > > escribió:
> > > >
> > > > Even simpler. Just name the file "log4j2-name.xml” where “name” is
> the
> > > name of the web application.
> > > >
> > > > Ralph
> > > >
> > > >> On Dec 5, 2018, at 8:23 AM, Ralph Goers <[hidden email]
> >
> > > wrote:
> > > >>
> > > >> From what you are describing I would set log4jConfiguration in your
> > web
> > > application’s web.xml as a context parameter. See
> > > http://logging.apache.org/log4j/2.x/manual/webapp.html <
> > > http://logging.apache.org/log4j/2.x/manual/webapp.html>.
> > > >>
> > > >> Ralph
> > > >>
> > > >>
> > > >>> On Dec 5, 2018, at 7:54 AM, paginas <[hidden email]
> > > <mailto:[hidden email]>> wrote:
> > > >>>
> > > >>> Dear Log4j Team,
> > > >>>
> > > >>> First of all, thanks for your work. I am Leo, an Spanish web
> > developer
> > > that need some help.
> > > >>>
> > > >>> I am migrating one of our project from slf4j v. 1.7.21 to log4j
> > > v.2.11.1 and I have this problem:
> > > >>>
> > > >>> -In my web project, we need to have the log4j.configurationFile
> with
> > a
> > > particular name: Particular_web_app_log4j2.properties (example name)
> > > >>>
> > > >>> We cannot set the default log4j2.properties, log4j2.xml, etc in our
> > > repository.
> > > >>> In slf4j we solved this situation with this code. (with this, all
> > sl4j
> > > configuration is loaded from our custom log4j.properties):
> > > >>>
> > > >>>     URL log4jURL = Loader.getResource(Log4javaFileName);
> > > >>>     if (log4jURL == null) {
> > > >>>           throw new Exception();
> > > >>>     }
> > > >>>     PropertyConfigurator.configure(log4jURL);
> > > >>>
> > > >>> In log4j2 this method is deprecated and I found some alternatives,
> > but
> > > any of them worked.
> > > >>> Solution one:
> > > >>> Set this property in my first line of code:
> > > >>> System.setProperty("log4j.configurationFile",Log4java2FileName);
> > > >>>              It not works in my Websphere Application Server
> because
> > > log4j2 try to charge before my first web app line of code.
> > > >>> Solution two:
> > > >>>                               using java -D option which sets a
> > system
> > > property on server start.
> > > >>>                               It not works in my Websphere
> > Application
> > > Server because it is an application server with other applications and
> we
> > > share the node, this change can affect to other apps.
> > > >>> Solution three:
> > > >>> Using an recharge of properties from custom XML properties:
> > > >>> InputStream log4javaFile =
> > > getClass().getClassLoader().getResourceAsStream(Log4java2FileName);
> > > >>>           ConfigurationSource configuration =
> > > newConfigurationSource(log4javaFile);
> > > >>> Configurator.initialize(null, configuration);
> > > >>> It not works in my project because a regret to include this code in
> > my
> > > InitContext (first point of code), this change only affect in some
> class,
> > > not in all context. (I have different servlets in my application and
> > there
> > > are not affected by this change)
> > > >>>
> > > >>> Question:
> > > >>>               Is there an easy alternative for adjusting the
> > > properties file? (some like slf4j configuration)
> > > >>>
> > > >>> I would be very grateful if you could help me because I can not
> find
> > a
> > > solution and I would like to be able to use the new log4j2.
> > > >>> Best regards!
> > > >>
> > > >
> > >
> > >
> >
> > --
> > Matt Sicker <[hidden email]>
> >
>


--
Matt Sicker <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Problem with log4j2.configurationFile. Using log4j2.properties with custom file name.

Leo R
Hi all!

I have 5 web.xml because i have different maven projects inside my main
project.

Main:

·         main-core

·         main-app

·         main-web (in this web.xml I am writing my configuration)

·         child-name1-core

·         child-name1-web

·         child-name2-core

·         child-name2-web

·         child-name3-core

·         child-name3-web

·         child-name4-core

·         child-name4-web



I have servlet 3.1 and I think that the problem is the context.

I tried to use isLog4jAutoInitializationDisabled in all web.xml except
main-web (in this web.xml setting all following Servlet 2.5 Web
Applications from http://logging.apache.org/log4j/2.x/manual/webapp.html
because you say that in case of isLog4jAutoInitializationDisabled you need
to have the same configuration of servlet 2.5):

1.   <context-param>

2.  <param-name>isLog4jAutoInitializationDisabled</param-name>

3.  <param-value>true</param-value>

4.  </context-param>

And this solution not found.



Why is not included some configuration like:

 URL log4jURL = Loader.getResource(Log4javaFileName);
 if (log4jURL == null) {
      throw new Exception();
}
PropertyConfigurator.configure(log4jURL);

?

Could you help me, please?

Thanks for all support.

El vie., 7 dic. 2018 a las 16:36, Matt Sicker (<[hidden email]>) escribió:

> Could you define the system property "log4j2.debug" and include the debug
> log info?
>
> On Fri, 7 Dec 2018 at 02:59, Leo R <[hidden email]> wrote:
>
> > Hi!
> > Yes i included core, api and web.
> > I tested:
> > log4j2-name.xml ->not found
> > Property on web.xml -> not found
> > Could you give more ideas please?
> >
> > El El mié, 5 dic 2018 a las 23:28, Matt Sicker <[hidden email]>
> > escribió:
> >
> > > Are you including log4j-web in your war as well?
> > >
> > > On Wed, 5 Dec 2018 at 10:43, paginas <[hidden email]>
> wrote:
> > >
> > > > I added in my web.xml
> > > > <context-param>
> > > >         <param-name>log4jConfiguration</param-name>
> > > >         <param-value>file:///C:/
> > > >
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>name
> > > >
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> > > >
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>src
> > > >
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/particularName/
> > > >
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>configuracion
> > > >
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> > > >
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>entorno
> > > >
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> > > >
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>conf
> > > >
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>-especial-name-log4j2.properties
> > > >
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E></
> > > >
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>param-value
> > > >
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>>
> > > >
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>
> > > >     </context-param>
> > > >
> > > > And my application not works
> > > >
> > > > Could you give more support please?
> > > >
> > > > > El 5 dic 2018, a las 16:27, Ralph Goers <
> [hidden email]>
> > > > escribió:
> > > > >
> > > > > Even simpler. Just name the file "log4j2-name.xml” where “name” is
> > the
> > > > name of the web application.
> > > > >
> > > > > Ralph
> > > > >
> > > > >> On Dec 5, 2018, at 8:23 AM, Ralph Goers <
> [hidden email]
> > >
> > > > wrote:
> > > > >>
> > > > >> From what you are describing I would set log4jConfiguration in
> your
> > > web
> > > > application’s web.xml as a context parameter. See
> > > > http://logging.apache.org/log4j/2.x/manual/webapp.html <
> > > > http://logging.apache.org/log4j/2.x/manual/webapp.html>.
> > > > >>
> > > > >> Ralph
> > > > >>
> > > > >>
> > > > >>> On Dec 5, 2018, at 7:54 AM, paginas <[hidden email]
> > > > <mailto:[hidden email]>> wrote:
> > > > >>>
> > > > >>> Dear Log4j Team,
> > > > >>>
> > > > >>> First of all, thanks for your work. I am Leo, an Spanish web
> > > developer
> > > > that need some help.
> > > > >>>
> > > > >>> I am migrating one of our project from slf4j v. 1.7.21 to log4j
> > > > v.2.11.1 and I have this problem:
> > > > >>>
> > > > >>> -In my web project, we need to have the log4j.configurationFile
> > with
> > > a
> > > > particular name: Particular_web_app_log4j2.properties (example name)
> > > > >>>
> > > > >>> We cannot set the default log4j2.properties, log4j2.xml, etc in
> our
> > > > repository.
> > > > >>> In slf4j we solved this situation with this code. (with this, all
> > > sl4j
> > > > configuration is loaded from our custom log4j.properties):
> > > > >>>
> > > > >>>     URL log4jURL = Loader.getResource(Log4javaFileName);
> > > > >>>     if (log4jURL == null) {
> > > > >>>           throw new Exception();
> > > > >>>     }
> > > > >>>     PropertyConfigurator.configure(log4jURL);
> > > > >>>
> > > > >>> In log4j2 this method is deprecated and I found some
> alternatives,
> > > but
> > > > any of them worked.
> > > > >>> Solution one:
> > > > >>> Set this property in my first line of code:
> > > > >>> System.setProperty("log4j.configurationFile",Log4java2FileName);
> > > > >>>              It not works in my Websphere Application Server
> > because
> > > > log4j2 try to charge before my first web app line of code.
> > > > >>> Solution two:
> > > > >>>                               using java -D option which sets a
> > > system
> > > > property on server start.
> > > > >>>                               It not works in my Websphere
> > > Application
> > > > Server because it is an application server with other applications
> and
> > we
> > > > share the node, this change can affect to other apps.
> > > > >>> Solution three:
> > > > >>> Using an recharge of properties from custom XML properties:
> > > > >>> InputStream log4javaFile =
> > > > getClass().getClassLoader().getResourceAsStream(Log4java2FileName);
> > > > >>>           ConfigurationSource configuration =
> > > > newConfigurationSource(log4javaFile);
> > > > >>> Configurator.initialize(null, configuration);
> > > > >>> It not works in my project because a regret to include this code
> in
> > > my
> > > > InitContext (first point of code), this change only affect in some
> > class,
> > > > not in all context. (I have different servlets in my application and
> > > there
> > > > are not affected by this change)
> > > > >>>
> > > > >>> Question:
> > > > >>>               Is there an easy alternative for adjusting the
> > > > properties file? (some like slf4j configuration)
> > > > >>>
> > > > >>> I would be very grateful if you could help me because I can not
> > find
> > > a
> > > > solution and I would like to be able to use the new log4j2.
> > > > >>> Best regards!
> > > > >>
> > > > >
> > > >
> > > >
> > >
> > > --
> > > Matt Sicker <[hidden email]>
> > >
> >
>
>
> --
> Matt Sicker <[hidden email]>
>
Reply | Threaded
Open this post in threaded view
|

Re: Problem with log4j2.configurationFile. Using log4j2.properties with custom file name.

Leo R
Hi!
i actived log4j.debug and i give this: log4javaDebug.txt
In this debug logs my custom file is charged but log4j2 do the reconfiguration:

 DEBUG StatusLogger Reconfiguration started for context[name=1e163e2] at URI null (org.apache.logging.log4j.core.LoggerContext@139ae54a) with optional ClassLoader: null

I have this configuration at the start of web.xml:
<context-param>
        <param-name>isLog4jAutoInitializationDisabled</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>log4jContextName</param-name>
        <param-value>mdes</param-value>
    </context-param>
    <context-param>
        <param-name>log4jConfiguration</param-name>
        <param-value>classpath:conf-hub-digital-log4j2.xml</param-value>
    </context-param>
     <listener>
        <listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>
    </listener>
 
    <filter>
        <filter-name>log4jServletFilter</filter-name>
        <filter-class>org.apache.logging.log4j.web.Log4jServletFilter</filter-class>
    </filter>

Please could you help me?
Why <context-param>
        <param-name>isLog4jAutoInitializationDisabled</param-name>
        <param-value>true</param-value>
    </context-param> 
is not disabling the reconfiguration?

Best Regards!

El jue., 13 dic. 2018 a las 17:30, Leo R (<[hidden email]>) escribió:

Hi all!

I have 5 web.xml because i have different maven projects inside my main project.

Main:

·         main-core

·         main-app

·         main-web (in this web.xml I am writing my configuration)

·         child-name1-core

·         child-name1-web

·         child-name2-core

·         child-name2-web

·         child-name3-core

·         child-name3-web

·         child-name4-core

·         child-name4-web

 

I have servlet 3.1 and I think that the problem is the context.

I tried to use isLog4jAutoInitializationDisabled in all web.xml except main-web (in this web.xml setting all following Servlet 2.5 Web Applications from http://logging.apache.org/log4j/2.x/manual/webapp.html because you say that in case of isLog4jAutoInitializationDisabled you need to have the same configuration of servlet 2.5):

1.   <context-param>

2.  <param-name>isLog4jAutoInitializationDisabled</param-name>

3.  <param-value>true</param-value>

4.  </context-param>

And this solution not found.

 

Why is not included some configuration like:

 URL log4jURL = Loader.getResource(Log4javaFileName);
 if (log4jURL == null) {
      throw new Exception();
}
PropertyConfigurator.configure(log4jURL);

?

Could you help me, please?

Thanks for all support.


El vie., 7 dic. 2018 a las 16:36, Matt Sicker (<[hidden email]>) escribió:
Could you define the system property "log4j2.debug" and include the debug
log info?

On Fri, 7 Dec 2018 at 02:59, Leo R <[hidden email]> wrote:

> Hi!
> Yes i included core, api and web.
> I tested:
> log4j2-name.xml ->not found
> Property on web.xml -> not found
> Could you give more ideas please?
>
> El El mié, 5 dic 2018 a las 23:28, Matt Sicker <[hidden email]>
> escribió:
>
> > Are you including log4j-web in your war as well?
> >
> > On Wed, 5 Dec 2018 at 10:43, paginas <[hidden email]> wrote:
> >
> > > I added in my web.xml
> > > <context-param>
> > >         <param-name>log4jConfiguration</param-name>
> > >         <param-value>file:///C:/
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>name
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>src
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/particularName/
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>configuracion
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>entorno
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>conf
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>-especial-name-log4j2.properties
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E></
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>param-value
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>>
> > >
> >
> <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>
> > >     </context-param>
> > >
> > > And my application not works
> > >
> > > Could you give more support please?
> > >
> > > > El 5 dic 2018, a las 16:27, Ralph Goers <[hidden email]>
> > > escribió:
> > > >
> > > > Even simpler. Just name the file "log4j2-name.xml” where “name” is
> the
> > > name of the web application.
> > > >
> > > > Ralph
> > > >
> > > >> On Dec 5, 2018, at 8:23 AM, Ralph Goers <[hidden email]
> >
> > > wrote:
> > > >>
> > > >> From what you are describing I would set log4jConfiguration in your
> > web
> > > application’s web.xml as a context parameter. See
> > > http://logging.apache.org/log4j/2.x/manual/webapp.html <
> > > http://logging.apache.org/log4j/2.x/manual/webapp.html>.
> > > >>
> > > >> Ralph
> > > >>
> > > >>
> > > >>> On Dec 5, 2018, at 7:54 AM, paginas <[hidden email]
> > > <mailto:[hidden email]>> wrote:
> > > >>>
> > > >>> Dear Log4j Team,
> > > >>>
> > > >>> First of all, thanks for your work. I am Leo, an Spanish web
> > developer
> > > that need some help.
> > > >>>
> > > >>> I am migrating one of our project from slf4j v. 1.7.21 to log4j
> > > v.2.11.1 and I have this problem:
> > > >>>
> > > >>> -In my web project, we need to have the log4j.configurationFile
> with
> > a
> > > particular name: Particular_web_app_log4j2.properties (example name)
> > > >>>
> > > >>> We cannot set the default log4j2.properties, log4j2.xml, etc in our
> > > repository.
> > > >>> In slf4j we solved this situation with this code. (with this, all
> > sl4j
> > > configuration is loaded from our custom log4j.properties):
> > > >>>
> > > >>>     URL log4jURL = Loader.getResource(Log4javaFileName);
> > > >>>     if (log4jURL == null) {
> > > >>>           throw new Exception();
> > > >>>     }
> > > >>>     PropertyConfigurator.configure(log4jURL);
> > > >>>
> > > >>> In log4j2 this method is deprecated and I found some alternatives,
> > but
> > > any of them worked.
> > > >>> Solution one:
> > > >>> Set this property in my first line of code:
> > > >>> System.setProperty("log4j.configurationFile",Log4java2FileName);
> > > >>>              It not works in my Websphere Application Server
> because
> > > log4j2 try to charge before my first web app line of code.
> > > >>> Solution two:
> > > >>>                               using java -D option which sets a
> > system
> > > property on server start.
> > > >>>                               It not works in my Websphere
> > Application
> > > Server because it is an application server with other applications and
> we
> > > share the node, this change can affect to other apps.
> > > >>> Solution three:
> > > >>> Using an recharge of properties from custom XML properties:
> > > >>> InputStream log4javaFile =
> > > getClass().getClassLoader().getResourceAsStream(Log4java2FileName);
> > > >>>           ConfigurationSource configuration =
> > > newConfigurationSource(log4javaFile);
> > > >>> Configurator.initialize(null, configuration);
> > > >>> It not works in my project because a regret to include this code in
> > my
> > > InitContext (first point of code), this change only affect in some
> class,
> > > not in all context. (I have different servlets in my application and
> > there
> > > are not affected by this change)
> > > >>>
> > > >>> Question:
> > > >>>               Is there an easy alternative for adjusting the
> > > properties file? (some like slf4j configuration)
> > > >>>
> > > >>> I would be very grateful if you could help me because I can not
> find
> > a
> > > solution and I would like to be able to use the new log4j2.
> > > >>> Best regards!
> > > >>
> > > >
> > >
> > >
> >
> > --
> > Matt Sicker <[hidden email]>
> >
>


--
Matt Sicker <[hidden email]>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

log4javaDebug.txt (72K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem with log4j2.configurationFile. Using log4j2.properties with custom file name.

Ralph Goers
I don’t think I completely understand what is going on in your app server. It appears that you have one application that is starting up with a LoggerContext name of custom name and uses classpath:conf-customname-digital-log4j2.xml for its configuration. I then see it trying to configure Log4j for a second Log4j context with a name of 1e163e2 which doesn't have any configuration configured for it.  At the end you seem to have two Logging configurations setup, presumably for different applications.

Ralph

> On Dec 19, 2018, at 6:30 AM, Leo R <[hidden email]> wrote:
>
> Hi!
> i actived log4j.debug and i give this: log4javaDebug.txt
> In this debug logs my custom file is charged but log4j2 do the reconfiguration:
>
>  DEBUG StatusLogger Reconfiguration started for context[name=1e163e2] at URI null (org.apache.logging.log4j.core.LoggerContext@139ae54a) with optional ClassLoader: null
>
> I have this configuration at the start of web.xml:
> <context-param>
>         <param-name>isLog4jAutoInitializationDisabled</param-name>
>         <param-value>true</param-value>
>     </context-param>
>     <context-param>
>         <param-name>log4jContextName</param-name>
>         <param-value>mdes</param-value>
>     </context-param>
>     <context-param>
>         <param-name>log4jConfiguration</param-name>
>         <param-value>classpath:conf-hub-digital-log4j2.xml</param-value>
>     </context-param>
>      <listener>
>         <listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>
>     </listener>
>  
>     <filter>
>         <filter-name>log4jServletFilter</filter-name>
>         <filter-class>org.apache.logging.log4j.web.Log4jServletFilter</filter-class>
>     </filter>
>
> Please could you help me?
> Why <context-param>
>         <param-name>isLog4jAutoInitializationDisabled</param-name>
>         <param-value>true</param-value>
>     </context-param>
> is not disabling the reconfiguration?
>
> Best Regards!
>
> El jue., 13 dic. 2018 a las 17:30, Leo R (<[hidden email] <mailto:[hidden email]>>) escribió:
> Hi all!
> I have 5 web.xml because i have different maven projects inside my main project.
> Main:
> ·         main-core
> ·         main-app
> ·         main-web (in this web.xml I am writing my configuration)
> ·         child-name1-core
> ·         child-name1-web
> ·         child-name2-core
> ·         child-name2-web
> ·         child-name3-core
> ·         child-name3-web
> ·         child-name4-core
> ·         child-name4-web
>  
> I have servlet 3.1 and I think that the problem is the context.
> I tried to use isLog4jAutoInitializationDisabled in all web.xml except main-web (in this web.xml setting all following Servlet 2.5 Web Applications from http://logging.apache.org/log4j/2.x/manual/webapp.html <http://logging.apache.org/log4j/2.x/manual/webapp.html> because you say that in case of isLog4jAutoInitializationDisabled you need to have the same configuration of servlet 2.5):
>
> 1.   <context-param>
>
> 2.  <param-name>isLog4jAutoInitializationDisabled</param-name>
>
> 3.  <param-value>true</param-value>
>
> 4.  </context-param>
>
> And this solution not found.
>  
> Why is not included some configuration like:
>  URL log4jURL = Loader.getResource(Log4javaFileName);
>  if (log4jURL == null) {
>       throw new Exception();
> }
> PropertyConfigurator.configure(log4jURL);
> ?
>
> Could you help me, please?
>
> Thanks for all support.
>
>
> El vie., 7 dic. 2018 a las 16:36, Matt Sicker (<[hidden email] <mailto:[hidden email]>>) escribió:
> Could you define the system property "log4j2.debug" and include the debug
> log info?
>
> On Fri, 7 Dec 2018 at 02:59, Leo R <[hidden email] <mailto:[hidden email]>> wrote:
>
> > Hi!
> > Yes i included core, api and web.
> > I tested:
> > log4j2-name.xml ->not found
> > Property on web.xml -> not found
> > Could you give more ideas please?
> >
> > El El mié, 5 dic 2018 a las 23:28, Matt Sicker <[hidden email] <mailto:[hidden email]>>
> > escribió:
> >
> > > Are you including log4j-web in your war as well?
> > >
> > > On Wed, 5 Dec 2018 at 10:43, paginas <[hidden email] <mailto:[hidden email]>> wrote:
> > >
> > > > I added in my web.xml
> > > > <context-param>
> > > >         <param-name>log4jConfiguration</param-name>
> > > >         <param-value>file:///C:/
> > > >
> > >
> > <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>name
> > > >
> > >
> > <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> > > >
> > >
> > <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>src
> > > >
> > >
> > <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/particularName/
> > > >
> > >
> > <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>configuracion
> > > >
> > >
> > <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> > > >
> > >
> > <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>entorno
> > > >
> > >
> > <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>/
> > > >
> > >
> > <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>conf
> > > >
> > >
> > <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>-especial-name-log4j2.properties
> > > >
> > >
> > <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E></
> > > >
> > >
> > <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>param-value
> > > >
> > >
> > <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>>
> > > >
> > >
> > <file:///C:/name/src/particularName/configuracion/entorno/conf-especial-name-log4j2.properties%3C/param-value%3E>
> > > >     </context-param>
> > > >
> > > > And my application not works
> > > >
> > > > Could you give more support please?
> > > >
> > > > > El 5 dic 2018, a las 16:27, Ralph Goers <[hidden email] <mailto:[hidden email]>>
> > > > escribió:
> > > > >
> > > > > Even simpler. Just name the file "log4j2-name.xml” where “name” is
> > the
> > > > name of the web application.
> > > > >
> > > > > Ralph
> > > > >
> > > > >> On Dec 5, 2018, at 8:23 AM, Ralph Goers <[hidden email] <mailto:[hidden email]>
> > >
> > > > wrote:
> > > > >>
> > > > >> From what you are describing I would set log4jConfiguration in your
> > > web
> > > > application’s web.xml as a context parameter. See
> > > > http://logging.apache.org/log4j/2.x/manual/webapp.html <http://logging.apache.org/log4j/2.x/manual/webapp.html> <
> > > > http://logging.apache.org/log4j/2.x/manual/webapp.html <http://logging.apache.org/log4j/2.x/manual/webapp.html>>.
> > > > >>
> > > > >> Ralph
> > > > >>
> > > > >>
> > > > >>> On Dec 5, 2018, at 7:54 AM, paginas <[hidden email] <mailto:[hidden email]>
> > > > <mailto:[hidden email] <mailto:[hidden email]>>> wrote:
> > > > >>>
> > > > >>> Dear Log4j Team,
> > > > >>>
> > > > >>> First of all, thanks for your work. I am Leo, an Spanish web
> > > developer
> > > > that need some help.
> > > > >>>
> > > > >>> I am migrating one of our project from slf4j v. 1.7.21 to log4j
> > > > v.2.11.1 and I have this problem:
> > > > >>>
> > > > >>> -In my web project, we need to have the log4j.configurationFile
> > with
> > > a
> > > > particular name: Particular_web_app_log4j2.properties (example name)
> > > > >>>
> > > > >>> We cannot set the default log4j2.properties, log4j2.xml, etc in our
> > > > repository.
> > > > >>> In slf4j we solved this situation with this code. (with this, all
> > > sl4j
> > > > configuration is loaded from our custom log4j.properties):
> > > > >>>
> > > > >>>     URL log4jURL = Loader.getResource(Log4javaFileName);
> > > > >>>     if (log4jURL == null) {
> > > > >>>           throw new Exception();
> > > > >>>     }
> > > > >>>     PropertyConfigurator.configure(log4jURL);
> > > > >>>
> > > > >>> In log4j2 this method is deprecated and I found some alternatives,
> > > but
> > > > any of them worked.
> > > > >>> Solution one:
> > > > >>> Set this property in my first line of code:
> > > > >>> System.setProperty("log4j.configurationFile",Log4java2FileName);
> > > > >>>              It not works in my Websphere Application Server
> > because
> > > > log4j2 try to charge before my first web app line of code.
> > > > >>> Solution two:
> > > > >>>                               using java -D option which sets a
> > > system
> > > > property on server start.
> > > > >>>                               It not works in my Websphere
> > > Application
> > > > Server because it is an application server with other applications and
> > we
> > > > share the node, this change can affect to other apps.
> > > > >>> Solution three:
> > > > >>> Using an recharge of properties from custom XML properties:
> > > > >>> InputStream log4javaFile =
> > > > getClass().getClassLoader().getResourceAsStream(Log4java2FileName);
> > > > >>>           ConfigurationSource configuration =
> > > > newConfigurationSource(log4javaFile);
> > > > >>> Configurator.initialize(null, configuration);
> > > > >>> It not works in my project because a regret to include this code in
> > > my
> > > > InitContext (first point of code), this change only affect in some
> > class,
> > > > not in all context. (I have different servlets in my application and
> > > there
> > > > are not affected by this change)
> > > > >>>
> > > > >>> Question:
> > > > >>>               Is there an easy alternative for adjusting the
> > > > properties file? (some like slf4j configuration)
> > > > >>>
> > > > >>> I would be very grateful if you could help me because I can not
> > find
> > > a
> > > > solution and I would like to be able to use the new log4j2.
> > > > >>> Best regards!
> > > > >>
> > > > >
> > > >
> > > >
> > >
> > > --
> > > Matt Sicker <[hidden email] <mailto:[hidden email]>>
> > >
> >
>
>
> --
> Matt Sicker <[hidden email] <mailto:[hidden email]>>
> <log4javaDebug.txt>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Regarding log4j2 monitor interval

Bhavesh Patel
 Hi,    I have a question about monitor interval on log4j2 configuration file. I know that the monitor interval will work if anything is directly updated in the configuration file. Is there a way to track updates made to any lookups referred in the configuration file using monitor interval?   Our issue if that we are using a Kafka Appender and have removed the Kafka bootstrap servers and topic names in a separate abc.properties file. From log4j2.xml, we do a bundle lookup to abc and get the value for Kafka bootstrap server and topic names. We have monitor interval set on log4j2.xml but since Kafka bootstrap server and topic names are not in this file, any updated made to them in the abc.properties file will not be picked up by monitor interval unless the application is restarted.    Anyone faced this issue or can suggest any solution for this?
Thanks,Bhavesh. 
Reply | Threaded
Open this post in threaded view
|

Re: Regarding log4j2 monitor interval

Matt Sicker
I'm also interested in this idea. My current workaround that I'm using for
refreshing system properties (for example) is to call
LoggerContext.getContext(false).reconfigure() after updating lookup values.
I'd imagine we'd need a new API to support the configuration being notified
of lookup value changes to avoid this, though.

On Thu, 20 Dec 2018 at 16:18, Bhavesh Patel <[hidden email]>
wrote:

>  Hi,    I have a question about monitor interval on log4j2 configuration
> file. I know that the monitor interval will work if anything is directly
> updated in the configuration file. Is there a way to track updates made to
> any lookups referred in the configuration file using monitor interval?
>  Our issue if that we are using a Kafka Appender and have removed the Kafka
> bootstrap servers and topic names in a separate abc.properties file. From
> log4j2.xml, we do a bundle lookup to abc and get the value for Kafka
> bootstrap server and topic names. We have monitor interval set on
> log4j2.xml but since Kafka bootstrap server and topic names are not in this
> file, any updated made to them in the abc.properties file will not be
> picked up by monitor interval unless the application is restarted.
> Anyone faced this issue or can suggest any solution for this?
> Thanks,Bhavesh.



--
Matt Sicker <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Regarding log4j2 monitor interval

Ralph Goers
If you haven’t created a Jira issue for this please do. I need to make modifications to the current file watching logic as I need to be able to monitor configurations external to the application, such as in Spring cloud or possibly even in a git repo. It may be that we will want to add a list of paths or urls to monitor in the configuration.

Ralph

> On Dec 21, 2018, at 8:49 AM, Matt Sicker <[hidden email]> wrote:
>
> I'm also interested in this idea. My current workaround that I'm using for
> refreshing system properties (for example) is to call
> LoggerContext.getContext(false).reconfigure() after updating lookup values.
> I'd imagine we'd need a new API to support the configuration being notified
> of lookup value changes to avoid this, though.
>
> On Thu, 20 Dec 2018 at 16:18, Bhavesh Patel <[hidden email]>
> wrote:
>
>> Hi,    I have a question about monitor interval on log4j2 configuration
>> file. I know that the monitor interval will work if anything is directly
>> updated in the configuration file. Is there a way to track updates made to
>> any lookups referred in the configuration file using monitor interval?
>> Our issue if that we are using a Kafka Appender and have removed the Kafka
>> bootstrap servers and topic names in a separate abc.properties file. From
>> log4j2.xml, we do a bundle lookup to abc and get the value for Kafka
>> bootstrap server and topic names. We have monitor interval set on
>> log4j2.xml but since Kafka bootstrap server and topic names are not in this
>> file, any updated made to them in the abc.properties file will not be
>> picked up by monitor interval unless the application is restarted.
>> Anyone faced this issue or can suggest any solution for this?
>> Thanks,Bhavesh.
>
>
>
> --
> Matt Sicker <[hidden email]>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Regarding log4j2 monitor interval

Bhavesh Patel
 Created a JIRA issue (https://issues.apache.org/jira/browse/LOG4J2-2526). I have put in the basic information. Please feel free to update it as needed.
Thanks,Bhavesh.

    On Friday, December 21, 2018, 8:36:01 AM PST, Ralph Goers <[hidden email]> wrote:  
 
 If you haven’t created a Jira issue for this please do. I need to make modifications to the current file watching logic as I need to be able to monitor configurations external to the application, such as in Spring cloud or possibly even in a git repo. It may be that we will want to add a list of paths or urls to monitor in the configuration.

Ralph

> On Dec 21, 2018, at 8:49 AM, Matt Sicker <[hidden email]> wrote:
>
> I'm also interested in this idea. My current workaround that I'm using for
> refreshing system properties (for example) is to call
> LoggerContext.getContext(false).reconfigure() after updating lookup values.
> I'd imagine we'd need a new API to support the configuration being notified
> of lookup value changes to avoid this, though.
>
> On Thu, 20 Dec 2018 at 16:18, Bhavesh Patel <[hidden email]>
> wrote:
>
>> Hi,    I have a question about monitor interval on log4j2 configuration
>> file. I know that the monitor interval will work if anything is directly
>> updated in the configuration file. Is there a way to track updates made to
>> any lookups referred in the configuration file using monitor interval?
>> Our issue if that we are using a Kafka Appender and have removed the Kafka
>> bootstrap servers and topic names in a separate abc.properties file. From
>> log4j2.xml, we do a bundle lookup to abc and get the value for Kafka
>> bootstrap server and topic names. We have monitor interval set on
>> log4j2.xml but since Kafka bootstrap server and topic names are not in this
>> file, any updated made to them in the abc.properties file will not be
>> picked up by monitor interval unless the application is restarted.
>> Anyone faced this issue or can suggest any solution for this?
>> Thanks,Bhavesh.
>
>
>
> --
> Matt Sicker <[hidden email]>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
 
Reply | Threaded
Open this post in threaded view
|

Re: Regarding log4j2 monitor interval

Bhavesh Patel-2
In reply to this post by Matt Sicker
 Thanks Matt.
Regards,Bhavesh.
    On Friday, December 21, 2018, 7:50:44 AM PST, Matt Sicker <[hidden email]> wrote:  
 
 I'm also interested in this idea. My current workaround that I'm using for
refreshing system properties (for example) is to call
LoggerContext.getContext(false).reconfigure() after updating lookup values.
I'd imagine we'd need a new API to support the configuration being notified
of lookup value changes to avoid this, though.

On Thu, 20 Dec 2018 at 16:18, Bhavesh Patel <[hidden email]>
wrote:

>  Hi,    I have a question about monitor interval on log4j2 configuration
> file. I know that the monitor interval will work if anything is directly
> updated in the configuration file. Is there a way to track updates made to
> any lookups referred in the configuration file using monitor interval?
>  Our issue if that we are using a Kafka Appender and have removed the Kafka
> bootstrap servers and topic names in a separate abc.properties file. From
> log4j2.xml, we do a bundle lookup to abc and get the value for Kafka
> bootstrap server and topic names. We have monitor interval set on
> log4j2.xml but since Kafka bootstrap server and topic names are not in this
> file, any updated made to them in the abc.properties file will not be
> picked up by monitor interval unless the application is restarted.
> Anyone faced this issue or can suggest any solution for this?
> Thanks,Bhavesh.



--
Matt Sicker <[hidden email]>