Introduction
JavaLog can be controlled at runtime using properties or in code. Using properties specified on the
command line or in a file is the better than using code controls
because it means the end user has the ultimate control over the
logging.
Properties can be specified on the command line or in one or more
files. Since the number of properties that one needs to specify at
runtime to control JavaLog can be large, properties can be read from
files in special locations in the user's environment. The rest of
this document describes these two forms of specifying properties.
Loading Precedence
JavaLog loads properties first from the command line (system
properties), then from files, and then from the command line again.
The first load of the system properties is to allow the user to
override the names of the files. The second load of the system
properties is to make sure that the command line overrides the
contents of any files. Here's a summary of the actions:
- Command line
- ${user.home}/.logrc
- .logrc (or name specified by property -Dlog.rc=filename)
- Command line (again)
So, the command line properties are highest priority, the local .logrc
is next and the ${user.home}/.logrc is last.
Note: currently, all properties used by JavaLog are read into
the System properties object. This means they may collide with
similarly names properties in your software.
Command Line
The entry of properties on the command line is specified by the java
runtime environment. The basic syntax is:
$ java -Dname-1=value-with-no-spaces ... -Dname-N="value with spaces" MyClass args...
There are a few things to notice in this syntax:
- names must be unique (must not be the same as other names)
- names must not contain white space (spaces, tabs, etc)
- values must be in quotes if they contain white space
- the command line arguments args... are not used by JavaLog
Files
Property files allow less typing on the command line and can be used
to store preferences and customizations to JavaLog. As indicated
above in the section on loading, after loading the system properties,
JavaLog tries to load a file called .logrc in the user's home
directory (notice the leading period, Windows users). It then tries
to load the same named file in the current run directory. Then it
loads the system properties again (see above). These files contain
the exact same properties as can be specified on the command line (but
without the -D).
Types
JavaLog recognizes a few different types of property values. More
information is presented in further JavaLog documentation but these
are the basics of the types recognized by JavaLog.
- String
- integer
- size in bytes: integer [ + {k|m} ]
- boolean
- { t | true | on | yes | 1 } = true
- anything else = false
- URL
- rmi://host/name
- file:///absolute-path
- file:relative-path
- jdbc:protocol://host/db-name