Class Overview
A handler that writes log messages to a socket connection.
This handler reads the following properties from the log manager to
initialize itself:
- java.util.logging.ConsoleHandler.level specifies the logging level,
defaults to
Level.ALL if this property is not found or has an
invalid value;
- java.util.logging.SocketHandler.filter specifies the name of the filter
class to be associated with this handler, defaults to
null if
this property is not found or has an invalid value;
- java.util.logging.SocketHandler.formatter specifies the name of the
formatter class to be associated with this handler, defaults to
java.util.logging.XMLFormatter if this property is not found
or has an invalid value;
- java.util.logging.SocketHandler.encoding specifies the encoding this
handler will use to encode log messages, defaults to
null if
this property is not found or has an invalid value.
- java.util.logging.SocketHandler.host specifies the name of the host that
this handler should connect to. There's no default value for this property.
- java.util.logging.SocketHandler.encoding specifies the port number that
this handler should connect to. There's no default value for this property.
This handler buffers the outgoing messages, but flushes each time a log
record has been published.
This class is not thread-safe.
Summary
| Public Constructors |
|
|
SocketHandler()
Constructs a SocketHandler object using the properties
read by the log manager, including the host name and port number.
|
|
|
SocketHandler(String host, int port)
Constructs a SocketHandler object using the specified host
name and port number together with other properties read by the log
manager.
|
| Public Methods |
|
void
|
close()
Closes this handler.
|
|
void
|
publish(LogRecord record)
Logs a record if necessary.
|
|
[Expand]
Inherited Methods |
From class java.util.logging.StreamHandler
|
From class java.util.logging.Handler
|
From class java.lang.Object
|
Object
|
clone()
Returns a new instance of the same class as the receiver, whose slots
have been filled in with the values in the slots of the receiver.
|
|
boolean
|
equals(Object o)
Compares the argument to the receiver, and returns true if they represent
the same object using a class specific comparison.
|
|
void
|
finalize()
Called by the virtual machine when there are no longer any (non-weak)
references to the receiver.
|
|
final
Class<? extends Object>
|
getClass()
Returns the unique instance of java.lang.Class which represents the class
of the receiver.
|
|
int
|
hashCode()
Returns an integer hash code for the receiver.
|
|
final
void
|
notify()
Causes one thread which is wait ing on the receiver to be
made ready to run.
|
|
final
void
|
notifyAll()
Causes all threads which are wait ing on the receiver to
be made ready to run.
|
|
String
|
toString()
Returns a string containing a concise, human-readable description of the
receiver.
|
|
final
void
|
wait(long time, int frac)
Causes the thread which sent this message to be made not ready to run
either pending some change in the receiver (as indicated by
notify or notifyAll) or the expiration of
the timeout.
|
|
final
void
|
wait(long time)
Causes the thread which sent this message to be made not ready to run
either pending some change in the receiver (as indicated by
notify or notifyAll) or the expiration of
the timeout.
|
|
final
void
|
wait()
Causes the thread which sent this message to be made not ready to run
pending some change in the receiver (as indicated by notify
or notifyAll).
|
|
Public Constructors
public
SocketHandler
()
Constructs a SocketHandler object using the properties
read by the log manager, including the host name and port number.
Throws
| IOException
| If failed to connect to the specified host and port. |
| IllegalArgumentException
| If the host name or port number is illegal. |
| SecurityException
| If a security manager determines that the caller does not
have the required permission to control this handler.
|
public
SocketHandler
(String host, int port)
Constructs a SocketHandler object using the specified host
name and port number together with other properties read by the log
manager.
Parameters
| host
| the host name |
| port
| the port number |
Throws
| IOException
| If failed to connect to the specified host and port. |
| IllegalArgumentException
| If the host name or port number is illegal. |
| SecurityException
| If a security manager determines that the caller does not
have the required permission to control this handler.
|
Public Methods
public
void
close
()
Closes this handler. The network connection to the host is also closed.
Throws
| SecurityException
| If a security manager determines that the caller does not
have the required permission to control this handler.
|
public
void
publish
(LogRecord record)
Logs a record if necessary. A flush operation will be done afterwards.
Parameters
| record
| the log record to be logged
|