Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5973897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:51:56+00:00 2026-05-22T20:51:56+00:00

I cannot create object for this coding. How can I access this values I

  • 0

I cannot create object for this coding. How can I access this values I want to return the msg value in this coding?

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 static void main(String args[])
{
    new LogCapture(Level.INFO);

    LogCapture.getMessage() ;
}
    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;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:51:57+00:00Added an answer on May 22, 2026 at 8:51 pm

    I’m not sure that I understand the question, but it sounds easy. You create an instance like this:

    new LogCapture(Level.INFO);
    

    You can find the other log levels here:
    Documentation for Level

    Edit (since the OP has added some more code):
    Change the code in the main method so that it says

    LogCapture logCapture = new LogCapture(Level.INFO);
    logCapture.getMessage();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want to understand why I cannot create a protected enum on C#?
This post is incorrectly tagged 'send' since I cannot create new tags. I have
I want to create a token generator that generates tokens that cannot be guessed
I want to create an allocator which provides memory with the following attributes: cannot
I've got a Stateful Session bean where I create a object (in this case
It is possible, given only an interface, to create an object from this? Something
Drupal cannot create the files folder. I tried to upload a php script with
One of my columns type is DateTime (Date Registered). I cannot create a query
I am creating a database in SQL Server 2005 and cannot remember the CREATE
I'm trying to create a piece of code but cannot get it working. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.