Results 1 to 5 of 5
  1. #1
    nirasiva is offline Member
    Join Date
    May 2011
    Location
    chennai
    Posts
    29
    Rep Power
    0

    Default Here My coding i have Some doubt ,how can i get the value of msg?

    Here my coding how can i get the value of msg..it return some value how can i get these value?
    Java Code:
    package com.my;
    import org.apache.log4j.Level;
    import org.apache.log4j.Logger;
    import org.apache.log4j.VectorAppender;
    import org.apache.log4j.spi.LoggingEvent;
    import java.util.Vector;
    public class LogCapture {
    
        private final VectorAppender appender;
        private final Level level;
      
        public LogCapture(final Level level) {
            this.level = level;
            Logger root = Logger.getRootLogger();
            appender = new VectorAppender();
            root.addAppender(appender);
        }
    	
        public String getMessage() {
            Vector vector = appender.getVector();
            String msg = null;
    
            switch (vector.size()) {
            case 0:
                break;
    
            case 1:
    
                LoggingEvent event = (LoggingEvent) vector.elementAt(0);
            
                msg = event.getRenderedMessage();
    
                break;
    
          
            }
    
            return msg;
        }
    }
    Last edited by nirasiva; 06-04-2011 at 10:06 AM.

  2. #2
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default

    What is your question? Title are not considered as question. And also, use code tags when posting codes

  3. #3
    nirasiva is offline Member
    Join Date
    May 2011
    Location
    chennai
    Posts
    29
    Rep Power
    0

    Default

    I want to get the value of msg.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,774
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by nirasiva View Post
    I want to get the value of msg.
    What does the API documentation say about the return type of this?

    Java Code:
    event.getRenderedMessage();
    Is it of type String? Your problem is solved then. If it isn't, just dumping your code here and demanding us to solve it for you, isn't going to work.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    nirasiva is offline Member
    Join Date
    May 2011
    Location
    chennai
    Posts
    29
    Rep Power
    0

    Default

    Ya it's return type is String,But i cant create instance for Log Capture.so i cant able to cal the method getMessage();

Similar Threads

  1. Replies: 4
    Last Post: 10-25-2010, 04:49 PM
  2. a doubt
    By Thia in forum New To Java
    Replies: 13
    Last Post: 11-24-2009, 03:26 AM
  3. Doubt
    By karthikeyan_raju in forum Advanced Java
    Replies: 11
    Last Post: 11-05-2009, 05:48 PM
  4. have doubt
    By ras_pari in forum Advanced Java
    Replies: 3
    Last Post: 10-01-2009, 10:51 AM
  5. doubt in jms
    By veena in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 01-05-2008, 02:42 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •