Log
public class EventLog extends Object implements Log
Here is an example use of EventLog, which will write a timestamp and message to the specified file:
EventLog myLog = new EventLog("myFile"); myLog.log("You have successfully written to my log file."); myLog.log("Another log message.");
Each successive message will be appended to the previous messages in the log.
Here is what the log file will look like:
Mon Jan 03 09:00:00 CST 2000 Yout have successfully written to my log file.
Mon Jan 03 09:00:01 CST 2000 Another log message.
Constructor | Description |
---|---|
EventLog() |
Constructs a default EventLog object.
|
EventLog(OutputStream stream) |
Constructs an EventLog object with the specified OutputStream.
|
EventLog(PrintWriter out) |
Constructs an EventLog object with the specified PrintWriter.
|
EventLog(String pathname) |
Constructs an EventLog object with the specified file pathname.
|
Modifier and Type | Method | Description |
---|---|---|
protected void |
finalize() |
|
void |
log(String msg) |
Logs a message to the event log.
|
void |
log(String msg,
Throwable exception) |
Logs an exception and message to the event log.
|
public EventLog()
public EventLog(String pathname) throws IOException
pathname
- The file pathname.IOException
- If an error occurs while accessing the file.public EventLog(OutputStream stream) throws IOException
stream
- The log OutputStream.IOException
- If an error occurs while accessing the stream.public EventLog(PrintWriter out)
out
- The PrintWriter.Copyright © 2024. All rights reserved.