You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Thomas Rohde <tr...@ordix.de> on 2019/02/20 13:00:18 UTC

Logging web applications with log4j 1.2

Hi!

I've some basic questions regarding the usage of log4j 1.2 in Tomcat 8.5.

We are running more than one web application in Tomcat. Each application uses log4j via slf4j and ships the log4j.jar in WEB-INF/lib. The Tomcat itself uses JULI.

We are using a common log4j.xml file for configuration.

The file path is set as system property in CATALINA_OPTS as follows:
-Dlog4j.configuration=/path/to/file/log4j.xml

1. Is this a valid setup or are there any side effects in initialization log4j by the different WebAppClassLoaders?

2. We are observing weird things in rolling the files hourly. The timestamp of the log messages doesn't fit to the timestamp suffix of the file. Why does this happen?

Regards,
Thomas



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Logging web applications with log4j 1.2

Posted by John Dale <jc...@gmail.com>.
I'm using 7.x still .. I put my log4j file in the classes folder of my web app.

On 2/20/19, Thomas Rohde <tr...@ordix.de> wrote:
> Hi!
>
> I've some basic questions regarding the usage of log4j 1.2 in Tomcat 8.5.
>
> We are running more than one web application in Tomcat. Each application
> uses log4j via slf4j and ships the log4j.jar in WEB-INF/lib. The Tomcat
> itself uses JULI.
>
> We are using a common log4j.xml file for configuration.
>
> The file path is set as system property in CATALINA_OPTS as follows:
> -Dlog4j.configuration=/path/to/file/log4j.xml
>
> 1. Is this a valid setup or are there any side effects in initialization
> log4j by the different WebAppClassLoaders?
>
> 2. We are observing weird things in rolling the files hourly. The timestamp
> of the log messages doesn't fit to the timestamp suffix of the file. Why
> does this happen?
>
> Regards,
> Thomas
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


AW: AW: Logging web applications with log4j 1.2

Posted by Thomas Rohde <tr...@ordix.de>.
Hi Chris,

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> Thomas,
> 
> On 2/21/19 07:20, Thomas Rohde wrote:
> > Hi Chris,
> > 
> > -----Ursprüngliche Nachricht----- Von: Christopher Schultz 
> > [mailto:chris@christopherschultz.net] Gesendet: Mittwoch, 20.
> > Februar 2019 16:41 An: users@tomcat.apache.org Betreff: Re: Logging 
> > web applications with log4j 1.2
> > 
> >>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
> >>> 
> >>> Thomas,
> >>> 
> >>> On 2/20/19 08:00, Thomas Rohde wrote:
> >>>> I've some basic questions regarding the usage of log4j 1.2 in 
> >>>> Tomcat 8.5.
> >>>> 
> >>>> We are running more than one web application in Tomcat. Each  
> >>>> application uses log4j via slf4j and ships the log4j.jar in
> >>>> 
> >>> WEB-INF/lib. The Tomcat itself uses JULI.
> >>> 
> >>> We are using a common log4j.xml file for configuration.
> >>> 
> >>> The file path is set as system property in CATALINA_OPTS as
> >>> follows: -Dlog4j.configuration=/path/to/file/log4j.xml
> >>> 
> >>> 1. Is this a valid setup or are there any side effects in 
> >>> initialization log4j by the different WebAppClassLoaders?
> >> 
> >> You are not using classpath-based config-file-loading, so it should 
> >> not be a problem[*].
> >> 
> >>> 2. We are observing weird things in rolling the files hourly.
> >>> The timestamp of the log messages doesn't fit to the timestamp 
> >>> suffix of the file. Why does this happen?
> >> 
> >> Possibly conflicting time zones, somewhere? Because log4j.jar is in 
> >> each application's class loader, they CAN have different in-memory 
> >> configurations.
> > No there are no different time zones in use.
> 
> That's what I figured. I've never see anything quite like you describe. I could imagine that the JVM has one time zone but the shell is using another.
> 
> For example, if the JVM is convinced that the time zone is UTC but when you are logged-into the server, your shell has TZ=America/Los_Angeles, then you'll see a ~9 hour difference between file timestamps and the filenames. Like this:
> 
> $ ls -l logs/
> 
> - -rw-r--r--   12345 Feb 19 16:01 log4j.log.2019-02-18
> - -rw-r--r--   12345 Feb 20 16:00 log4j.log.2019-02-19
> - -rw-r--r--   12345 Feb 21 16:01 log4j.log.2019-02-20
> 
> Note how each filename has the name you'd expect, but the timestamp looks a little odd. If you look into each file, you'd see that e.g. in the 2019-02-19 file, the timestamps go from 2019-02-19T00:00:00 through 2019-02-19T23:59:59 but it looks like the file was rotated 8 hours earlier. That's because it was rotated at 00:00 (PST) as reckoned by the JVM, but at 16:01 in UTC.
> 
> My recommendation would be to set all of your timezones to the same thing. UTC makes the most sense to me, but that's just my opinion.
> Theoretically, all timestamps are interchangeable, right?

