logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Deboy <scott.de...@gmail.com>
Subject Re: log4j----Edit the event received
Date Wed, 14 Sep 2011 20:49:39 GMT
There are only three unique attributes provided for socket-received events:
hostname
remoteSourceInfo
application (if set on appender)

If you can't leverage application and would like to use additional
properties to identify instances, there is a mechanism that supports that
(via configuration): RewriteAppender

RewriteAppender allows you to modify event attributes (or add properties)
before sending the event to the appender.

A RewriteAppender expects a nested appender (your SocketAppender) and a
RewritePolicy.

You can use a PropertyRewritePolicy as a quick way to add custom properties
to each event.

This requires you to add the receivers companion jar and probably component
companion jar (not sure about extras companion) to your appender side.

http://logging.apache.org/log4j/companions/receivers/apidocs/org/apache/log4j/rewrite/RewriteAppender.html
http://logging.apache.org/log4j/companions/receivers/apidocs/org/apache/log4j/rewrite/RewritePolicy.html

Example configuration (didn't run this, but it should be correct) that will
add two properties to each event, somepropertyname1 and somepropertyname2.

<appender name="rewrite" class="org.apache.log4j.rewrite.RewriteAppender">
    <appender name="socket" class="org.apache.log4j.net.SocketAppender">
      <param name="Port" value="12346"/>
      <param name="RemoteHost" value="localhost"/>
      <param name="Application" value="app1"/>
      <param name="ReconnectionDelay" value="60000"/>
      <param name="Threshold" value="ALL"/>
    </appender>
    <RewritePolicy name="propertyPolicy"
class="org.apache.log4j.rewrite.PropertyRewritePolicy">
        <param name="properties"
value="somepropertyname1=somepropertyvalue1,somepropertyname2=somepropertyvalue2">
    </RewritePolicy>
</appender>

Scott


On Wed, Sep 14, 2011 at 1:29 PM, Konduru, Geetha
<Geetha_Konduru@medco.com>wrote:

> Actually  issue is , We have 100 server instances running on 20
> different machines (5 instances per machine).
>
> We want to merge and see them,
>
> When I merge , seeing " log4j.remoteSourceInfo"   I can say particular
> logging event is generated by server instances running on one particular
> machine, Is there a way to figure out which particular Instance out of 5
> instances running on that particular machine.
>
> Thank u,
> VGSS
>
> -----Original Message-----
> From: Scott Deboy [mailto:scott.deboy@gmail.com]
> Sent: Wednesday, September 14, 2011 4:15 PM
> To: Log4J Users List
> Subject: Re: log4j----Edit the event received
>
> The SocketReceiver adds two properties to each event:
> hostname
> log4j.remoteSourceInfo
>
> With the developer snapshot of Chainsaw you should see those as
> individual
> columns in the table.  If they aren't displayed by default you can
> enable
> them via the tab preferences menu (select Columns).
>
> Scott
>
> On Wed, Sep 14, 2011 at 12:38 PM, Konduru, Geetha
> <Geetha_Konduru@medco.com>wrote:
>
> > Hi,
> >
> >
> >
> >  What I am looking for is, every event received by SocketAppender,
> even
> > before it send to remote machine, it must append  to the event(on
> which
> > log4j is running).
> >
> >
> >
> >  Can any one please tell me a solution for this.
> >
> >
> >
> > Example: if application(running on machine HOSTNAME) logs message "I
> am
> > a Logging event", than SOCKET APPENDER must send following to REMOTE
> > machine(or SOCKET RECEIVER on Remote machine should receive following
> as
> > log message).
> >
> >
> >
> > "HOSTNAME:I am a Logging event"
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Thank U,
> >
> > VGSS
> >
> > **********************************************************************
> > This e-mail message and any attachments contain confidential
> information
> > from Medco. If you are not the intended recipient, you are hereby
> notified
> > that disclosure, printing, copying, distribution, or the taking of any
> > action in reliance on the contents of this electronic information is
> > strictly prohibited. If you have received this e-mail message in
> error,
> > please immediately notify the sender by reply message and then delete
> the
> > electronic message and any attachments.
> >
>
> **********************************************************************
> This e-mail message and any attachments contain confidential information
> from Medco. If you are not the intended recipient, you are hereby notified
> that disclosure, printing, copying, distribution, or the taking of any
> action in reliance on the contents of this electronic information is
> strictly prohibited. If you have received this e-mail message in error,
> please immediately notify the sender by reply message and then delete the
> electronic message and any attachments.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message