• Post Reply Bookmark Topic Watch Topic
  • New Topic

can't figure this one out  RSS feed

 
joe weakers
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there. I have a quick query in relation to Java logging functionality (java.util.logging). I know this may not be the best place to post this meassage but here goes anyway. In Java logging there is a Class LogRecord which has one constructor taking two parameters, i.e.

LogRecord(Level level, String msg)

I am simply trying to extend this LogRecord class so that I can add my own methods and so on to the subclass as is standard in inheritance. However when I try to create a subclass called MyLogRecord, I keep encountering the following error:

constructor LogRecord() not found in class java.util.logging.LogRecord

The MyLogRecord class appears as follows.

import java.util.logging.LogRecord;
import java.util.logging.*;

public class MyLogRecord extends LogRecord
{}

I have reduced this class to a mere couple of lines of code, as it appears above, but I am still getting the same error. Can anyone please help. joe
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A subclass has to call one of its superclass's constructors; if you don't call one explicitly, then the no-argument one is called implicitly. But LogRecord doesn't have a no-argument constructor, and so you're getting this compile error. You need to include a constructor in your class which looks like

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!