At 09:34 12.12.2002 -0800, you wrote:
Dan,

My only concern is the changing of LoggingEvent.  This object gets
serialized across sockets from one log4j process to another, so maintaining
some level of compatibility between different log4j versions is important.
Won't adding a new private member break serialization between versions?
Anyone?
No, adding fields does not break backward compatibility in the sense that clients version 'n' can send to server version 'n+1' where the difference between n and n+1 is the addition of an extra field. I don't remember what happens when n+1 sends to n.

That being said, I do agree that this functionality is useful.  We have
talked in the past about making changes in LoggingEvent that would make it
incompatible with earlier versions, but much faster serialized and maybe
more maintainable going forward.  Maybe v1.3 is the time to make the change.
Why stop at hostname? What about username? Session id? Cookies? Address of my dentist? You get the point. The JMS API solves this problem by having properties attached to each message. See http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/Message.html


-Mark

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 12, 2002 8:34 AM
> To: [EMAIL PROTECTED]
> Subject: Hostname support in PatternLayout (patch included)
>
>
>
>
> Hi.
>
> I sent this patch in on Friday. It modifies PatternLayout so it can output
> the hostname via %h. It seems like it's simple enough for a developer to
> say good idea/bad idea, but it has slipped through the cracks.
> Therefore, I
> am submitting it again.
>
> Thanks
>
> Dan
>
>
> diff -ru
> orig/src/java/org/apache/log4j/helpers/PatternParser.java
> src/java/org/apache/log4j/helpers/PatternParser.java
> --- orig/src/java/org/apache/log4j/helpers/PatternParser.java
> 2002-10-09 18:50:03.000000000 -0400
> +++ src/java/org/apache/log4j/helpers/PatternParser.java
> 2002-12-05 12:19:13.000000000 -0500
> @@ -56,6 +56,7 @@
>    static final int LEVEL_CONVERTER = 2002;
>    static final int NDC_CONVERTER = 2003;
>    static final int MESSAGE_CONVERTER = 2004;
> +  static final int HOSTNAME_CONVERTER = 2005;
>
>    int state;
>    protected StringBuffer currentLiteral = new StringBuffer(32);
> @@ -277,6 +278,12 @@
>        //formattingInfo.dump();
>        currentLiteral.setLength(0);
>        break;
> +    case 'h':
> +      pc = new BasicPatternConverter(formattingInfo, HOSTNAME_CONVERTER);
> +      //LogLog.debug("Hostname converter.");
> +      //formattingInfo.dump();
> +      currentLiteral.setLength(0);
> +      break;
>      case 'l':
>        pc = new LocationPatternConverter(formattingInfo,
>                               FULL_LOCATION_CONVERTER);
> @@ -391,6 +398,8 @@
>       return event.getLevel().toString();
>        case NDC_CONVERTER:
>       return event.getNDC();
> +      case HOSTNAME_CONVERTER:
> +        return event.getHostname();
>        case MESSAGE_CONVERTER: {
>       return event.getRenderedMessage();
>        }
> diff -ru orig/src/java/org/apache/log4j/spi/LoggingEvent.java
> src/java/org/apache/log4j/spi/LoggingEvent.java
> --- orig/src/java/org/apache/log4j/spi/LoggingEvent.java
> 2002-10-21 19:20:34.000000000 -0400
> +++ src/java/org/apache/log4j/spi/LoggingEvent.java   2002-12-06
> 11:03:44.000000000 -0500
> @@ -102,6 +102,9 @@
>    /** The name of thread in which this logging event was generated. */
>    private String threadName;
>
> +  /** The name of the host on which this logging event was generated. */
> +  private String hostName;
> +
>    /** This
>        variable contains information about this event's throwable
>    */
> @@ -142,6 +145,13 @@
>      this.categoryName = logger.getName();
>      this.level = priority;
>      this.message = message;
> +
> +    try {
> +      this.hostName = java.net.InetAddress.getLocalHost().getHostName();
> +    } catch (java.net.UnknownHostException uhe) {
> +      this.hostName = "*HOSTNAME UNKNOWN*";
> +    }
> +
>      if (throwable != null) {
>        this.throwableInfo = new ThrowableInformation(throwable);
>      }
> @@ -171,6 +181,13 @@
>      this.categoryName = logger.getName();
>      this.level = priority;
>      this.message = message;
> +
> +    try {
> +      this.hostName = java.net.InetAddress.getLocalHost().getHostName();
> +    } catch (java.net.UnknownHostException uhe) {
> +      this.hostName = "*HOSTNAME UNKNOWN*";
> +    }
> +
>      if (throwable != null) {
>        this.throwableInfo = new ThrowableInformation(throwable);
>      }
> @@ -190,6 +207,13 @@
>    }
>
>    /**
> +   * Return the hostname of this event. Use this form instead of directly
> +   * accessing the <code>hostName</code> field. */
> +  public String getHostname() {
> +    return hostName;
> +  }
> +
> +  /**
>     * Return the level of this event. Use this form instead of directly
>     * accessing the <code>level</code> field.  */
>    public Level getLevel() {
>
>
>
> ------------------------------------------------------------------
> -------------
> This message and any included attachments are from Siemens
> Medical Solutions
> Health Services Corporation and are intended only for the addressee(s).
> The information contained herein may include trade secrets or
> privileged or
> otherwise confidential information.  Unauthorized review,
> forwarding, printing,
> copying, distributing, or using such information is strictly
> prohibited and may
> be unlawful.  If you received this message in error, or have
> reason to believe
> you are not authorized to receive it, please promptly delete this
> message and
> notify the sender by e-mail with a copy to [EMAIL PROTECTED]  Thank you
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
Ceki



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to