Class SocketServer
- java.lang.Object
-
- org.apache.log4j.net.SocketServer
-
public class SocketServer extends java.lang.Object
ASocketNode
based server that uses a different hierarchy for each client.Usage: java org.apache.log4j.net.SocketServer port configFile configDir where port is a part number where the server listens, configFile is a configuration file fed to the
PropertyConfigurator
and configDir is a path to a directory containing configuration files, possibly one for each client host.The
configFile
is used to configure the log4j default hierarchy that theSocketServer
will use to report on its actions.When a new connection is opened from a previously unknown host, say
foo.bar.net
, then theSocketServer
will search for a configuration file calledfoo.bar.net.lcf
under the directoryconfigDir
that was passed as the third argument. If the file can be found, then a new hierarchy is instantiated and configured using the configuration filefoo.bar.net.lcf
. If and when the hostfoo.bar.net
opens another connection to the server, then the previously configured hierarchy is used.In case there is no file called
foo.bar.net.lcf
under the directoryconfigDir
, then the generic hierarchy is used. The generic hierarchy is configured using a configuration file calledgeneric.lcf
under theconfigDir
directory. If no such file exists, then the generic hierarchy will be identical to the log4j default hierarchy.Having different client hosts log using different hierarchies ensures the total independence of the clients with respect to their logging settings.
Currently, the hierarchy that will be used for a given request depends on the IP address of the client host. For example, two separate applicatons running on the same host and logging to the same server will share the same hierarchy. This is perfectly safe except that it might not provide the right amount of independence between applications. The
SocketServer
is intended as an example to be enhanced in order to implement more elaborate policies.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static Logger
cat
(package private) static java.lang.String
CONFIG_FILE_EXT
(package private) java.io.File
dir
(package private) static java.lang.String
GENERIC
(package private) LoggerRepository
genericHierarchy
(package private) java.util.Hashtable
hierarchyMap
(package private) static int
port
(package private) static SocketServer
server
-
Constructor Summary
Constructors Constructor Description SocketServer(java.io.File directory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) LoggerRepository
configureHierarchy(java.net.InetAddress inetAddress)
(package private) LoggerRepository
genericHierarchy()
(package private) static void
init(java.lang.String portStr, java.lang.String configFile, java.lang.String dirStr)
static void
main(java.lang.String[] argv)
(package private) static void
usage(java.lang.String msg)
-
-
-
Field Detail
-
GENERIC
static java.lang.String GENERIC
-
CONFIG_FILE_EXT
static java.lang.String CONFIG_FILE_EXT
-
cat
static Logger cat
-
server
static SocketServer server
-
port
static int port
-
hierarchyMap
java.util.Hashtable hierarchyMap
-
genericHierarchy
LoggerRepository genericHierarchy
-
dir
java.io.File dir
-
-
Method Detail
-
main
public static void main(java.lang.String[] argv)
-
usage
static void usage(java.lang.String msg)
-
init
static void init(java.lang.String portStr, java.lang.String configFile, java.lang.String dirStr)
-
configureHierarchy
LoggerRepository configureHierarchy(java.net.InetAddress inetAddress)
-
genericHierarchy
LoggerRepository genericHierarchy()
-
-