logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jensen, Jeff" <Jeff.Jen...@state.mn.us>
Subject RE: an HttpServletRequestAppender?
Date Tue, 23 Sep 2003 16:21:07 GMT
Have you thought about using Logger.l7dlog(), sharing the key with the ActionMessage, and wrapping
both in the appropriate log level check?  This will enable the Log4j config to control both
the log and user messages.  E.g.

  if (LOG.isInfoEnabled())
  {
    String msgKey = "the.key";
    Object[] valuesArray = {"val1", "val2"};
    ActionMessage msg = new ActionMessage(msgKey, valuesArray);

    LOG.l7dlog(Level.INFO, msgKey, valuesArray, throwab);
    actionMessages.add(ActionMessages.GLOBAL_MESSAGE, msg);
  }

Will that work for you?  A little extra code is a negative moving forward, and revamping your
existing classes is the big negative!

I do not think you can have an appender to a transient object (i.e. in the Struts Action),
nor is there a list of Log4j messages to retrieve (need to receive the callAppenders() event).
 But, perhaps one of the gurus will explain further...


> -----Original Message-----
> From: Brian Buckley [mailto:briankbuckley@comcast.net]
> Sent: Tuesday, September 23, 2003 10:57 AM
> To: Log4J Users List
> Subject: Re: an HttpServletRequestAppender?
> 
> 
> Thanks.  I am familiar with <html:messages />, ActionMessage, 
> etc. and using
> those may be my solution in the end, but I have some business 
> classes which
> already emit some appropriate log messages using log4j and I 
> was hoping to
> be able to display those messages.
> 
> Also, log4j allows one good control of turning on and off levels and
> categories of messages by configuration file and I wanted to 
> take advantage
> of that.  I don't believe the Strut's ActionMessages 
> technique has that
> flexibility.
> 
> Brian
> 
> ------------------------------------
> 
> 
> For "any tips" - Are you familiar with the Struts ActionMessages,
> ActionMessage, ActionErrors, and ActionError classes and the Struts
> <html:messages> tag?
> 
> You may want to consider using them instead of pushing log 
> messages to the
> user.
> 
> Lemme know if you are not familiar and would like further info.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Mime
View raw message