Thank you for the hint. We will check that!

> 
> >> [*] While this will work, why would you ever want multiple 
> >> applications to have their logging configuration all tied together? 
> >> Why not separate the logging configuration into one config-per web 
> >> application? OR are you trying to unify all logging into the same 
> >> file(s )?
> > Yes I would like to do that, but I'm not sure how to achieve it 
> > without putting the log4j.xml into the WAR file. Do you have any hint?
> I can think of several ways, but it depends upon how your application initializes log4j.
> 
> If you specify where the configuration file is, directly, then you can either change that to somewhere else, or you can replace that filename with a parameter that you can set in web.xml -- say, in an <init-param>. You *are* configuring log4j in a ServletContextInitializer, right?
> 
> If you just do "new PropertyConfigurator()" (like I do), then it will search the parent ClassLoader and that's it. In that case, you'll have to arrange for the log4j.properties file to be present, there. Placing it in the WAR file is an option. Another option would be to put the file elsewhere, but then modify the Tomcat configuration to add another directory to the ClassLoader, like this:
> 
> <Context>
>   <Resources>
>     <PostResources
>       webAppMount="/"
>         base="/path/to/app-specific-log-dir"
>         className="org.apache.catalina.webresources.DirResourceSet"
>   </Resources>
> </Context>
> 
> Then you put your log4j.properties file in /path/to/app-specific-log-dir .

Yeah, in the meantime, I have already thougt about this solution. We will do some tests. Thank you!

> 
> Hope that helps,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
> 
> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlxuv/0ACgkQHPApP6U8
> pFiiTA/+MesYHVHy1lHSzhxLylGC9q/vLXu2wykUQysUBh0GCbHqnftzytV5gKrd
> GBwsPbbFSveGcn6VkhL/mJZJPsHAxGWB6pgoK4rYsjw1qVfUeDWr2XeC7AAVNFMC
> 0BXyS99u5CC0jlh+/Ps/SZMOZAby/hGfTuoFRD4VT6K3MmgtdAsbGVcci+ycLSLd
> tOKWmxglu/0ylEc4fmxBDPygvmve/FD+elfSyqZ8VBri6UTlae++qcsnmBSeus8y
> KqiHiZCWrZsn55FBhAsEJXQ1tvluxhpNYrcleEVXM/KZcH/g7eyNGdelFMJ4UVyk
> cEM9dfWJdi74RJlZNN03CIWjJawI7IVZg0ghU/2C0ErwXlfjecA2vW0HZE2z/XtO
> v+vJW2PXcM/pVef+Af5kf+f8wFGWeAaFVQhwQeSFEZQnG8Mfi8VaQifZd8X+ho9f
> SshOywKZ4vDb2VmJrhg3aMwu9Q2BtggA+7fZ0n0/wJJJHj7qC9W8OI35hacSJJ1d
> U+USkNNo9vhoF6/wqU+NCMxj7sApEJyIgR4+Vcfl4MFnMaVRthc1WsOiTraW6RuS
> G7IJm1z/pSSjqR+Age2/0F/zAAqknjVmCxKzuQIIv66K6PYV4UncRJY0r9bSnMx6
> 43eGJmG+wTcH+R7IAXEi0+r9zVb7UbK6kqpvfD9SpFWD3Ijlb8Y=
> =BT+f
> -----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: AW: Logging web applications with log4j 1.2

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Thomas,

