2017-09-25 8:04 GMT+03:00 Kevin Weslowski <kevin.weslow...@gmail.com>:
I've reviewed the documentation for Tomcat 8.5 logging

https://tomcat.apache.org/tomcat-8.5-doc/logging.html

as well as the generic java.util.logging documentation. However, I'm still
having problems understanding and configuring logging for my web application
that I've deployed to Tomcat 8.5.20 on a Linux CentOS 7 server.

Here's what I've tried and where I'm stalled:

- Edited the default logging.properties in the Tomcat conf directory. I
added the package that I'm interested in capturing logging information. For
example:
com.example.myapp.level = ALL
com.example.myapp.handlers = 1catalina.org.apache.juli.AsyncFileHandler

- I deployed my web application. It has a class in the package
com.example.myapp that has a logger defined:
final static Logger log =
Logger.getLogger(com.example.myapp.MyClass.class.getName());

which I then use to call the log APIs like this:
log.severe("severe test");

and

log.finer("finer test");

- The problem is my severe API call is logged but my finer API call isn't.
Actually, even when I back out all of my changes to the logging.properties
file, my severe API call is still logged.

- I'm sure that the logging.properties file I'm editing is being used
because it's I've edited it in other ways to get results (i.e. commented in
the org.apache.catalina.util.LifecycleBase.level = FINE line to see many
FINE log statements and defined another handler which resulted in another
log file being generated).

I'm struggling with getting any meaningful logging working for my web
application.
I must be missing something simple so I'm hoping someone can point me in the
right direction.

1. If there is "logging.properties" file in classpath of your
application, it takes precedence over conf/logging.properties

There was a case once when some 3-rd party jar file had its own
"logging.properties" file that enabled debug logging by default.

2. Log messages are filtered twice: first by logger (whether they are
created), second by handler (whether they are printed out by this
particular handler).

In default configuration
1catalina.org.apache.juli.AsyncFileHandler.level = FINE

so you should have seen your messages

3. Beware of typos.

Your configuration looks sane. I do not see any obvious errors in it.

4. If nothing else helps, run Tomcat with a debugger

https://wiki.apache.org/tomcat/FAQ/Developing#Debugging

Best regards,
Konstantin Kolinko

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


Turns out that I just needed to add logging.properties to my web application. 
Editing the one in Tomcat conf never seems to do anything with respect to 
logging statements from classes in my web application...maybe that means it's a 
classloader thing...I don't know.

As soon as I added logging.properties to my web application, logging started working 
right away. It wasn't clear to me from the documentation that having it there is 
"required" to get logging in a web application to work. Anyway, it works for me 
and I hope my experience helps someone else.

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

Reply via email to