logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randall <ra...@sciencedroppings.com>
Subject Re: IM Appender
Date Tue, 20 May 2003 16:06:40 GMT
Hey there.. I've been a lurker on this list for a while but I noticed this
thread.  I think this is a great idea.  I'm working on a process
monitoring tool for our platform here and it would be great if people in
operations could log into jabber when they wanted to, and have any
critical messages pop right up on their screen.  I'll be watching the
progres sof this and when we get to that point in development of our tool
i'll _definitely_ be interested in using it.

-Randy

Randy Locklair
Sr. Software Architect
Swiss American Securities, Inc.

> people to more easily monitor application behavior with tools already at
> their disposal (their chat clients).  SMTP means one gets email.  It's more
> difficult to subscribe and unsubscribe to this.  It's easy to log on or log
> off a chat room to which an application is forwarding some of it's log
> data.
>
> I'm not arguing the merits of IM over SMTP.  Rather the merits of a choice
> between (or both) of the two.
>
> - Paul
>
> Paul Glezen
> Consulting IT Specialist
> IBM Software Services for WebSphere
> 818 539 3321
> AIM: pfglezenibm
> YIM: pfglezen
> ICQ: 179406599
>
>
> Ceki Gülcü <ceki@qos.ch> on 05/20/2003 08:46:57 AM
>
> Please respond to "Log4J Developers List" <log4j-dev@jakarta.apache.org>
>
> To:    "Log4J Developers List" <log4j-dev@jakarta.apache.org>
> cc:
> Subject:    Re: IM Appender
>
>
>
>
> In what way is the IMAppender more useful than say the SMTPAppender? I
> realize that IM is based on Jabber and SMTP, on well, SMTP... So my
> question is when would a user prefer to employ IMAppender rather than say
> SMTPAppender?
>
> At 04:32 PM 5/20/2003 +0500, you wrote:
> >Hi all,
> >
> >I have write a new network appender that let my applications write
> >output through IM networks. I think instant messaging (IM) is a great
> >and easy way to monitor in real-time applications remotely deployed. The
> >application acts as an IM client that sends trouble messages (FATAL or
> >ERROR requests) to developer or system admin desk.
> >
> >IMAppender is an alternative path to another network appenders like JMS,
> >SMTP, Syslog, etc.
> >
> >I attach a preliminar version of IMAppender class (I will wrote javadoc
> >comments and a test case if your are interested in the code). The
> >configuration properties are:
> >
> >- host -> name of the XMPP server to connect to (e.g. jabber.org or a
> >private server in the corporate Intranet).
> >
> >- port -> the port on the server that should be used (default=5222).
> >
> >- userName -> username of jabber account created for the application.
> >
> >- password -> password of jabber account created for the application.
> >
> >- IMAddress -> IM user to send messages.
> >
> >- chatroom (work in progress).
> >
> >I have choose XMPP (Extensible Messaging and Presence Protocol) protocol
> >(a.k.a. Jabber protocol) because unlike other proprietary services (AIM,
> >Yahoo! Messenger, Microsoft Messenger), Jabber is completely open.
> >Jabber's design allows anyone to create a jabber server and run their
> >own Jabber network.
> >
> >Note that IMAppender depends of Jive Software's XMPP Smack API 1.0.1.
> >library (http://www.jivesoftware.com/xmpp/smack/). The use of this
> >software is governed by the Apache License.
> >
> >I'd appreciate any feedback.
> >
> >
> >Thanks,
> >
> >Rafael Luque
> >Orange Soft
> >
> >
> >IMAppender.java
> >---------------
> >
> >/*
> >  * Copyright (C) The Apache Software Foundation. All rights reserved.
> >  *
> >  * This software is published under the terms of the Apache Software
> >  * License version 1.1, a copy of which has been included with this
> >  * distribution in the LICENSE.txt file.  */
> >
> >package com.orangesoft.log4j.net;
> >
> >import org.apache.log4j.AppenderSkeleton;
> >import org.apache.log4j.spi.LoggingEvent;
> >import org.apache.log4j.spi.ErrorCode;
> >import org.apache.log4j.helpers.LogLog;
> >
> >
> >// JiveSoftware Smack API
> >
> >import org.jivesoftware.smack.XMPPConnection;
> >import org.jivesoftware.smack.XMPPException;
> >import org.jivesoftware.smack.Chat;
> >import org.jivesoftware.smack.packet.Message;
> >import org.jivesoftware.smack.packet.Message.Type;
> >
> >
> >/**
> >  * IMAppender appends logging requests through Jabber
> >  * IM network.
> >  *
> >  * @author Rafael Luque
> >  */
> >
> >public class IMAppender extends AppenderSkeleton {
> >
> >
> >     // ----------------------------------------------- Variables
> >
> >
> >     /* Configuration properties */
> >
> >     private String host;
> >     private int port;
> >     private String userName;
> >     private String password;
> >     private String IMAddress;
> >
> >     private XMPPConnection con;
> >     private Chat chat;
> >
> >
> >     // -------------------------------------------- Constructors
> >
> >     public IMAppender() {
> >         this.port = 5222; // default XMPP port
> >     }
> >
> >
> >     // ------------------------------------------ Public methods
> >
> >     public String getHost() {
> >         return this.host;
> >     }
> >
> >     public void setHost(String host) {
> >         this.host = host;
> >     }
> >
> >     public int getPort() {
> >         return this.port;
> >     }
> >
> >     public void setPort(int port) {
> >         this.port = port;
> >     }
> >
> >     public String getUserName() {
> >         return this.userName;
> >     }
> >
> >     public void setUserName(String userName) {
> >         this.userName = userName;
> >     }
> >
> >     public String getPassword() {
> >         return this.password;
> >     }
> >
> >     public void setPassword(String password) {
> >         this.password = password;
> >     }
> >
> >     public String getIMAddress() {
> >         return this.IMAddress;
> >     }
> >
> >     public void setIMAddress(String IMAddress) {
> >         this.IMAddress = IMAddress;
> >     }
> >
> >
> >     /**
> >      *  Options are activated and become effective only after calling
> >      *  this method.
> >      */
> >
> >     public void activateOptions() {
> >         try {
> >             // Create a connection to the XMPP server
> >             LogLog.debug("Stablishing connection with XMPP server");
> >             if (port != 0) {
> >                 con = new XMPPConnection(host, port);
> >             } else {
> >                 con = new XMPPConnection(host);
> >             }
> >
> >             // Most servers require login before performing other tasks
> >             LogLog.debug("About to login as [" + userName +
> >                 "/" + password + "].");
> >             con.login(userName, password);
> >
> >             // Start a conversation with IMAddress
> >             LogLog.debug("About to create a Chat");
> >             chat = con.createChat(IMAddress);
> >
> >         } catch (XMPPException xmppe) {
> >             errorHandler.
> >                 error("Error activating options for appender named [" +
> >                 name + "].", xmppe, ErrorCode.GENERIC_FAILURE);
> >         }
> >     }
> >
> >
> >
> >     /**
> >      * Close this IMAppender.
> >      *
> >      * Closing releases all resources used by the appender. A closed
> >      * appender cannot be re-opened.
> >      */
> >
> >      public synchronized void close() {
> >         if(this.closed)
> >             return;
> >
> >         LogLog.debug("Closing appender ["+name+"].");
> >         this.closed = true;
> >
> >         // Closes the connection by setting presence to unavailable
> >         // then closing the stream to the XMPP server.
> >         if (con != null)
> >             con.close();
> >
> >         // Help GC
> >         con = null;
> >         chat = null;
> >     }
> >
> >
> >     /**
> >      * This method called by {@link AppenderSkeleton#doAppend} method to
> >      * do most of the real appending work.
> >      */
> >
> >     public void append(LoggingEvent event) {
> >         // We must not attempt to append if chat is null.
> >         if(chat == null) {
> >             errorHandler.
> >                 error("No Chat is set for IMAppedender named [" +
> >                     name + "].");
> >             return;
> >         }
> >
> >         try {
> >             Message msg = chat.createMessage();
> >             msg.setBody(layout.format(event));
> >             chat.sendMessage(msg);
> >         } catch(Exception e) {
> >             errorHandler.
> >                 error("Could not publish message in IMAppender [" +
> >                     name + "].", e, ErrorCode.GENERIC_FAILURE);
> >         }
> >     }
> >
> >
> >     /**
> >      * The JSMAppender requires a layout. Hence, this method returns
> >      * <code>true</code>.
> >      */
> >
> >     public boolean requiresLayout() {
> >         return true;
> >     }
> >
> >}
> >
> >
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: log4j-dev-help@jakarta.apache.org
>
> --
> Ceki  For log4j documentation consider "The complete log4j manual"
>        ISBN: 2970036908  http://www.qos.ch/shop/products/clm_t.jsp
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-dev-help@jakarta.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-dev-help@jakarta.apache.org
>


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


Mime
View raw message