On 2/21/19 07:20, Thomas Rohde wrote:
> Hi Chris,
> 
> -----Ursprüngliche Nachricht----- Von: Christopher Schultz
> [mailto:chris@christopherschultz.net] Gesendet: Mittwoch, 20.
> Februar 2019 16:41 An: users@tomcat.apache.org Betreff: Re: Logging
> web applications with log4j 1.2
> 
>>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
>>> 
>>> Thomas,
>>> 
>>> On 2/20/19 08:00, Thomas Rohde wrote:
>>>> I've some basic questions regarding the usage of log4j 1.2 in
>>>> Tomcat 8.5.
>>>> 
>>>> We are running more than one web application in Tomcat. Each
>>>>  application uses log4j via slf4j and ships the log4j.jar in
>>>> 
>>> WEB-INF/lib. The Tomcat itself uses JULI.
>>> 
>>> We are using a common log4j.xml file for configuration.
>>> 
>>> The file path is set as system property in CATALINA_OPTS as 
>>> follows: -Dlog4j.configuration=/path/to/file/log4j.xml
>>> 
>>> 1. Is this a valid setup or are there any side effects in 
>>> initialization log4j by the different WebAppClassLoaders?
>> 
>> You are not using classpath-based config-file-loading, so it
>> should not be a problem[*].
>> 
>>> 2. We are observing weird things in rolling the files hourly.
>>> The timestamp of the log messages doesn't fit to the timestamp
>>> suffix of the file. Why does this happen?
>> 
>> Possibly conflicting time zones, somewhere? Because log4j.jar is
>> in each application's class loader, they CAN have different
>> in-memory configurations.
> No there are no different time zones in use.

That's what I figured. I've never see anything quite like you
describe. I could imagine that the JVM has one time zone but the shell
is using another.

For example, if the JVM is convinced that the time zone is UTC but
when you are logged-into the server, your shell has
TZ=America/Los_Angeles, then you'll see a ~9 hour difference between
file timestamps and the filenames. Like this:

$ ls -l logs/

- -rw-r--r--   12345 Feb 19 16:01 log4j.log.2019-02-18
- -rw-r--r--   12345 Feb 20 16:00 log4j.log.2019-02-19
- -rw-r--r--   12345 Feb 21 16:01 log4j.log.2019-02-20

Note how each filename has the name you'd expect, but the timestamp
looks a little odd. If you look into each file, you'd see that e.g. in
the 2019-02-19 file, the timestamps go from 2019-02-19T00:00:00
through 2019-02-19T23:59:59 but it looks like the file was rotated 8
hours earlier. That's because it was rotated at 00:00 (PST) as
reckoned by the JVM, but at 16:01 in UTC.

My recommendation would be to set all of your timezones to the same
thing. UTC makes the most sense to me, but that's just my opinion.
Theoretically, all timestamps are interchangeable, right?

>> [*] While this will work, why would you ever want multiple 
>> applications to have their logging configuration all tied 
>> together? Why not separate the logging configuration into one 
>> config-per web application? OR are you trying to unify all
>> logging into the same file(s )?
> Yes I would like to do that, but I'm not sure how to achieve it 
> without putting the log4j.xml into the WAR file. Do you have any 
> hint?
I can think of several ways, but it depends upon how your application
initializes log4j.

If you specify where the configuration file is, directly, then you can
either change that to somewhere else, or you can replace that filename
with a parameter that you can set in web.xml -- say, in an
<init-param>. You *are* configuring log4j in a
ServletContextInitializer, right?

If you just do "new PropertyConfigurator()" (like I do), then it will
search the parent ClassLoader and that's it. In that case, you'll have
to arrange for the log4j.properties file to be present, there. Placing
it in the WAR file is an option. Another option would be to put the
file elsewhere, but then modify the Tomcat configuration to add
another directory to the ClassLoader, like this:

<Context>
  <Resources>
    <PostResources
      webAppMount="/"
        base="/path/to/app-specific-log-dir"
        className="org.apache.catalina.webresources.DirResourceSet"
  </Resources>
</Context>

Then you put your log4j.properties file in /path/to/app-specific-log-dir
.

