Hi Joleen

-----Original Message-----
From: Joleen Barker [mailto:oldenuf2no...@gmail.com]
Sent: Thursday, March 03, 2016 11:23 PM
To: Tomcat Users List
Subject: Re: Understanding how to controlling what data is written to log4j 
appenders

> Hello,
>
> I don't know if I should use a new thread or not but this is a continuation 
> of this issue. I found that even after my changes there was very little being 
> written to my new log and there were still many of the product messages being 
> written to the catalina.out. It has now come to my attention that the web 
> application contains a log4j.jar file in the <WEB-INF>/lib directory and a 
> log4j.properties file in the <WEB-INF>/classes directory.
> This log4j.properties file has a lot more items in it and I believe is the 
> reason all the messages from the product are still going to the catalina.out 
> log.
>
> Here I was so proud of myself for getting the logs to go to an appender and 
> the log rolling over as expected only to find the catalina.out still growing 
> with messages from the application.

Hey, that's a good start!  I just completed refactoring our app to use log4j2, 
and it was a challenge.  While I am new to using log4j, maybe we can stumble 
thru your problem and solve it together.

> I am unsure how to get these messages to be added to my log file that is 
> being used from the log4j.properties file that is in the CATALINA_BASE/lib 
> directory.
>
> One of the other things I noticed is the vendor has a tomcat-juli.jar in the 
> CATALINA_BASE/lib as well as in the CATALINA_BASE/bin directory where it 
> should be. Would the one that is in the CATALINA_BASE/lib directory be doing 
> anything. Maybe it is there in error and not really effecting anything but I 
> don't know.
>
> I did read in a note on the tomcat web page that gave the instructions to use 
> the log4j logging that the steps it had written were not needed if you just 
> want to use log4j in your own web application - in that case, you would just 
> put log4j and the log4j.properties in the WEB-INF/lib and the WEB-INF/classes 
> of your web application which it appears the vendor did. So I think I would 
> need to edit their log4j.properties file.
>
> Am I on the right track at all here?

I would check a few things:

1. Check the container/application startup messages for autoconfig or default 
config notifications.  This may be a moot point since you already said "the 
logs to go to an appender and the log rolling over as expected".

2. Check the log4j config files:
  a. For appenders that go to Console or System_Out.
  b. That the logger(s) refer to the appender(s) you want.
  c. Check the logger(s) "level" to ensure the messages levesl are >= that 
minimum threshold.

3. If you are in doubt as to which log4j config file is in use and have the 
ability to experiment, try changing the config files (and restarting the 
container?) to see how that affects the logs.  Often what I will do is try to 
break something with invalid syntax - if that causes an error then I know I am 
editing the correct file, but if no error is generated, then I don't even have 
the correct file and know I should be looking elsewhere.

4. Check the application code to be sure it is not writing to System.out or 
calling exception printStackTrace directly.

5. Is there an "adaptor" for connecting the Tomcat logging interface to log4j 
that needs to be configured?  I did not use the logging interface built into 
Tomcat, so I cannot provide help with that.

> Would it be bad to post their log4j.properties along with mine to see how I 
> can edit it to have the info go to the new log?
>
> -Joleen
>
> On Fri, Dec 4, 2015 at 4:49 PM, Joleen Barker <oldenuf2no...@gmail.com>
> wrote:
>
>> Hello Chris,
>>
>> As of now I am not using JULI any longer. I am using the log4j
>> v1.2.17.jar
>>
>> Eventually I will jump in to the log4j v2 users and try my hand at that.
>>
>> Thank you for the clarification on where to go for information. I
>> completely missed seeing the log4j mailing list. Could you send me the
>> url to signup for it.
>>
>> Have a wonderful weekend.
>>
>> -Joleen
>>
>>
>>
>> On Fri, Dec 4, 2015 at 1:11 PM, Christopher Schultz <
>> ch...@christopherschultz.net> wrote:
>>
>>> Joleen,
>>>
>>> On 12/3/15 11:55 PM, Joleen Barker wrote:
>>>> The information you gave me for the additivity was PERFECT! It did
>>> exactly
>>>> what I was looking for. This also really allowed me to understand
>>>> what processes were writing to which log. I have the settings in
>>>> place in my test environment now and if all goes well the changes
>>>> will be added in
>>> the
>>>> production environment soon.
>>>
>>> Glad you are making progress.
>>>
>>> There are many folks here who have experience with log4j (myself and,
>>> evidently, Konstantin as well), but for more thorough log4j help,
>>> you're probably going to wait to go over to the log4j mailing list.
>>>
>>> If JULI is in the mix (the default logging framework for Tomcat) and
>>> you are using logging.properties, then you want to stay /here/ for
>>> those questions. Similarly, for configuration involving Tomcat's
>>> container-defined loggers ("categories" in older log4j-speak), here
>>> is also the best place to post.
>>>
>>> -chris
>>>

--
Cris Berneburg, Lead Software Engineer, CACI

Reply via email to