As I recall the intention was to add some JMX support that could go and get 
messages in the queue, but I haven't implemented much of anything for JMX yet.  
I'll have to look at it again but I think the idea was to be able to go back 
and report errors even if no listener was registered.

Ralph

On Sep 28, 2012, at 11:04 AM, Gary Gregory wrote:

> Hi All:
> 
> Consider what happens when no one listens to a 
> org.apache.logging.log4j.status.StatusLogger in log(Marker, String, Level, 
> Message, Throwable):
> 
>     /**
>      * Add an event.
>      * @param marker The Marker
>      * @param fqcn   The fully qualified class name of the <b>caller</b>
>      * @param level  The logging level
>      * @param msg    The message associated with the event.
>      * @param t      A Throwable or null.
>      */
>     @Override
>     public void log(Marker marker, String fqcn, Level level, Message msg, 
> Throwable t) {
>         StackTraceElement element = null;
>         if (fqcn != null) {
>             element = getStackTraceElement(fqcn, 
> Thread.currentThread().getStackTrace());
>         }
>         StatusData data = new StatusData(element, level, msg, t);
>         msgLock.lock();
>         try {
>             messages.add(data);
>         } finally {
>             msgLock.unlock();
>         }
>         for (StatusListener listener : listeners) {
>             listener.log(data);
>         }
>     }
> 
> Code runs in the methods, creating objects and so on only to have:
> 
>         for (StatusListener listener : listeners) {
>             listener.log(data);
>         }
> 
> 
> do nothing. But before that, the method records a data object in the messages 
> queue.
> 
> Why? It does not seem that references are used ATM.
> 
> If thought the method could be guarded by this at the top:
> 
>         if (listeners.isEmpty()) {
>             return;
>         }
> 
> But then the behavior would be different since the data object would not be 
> queued.
> 
> Please help me understand.
> 
> Thank you!
> 
> Gary
> -- 
> E-Mail: [email protected] | [email protected] 
> JUnit in Action, 2nd Ed: http://bit.ly/ECvg0
> Spring Batch in Action: http://bit.ly/bqpbCK
> Blog: http://garygregory.wordpress.com 
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory

Reply via email to