Hope that helps,
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlxuv/0ACgkQHPApP6U8
pFiiTA/+MesYHVHy1lHSzhxLylGC9q/vLXu2wykUQysUBh0GCbHqnftzytV5gKrd
GBwsPbbFSveGcn6VkhL/mJZJPsHAxGWB6pgoK4rYsjw1qVfUeDWr2XeC7AAVNFMC
0BXyS99u5CC0jlh+/Ps/SZMOZAby/hGfTuoFRD4VT6K3MmgtdAsbGVcci+ycLSLd
tOKWmxglu/0ylEc4fmxBDPygvmve/FD+elfSyqZ8VBri6UTlae++qcsnmBSeus8y
KqiHiZCWrZsn55FBhAsEJXQ1tvluxhpNYrcleEVXM/KZcH/g7eyNGdelFMJ4UVyk
cEM9dfWJdi74RJlZNN03CIWjJawI7IVZg0ghU/2C0ErwXlfjecA2vW0HZE2z/XtO
v+vJW2PXcM/pVef+Af5kf+f8wFGWeAaFVQhwQeSFEZQnG8Mfi8VaQifZd8X+ho9f
SshOywKZ4vDb2VmJrhg3aMwu9Q2BtggA+7fZ0n0/wJJJHj7qC9W8OI35hacSJJ1d
U+USkNNo9vhoF6/wqU+NCMxj7sApEJyIgR4+Vcfl4MFnMaVRthc1WsOiTraW6RuS
G7IJm1z/pSSjqR+Age2/0F/zAAqknjVmCxKzuQIIv66K6PYV4UncRJY0r9bSnMx6
43eGJmG+wTcH+R7IAXEi0+r9zVb7UbK6kqpvfD9SpFWD3Ijlb8Y=
=BT+f
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Logging web applications with log4j 1.2

Posted by John Dale <jc...@gmail.com>.
1 - DevOps can alleviate this issue .. implicit in the model.
2 - exploded directory deployment would allow you to change log4j
assuming log4j is configured to reload its configuration on change

I'm not sure how classpath contexts are assigned to war files .. but
I'm sure there is way.  Anyone else have a suggestion?

On 2/21/19, Thomas Rohde <tr...@ordix.de> wrote:
> Hi Chris,
>
> -----Ursprüngliche Nachricht-----
> Von: Christopher Schultz [mailto:chris@christopherschultz.net]
> Gesendet: Mittwoch, 20. Februar 2019 16:41
> An: users@tomcat.apache.org
> Betreff: Re: Logging web applications with log4j 1.2
>
>> > -----BEGIN PGP SIGNED MESSAGE-----
>> > Hash: SHA256
>> >
>> > Thomas,
>> >
>> > On 2/20/19 08:00, Thomas Rohde wrote:
>> > > I've some basic questions regarding the usage of log4j 1.2 in Tomcat
>> > > 8.5.
>> > >
>> > > We are running more than one web application in Tomcat. Each
>> > > application uses log4j via slf4j and ships the log4j.jar in
>> > WEB-INF/lib. The Tomcat itself uses JULI.
>> >
>> > We are using a common log4j.xml file for configuration.
>> >
>> > The file path is set as system property in CATALINA_OPTS as
>> > follows: -Dlog4j.configuration=/path/to/file/log4j.xml
>> >
>> > 1. Is this a valid setup or are there any side effects in
>> > initialization log4j by the different WebAppClassLoaders?
>>
>> You are not using classpath-based config-file-loading, so it should not be
>> a problem[*].
>>
>> > 2. We are observing weird things in rolling the files hourly. The
>> > timestamp of the log messages doesn't fit to the timestamp suffix of
>> > the file. Why does this happen?
>>
>> Possibly conflicting time zones, somewhere? Because log4j.jar is in each
>> application's class loader, they CAN have different in-memory
>> configurations.
> No there are no different time zones in use.
>
>>
>> [*] While this will work, why would you ever want multiple applications to
>> have their logging configuration all tied together?
>> Why not separate the logging configuration into one config-per web
>> application? OR are you trying to unify all logging into the same file(s
>> )?
> Yes I would like to do that, but I'm not sure how to achieve it without
> putting the log4j.xml into the WAR file. Do you have any hint?
>
>>
>> - -chris
>> -----BEGIN PGP SIGNATURE-----
>> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
>>
>> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlxtdSUACgkQHPApP6U8
>> pFhxow//T+5ALVYJcljqLxykHND7ZSy9NHf0+a+jnWzlDO5S6oO+bxjso9raJZYC
>> jUG4nhBwuAtD5MWyS04t0UedYUBP+n1iw4aAGs7PrhFgPxLiHZpMOTBBaeDSYgny
>> bI+7GuqOhkiauPA8Jb6guE8SkrT18d9X+k7xzy6puYgqbTws0iwk2yEmSV+KNtXy
>> 0EsVC20KGhU9pCdD7MLSpYX8PaM8sctazxSSVMygL9Ed03WKkJ6BRPavq4ao1uGg
>> V0ZlTQb7f9PRPOXOQzoAlsaWNTCVRKQES82/HHJE/uJG5tg7jnQ5Syjs53FyfVwH
>> 0AtfNpJiOI4LES5ejR7E5JZ8Lx0/J41XwsPO5hOmYaiHHs35EFtozCETNNwjYxcb
>> 245z++YsBw0bnBDRpAFi5Kq5UL8ludo0CqDTfKQSIqrMoNHoiULm4U3niGl2P01w
>> O8k2KrwqtYWu77esh+TpJpXTTaLnEhCc+YWFGWnER3w8WAOHitvjbmAi21gL3NIG
>> 3PJEFEdrNMaoI2h3SkK+DJzuVVJRmXRMV2wduX4+3qGW6l31Jo3ihFiDDdXyGB+b
>> jtpU1JHYfYP+ck8mEXgOvI6RXZEG7R8Ef7ectYuKdhRRpE+S9wx1llZminsxY/fr
>> 0apA+L6paBo9R7EGxJVt237wx/L+tRnfF5raLZoAJrkks7SkWgE=
>> =sjai
>> -----END PGP SIGNATURE-----
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


