Skip to Main Content
WebLogic: The Definitive Guide
book

WebLogic: The Definitive Guide

by Jon Mountjoy, Avinash Chugh
February 2004
Intermediate to advanced content levelIntermediate to advanced
848 pages
27h 25m
English
O'Reilly Media, Inc.
Content preview from WebLogic: The Definitive Guide

Listening for Log Messages

There are two ways to listen for log messages. You can either take advantage of the JMX infrastructure and register a notification listener with the LogBroadcasterRuntime MBean, or you can attach a custom log handler (using the JDK 1.4 Logging API) to the server’s Logger directly using a startup class. Using the Logging API is simpler and lets you benefit from other features of the API, such as filtering and message formatting.

JMX Listeners

WebLogic distributes log messages as JMX notifications. Thus, writing an application that listens and responds to log events is no different from writing any other notification listener, which we covered in Chapter 20. As Figure 21-1 illustrates, each server hosts a log broadcaster. This is implemented by the LogBroadcasterRuntime MBean. The following command retrieves the name of the LogBroadcasterRuntime MBean on a Managed Server:

java weblogic.Admin -url t3://servera.x:7001/ -username system -password pssst 
     GET -pretty -type LogBroadcasterRuntime

In this case, the name of the MBean on ServerA is:

myClusterDomain:Location=ServerA,Name=TheLogBroadcaster,Type=LogBroadcasterRuntime

You can use the MBean’s name to register a NotificationListener with the LogBroadcasterRuntime MBean:

WebLogicObjectName name = new WebLogicObjectName("TheLogBroadcaster", "LogBroadcasterRuntime", "myClusterDomain", "ServerA"); MyLogListener mll = new MyLogListener( ); ah.getMBeanServer( ).addNotificationListener(name, mll, null /*no filter*/, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Building Microservices with Spring Boot, Second Edition

Building Microservices with Spring Boot, Second Edition

Josh Long / Phillip Webb
Spring Microservices in Action, Second Edition

Spring Microservices in Action, Second Edition

John Carnell, Illary Huaylupo Sanchez
Kubernetes: Up and Running, 2nd Edition

Kubernetes: Up and Running, 2nd Edition

Brendan Burns, Joe Beda, Kelsey Hightower
Learn OpenShift

Learn OpenShift

Denis Zuev, Artemii Kropachev, Aleksey Usov

Publisher Resources

ISBN: 059600432XErrata Page