Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

null pointer exception from Logger.getLogger

Status
Not open for further replies.

eggheadonist

Programmer
Mar 11, 2005
1
0
0
ZA
Hi guys

I have no doubt that I am being complete moron in this case, but I'd appreciate you help in pointing out the obvious.

I am getting a null pointer exception in the contructor for class Foo below in the line logger.debug(..). It seems logger is null. When I move the assignment of "logger = logger.getLogger(MessageService.class)" to the contructor the problem goes away & change to non-static. Why is this is? What is happening here?

Much appreciate.

public class Foo {

private static final Foo instance = new Foo();

static Logger logger = logger.getLogger(MessageService.class);

public Foo() {
logger.debug("constructor called.");
}

public static Foo getInstance() {
logger.debug("getInstance called.");
return instance;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top