AW: Logging web applications with log4j 1.2

Posted by Thomas Rohde <tr...@ordix.de>.
Hi Chris,

-----Ursprüngliche Nachricht-----
Von: Christopher Schultz [mailto:chris@christopherschultz.net] 
Gesendet: Mittwoch, 20. Februar 2019 16:41
An: users@tomcat.apache.org
Betreff: Re: Logging web applications with log4j 1.2

> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA256
> > 
> > Thomas,
> > 
> > On 2/20/19 08:00, Thomas Rohde wrote:
> > > I've some basic questions regarding the usage of log4j 1.2 in Tomcat 
> > > 8.5.
> > > 
> > > We are running more than one web application in Tomcat. Each 
> > > application uses log4j via slf4j and ships the log4j.jar in 
> > WEB-INF/lib. The Tomcat itself uses JULI.
> > 
> > We are using a common log4j.xml file for configuration.
> > 
> > The file path is set as system property in CATALINA_OPTS as
> > follows: -Dlog4j.configuration=/path/to/file/log4j.xml
> > 
> > 1. Is this a valid setup or are there any side effects in 
> > initialization log4j by the different WebAppClassLoaders?
> 
> You are not using classpath-based config-file-loading, so it should not be a problem[*].
> 
> > 2. We are observing weird things in rolling the files hourly. The 
> > timestamp of the log messages doesn't fit to the timestamp suffix of 
> > the file. Why does this happen?
> 
> Possibly conflicting time zones, somewhere? Because log4j.jar is in each application's class loader, they CAN have different in-memory configurations.
No there are no different time zones in use.

> 
> [*] While this will work, why would you ever want multiple applications to have their logging configuration all tied together?
> Why not separate the logging configuration into one config-per web application? OR are you trying to unify all logging into the same file(s )?
Yes I would like to do that, but I'm not sure how to achieve it without putting the log4j.xml into the WAR file. Do you have any hint?

> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
> 
> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlxtdSUACgkQHPApP6U8
> pFhxow//T+5ALVYJcljqLxykHND7ZSy9NHf0+a+jnWzlDO5S6oO+bxjso9raJZYC
> jUG4nhBwuAtD5MWyS04t0UedYUBP+n1iw4aAGs7PrhFgPxLiHZpMOTBBaeDSYgny
> bI+7GuqOhkiauPA8Jb6guE8SkrT18d9X+k7xzy6puYgqbTws0iwk2yEmSV+KNtXy
> 0EsVC20KGhU9pCdD7MLSpYX8PaM8sctazxSSVMygL9Ed03WKkJ6BRPavq4ao1uGg
> V0ZlTQb7f9PRPOXOQzoAlsaWNTCVRKQES82/HHJE/uJG5tg7jnQ5Syjs53FyfVwH
> 0AtfNpJiOI4LES5ejR7E5JZ8Lx0/J41XwsPO5hOmYaiHHs35EFtozCETNNwjYxcb
> 245z++YsBw0bnBDRpAFi5Kq5UL8ludo0CqDTfKQSIqrMoNHoiULm4U3niGl2P01w
> O8k2KrwqtYWu77esh+TpJpXTTaLnEhCc+YWFGWnER3w8WAOHitvjbmAi21gL3NIG
> 3PJEFEdrNMaoI2h3SkK+DJzuVVJRmXRMV2wduX4+3qGW6l31Jo3ihFiDDdXyGB+b
> jtpU1JHYfYP+ck8mEXgOvI6RXZEG7R8Ef7ectYuKdhRRpE+S9wx1llZminsxY/fr
> 0apA+L6paBo9R7EGxJVt237wx/L+tRnfF5raLZoAJrkks7SkWgE=
> =sjai
> -----END PGP SIGNATURE-----
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Logging web applications with log4j 1.2

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Thomas,

On 2/20/19 08:00, Thomas Rohde wrote:
> I've some basic questions regarding the usage of log4j 1.2 in
> Tomcat 8.5.
> 
> We are running more than one web application in Tomcat. Each
> application uses log4j via slf4j and ships the log4j.jar in
> WEB-INF/lib. The Tomcat itself uses JULI.
> 
> We are using a common log4j.xml file for configuration.
> 
> The file path is set as system property in CATALINA_OPTS as
> follows: -Dlog4j.configuration=/path/to/file/log4j.xml
> 
> 1. Is this a valid setup or are there any side effects in
> initialization log4j by the different WebAppClassLoaders?

You are not using classpath-based config-file-loading, so it should
not be a problem[*].

> 2. We are observing weird things in rolling the files hourly. The
> timestamp of the log messages doesn't fit to the timestamp suffix
> of the file. Why does this happen?

Possibly conflicting time zones, somewhere? Because log4j.jar is in
each application's class loader, they CAN have different in-memory
configurations.

[*] While this will work, why would you ever want multiple
applications to have their logging configuration all tied together?
Why not separate the logging configuration into one config-per web
application? OR are you trying to unify all logging into the same file(s
)?

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlxtdSUACgkQHPApP6U8
pFhxow//T+5ALVYJcljqLxykHND7ZSy9NHf0+a+jnWzlDO5S6oO+bxjso9raJZYC
jUG4nhBwuAtD5MWyS04t0UedYUBP+n1iw4aAGs7PrhFgPxLiHZpMOTBBaeDSYgny
bI+7GuqOhkiauPA8Jb6guE8SkrT18d9X+k7xzy6puYgqbTws0iwk2yEmSV+KNtXy
0EsVC20KGhU9pCdD7MLSpYX8PaM8sctazxSSVMygL9Ed03WKkJ6BRPavq4ao1uGg
V0ZlTQb7f9PRPOXOQzoAlsaWNTCVRKQES82/HHJE/uJG5tg7jnQ5Syjs53FyfVwH
0AtfNpJiOI4LES5ejR7E5JZ8Lx0/J41XwsPO5hOmYaiHHs35EFtozCETNNwjYxcb
245z++YsBw0bnBDRpAFi5Kq5UL8ludo0CqDTfKQSIqrMoNHoiULm4U3niGl2P01w
O8k2KrwqtYWu77esh+TpJpXTTaLnEhCc+YWFGWnER3w8WAOHitvjbmAi21gL3NIG
3PJEFEdrNMaoI2h3SkK+DJzuVVJRmXRMV2wduX4+3qGW6l31Jo3ihFiDDdXyGB+b
jtpU1JHYfYP+ck8mEXgOvI6RXZEG7R8Ef7ectYuKdhRRpE+S9wx1llZminsxY/fr
0apA+L6paBo9R7EGxJVt237wx/L+tRnfF5raLZoAJrkks7SkWgE=
=sjai
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org