How to properly enable logging in "org.apache.catalina.core.StandardContext"

2024-02-29 Thread David Karr
In our SpringBoot services, we sometimes run into situations where we get
an exception like this:

org.springframework.context.ApplicationContextException: Unable to start
web server; nested exception is
org.springframework.boot.web.server.WebServerException: Unable to start
embedded Tomcat


It doesn't provide any meaningful root cause.  I've googled how to get more
verbosity from this, but the results are so varied and often conflicting,
and I've never found a strategy that works. It appears that the logger used
in Catalina is not directly compatible with logback, or I'm not figuring
out the correct logger name to use.

I was finally able to figure out why this particular failure was happening,
but that was by carefully stepping through the code and finding new
breakpoints to drill down further. I saw references to the "juli" framework
for logging, which I had seen mentioned in the threads that talk about
getting these logs, but I was never able to get it to work.

As opposed to using my serious debugging skills, I'd like to figure out how
to simply increase the Tomcat logging levels so we can get better
information.


Re: How to turn up logging for tomcat-embed-core in SpringBoot

2025-04-20 Thread David Karr
I've managed to find a solution that works. The info I found has me using
the "log4j-jul" bridge (and excluding spring-boot-starter-logging from
spring-boot-starter-web), which redirects from jul to log4j, which
effectively redirects to logback, which allows me to configure loggers in
the same place as my other loggers, in the logback.xml file. I haven't yet
verified this with the Tomcat startup error I was looking at (that was
apparently resolved in some other way), but I've verified that I can see
other log messages from StandardContext, so it's pretty likely this will
work.

On Sat, Apr 19, 2025, 11:49 AM KARR, DAVID  wrote:

> This is an issue I've tried to pursue multiple times in the past, and each
> time I've given up and used an awkward solution that won't work in the
> current situation I'm seeing this. I thought perhaps I had asked it here
> before, but I don't see it in the archives.
>
> We have a couple hundred Java SpringBoot services, most of them using
> SpringBoot 3.2.5. Internally, it is using Tomcat through the
> "tomcat-embed-core" artifact, version 10.1.30.
>
> Every once in a while, I run into a problem where the service startup
> fails with some variation of this:
>
> WebServerException: Unable to start embedded Tomcat
>
> The stacktrace provided in this case has no stack entries in application
> code. It provides no clue of what actually went wrong. Whenever I run into
> this, if I can run the service on my desktop, I set breakpoints in the
> StandardContext class wherever it sets "ok" to false. That always leads to
> the solution. It almost always points to a conflict with dependencies, but
> knowing that fact doesn't help me until I know what the conflict is.
>
> I really shouldn't have to do this. I can clearly see in the
> StandardContext class that it tries to log the exception message (usually a
> "MultiException" or something like that). Ideally, I should just be able to
> configure the logging for tomcat-embed-core to make it print the exception
> details. Several times I have struggled to make this work, and I've never
> been able to get it working. Tomcat uses java.util.logging, but it seems to
> have some variations that seemingly make it more difficult to configure.
> I've tried variations with a "logging.properties" file, but it never seems
> to make any difference. I've seen some posts that try to address this, but
> I've never found a complete solution for getting this working in a
> SpringBoot application.
>
> In the latest instance, I'm seeing this happen in an environment I can't
> run the debugger in, so I have no way to diagnose this.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>