[logback-user] Help with Tomcat -> GUI Viewer logging setup

Joern Huxhorn jhuxhorn at googlemail.com
Fri Jul 9 23:54:42 CEST 2010


Hi Steve,
my answers are inline...

On 09.07.2010, at 17:02, Steve Johnson wrote:

> Greetings,
> 
> I apologize in advance if my question is obviously documented somewhere already.  If so, I haven't been able to find those docs and would welcome being simply pointed to them.
> 
> I'm looking to switch to Logback after years of struggling with log4j and chainsaw within a Tomcat environment.  I'm hoping to get some advice up front to save me frustration in getting to what I want with Logback.
> 
> What I'd like to do is have multiple web applications running in a single Linux hosted Tomcat instance log to the same log stream.  I'd like this stream to be viewable on a remote Windows workstation via a GUI app (via Lilith, I guess).  Preferably, multiple GUIs on different workstations ought to be able to view the log stream simultaneously.  Also, it would be great if something like ZeroConf could be used such that no mucking with config files and IP addresses will be necessary.

ZeroConf isn't supported right now because it just isn't stable enough at the moment - at least that's my experience... it resulted in crashes on Mac OS X.
I'm also not very experienced concerning your special requirement of putting all events of various applications into a single stream on Tomcat. I'm not 100% sure that this is a really good idea, too, because that single appender would always be a common bottleneck for all of your apps.

I think Lilith ( http://lilith.huhorn.de ) can help you anyway because it has a global event view, beside one for each connection. This global view would essentially provide the single logstream that you are asking for.

> 
> I've had some luck getting all of this going with log4j and chainsaw, but the system has always been kinda flakey.  I had everything set up with ZeroConf, but I had to write my own version of the ZeroConfSocketHubAppender to bump the port number when a socket bind failed to deal with the fact that multiple appenders would be created by my various web applications and would otherwise all contend for the same local port.  I want something more reliable and robust.
> 
> So, can anyone offer suggestions for getting to such a setup with Logback?  Which sort of appender should I use?  What gotchas should I be aware of?
> 

I'd suggest my multiplex-appender for your use-case since you'd like to send your events to multiple hosts.
See http://sourceforge.net/apps/trac/lilith/wiki/AppenderPitfalls for a comparison of the different appender strategies.

Add the following dependency to your applications pom.xml file:

<dependency>
  <groupId>de.huxhorn.lilith</groupId>
  <artifactId>de.huxhorn.lilith.logback.appender.multiplex-classic</artifactId>
  <version>0.9.39</version>
  <scope>runtime</scope>
</dependency>

Then, add the following to your logback.xml file:

<appender name="multiplex" class="de.huxhorn.lilith.logback.appender.ClassicMultiplexSocketAppender">
  <Compressing>true</Compressing> <!-- will automatically use correct default port -->
  <!-- Default port for compressed is 10000 and uncompressed 10001 -->
  <ReconnectionDelay>10000</ReconnectionDelay>
  <IncludeCallerData>true</IncludeCallerData>
  <RemoteHosts>localhost, 10.200.55.13</RemoteHosts>
  <!-- Alternatively: 
  <RemoteHost>localhost</RemoteHost>
  <RemoteHost>10.200.55.13</RemoteHost>
  -->
</appender>

and attach that appender to the root logger or a specific one.

One of the benefits of my appender is that it serializes a logging event only once and sends the same bytes to an arbitrary amount of RemoteHosts. It also includes techniques to prevent stalling of connections - which was a rather big problem in our production environment both in case of log4j/Chainsaw and Logback SocketAppender.

Please let me know if this solved your questions.

I'd also like to point out that, while it's still largely missing from the homepage, help is available in Lilith itself.

> I quickly reviewed the document "Access log with logback, Jetty and Tomcat", but I find that document kinda confusing.  Does this module simply offer a web interface to logs, or is it something more?  Would it be any help in my situation if I'm not interested in accessing logs via HTTP?
> 

Access logs are also available but are different logs, i.e. server access logs instead of application logging events.
Those can also be received by Lilith, please take a look at the help and/or ask me if you need further help.

> TIA for any help you can provide.
> 
> Steve
> 

You are welcome.

Cheers,
Joern.


More information about the Logback-user mailing list