| Package | org.as3commons.logging.setup.log4j |
| Class | public final class Log4JStyleSetup |
| Inheritance | Log4JStyleSetup Object |
| Since : | 2.7 |
Log4JStyleSetup is a setup that works much like the log4j
properties format, without the text part.
Important note: Log4JStyleSetup
can not
implement ILogSetup. To setup this system its necessary to
use the compile() method that returns a valid setup.
LOGGER_FACTORY.setup = (new Log4JStyleSetup()).compile();
This setup allows the definition of appenders, named ILogTargets,
eigther by direct referencing or using a class name to instantiation.
var log4j: Log4JStyleSetup = new Log4JStyleSetup();
log4j.appender["referenced"] = new TraceTarget();
log4j.appender["generated"] = "org.as3commons.logging.setup.target::TraceTarget";
We just defined the two appenders named "referenced" and "generated".
As you can see appender is dyanmic so you can actually
just type it like this:
log4j.appender.generated = "org.as3commons.logging.setup.target::TraceTarget";
You can also set primitive properties like "format". They will be filled after the instantiation.
log4j.appender.generated.format = "{message} ({logLevel}, {logTime})";
These appenders can be used for example with the rootLogger.
log4j.rootLogger = "WARN, generated";
The rootLogger defines the basic setup. The first value passed is always
the level. It can be DEBUG,INFO,WARN,
ERROR or FATAL. Following the level you can pass
a list of appenders seperated by a colon.
That means with "WARN, generated" we allow warn,
error and fatal log statements to be used and send
them to our target with the name generated.
It is further possible to use the same kind of syntax for hierarchical
setups using the logger property.
log4j.logger["org"]["as3commons"] = "ERROR, referenced";
Also here we make strong use of dynamic proxies and you could just write it without the braces and quotes:
log4j.logger.org.as3commons = "ERROR, referenced";
The passed in log-level "ERROR" always overrides the level
definition in the upper levels. The target is by default merged
with the parent target. This means that now error and
fatal messages will be sent to the targets named generated
and referenced!
To avoid the merging of the targets of lower levels the setup allows
switching of appending using the additivity flag.
log4j.additivity["org"]["as3commons"] = false;
Again, thanks to dynamic proxies, you can write it also without the braces.
log4j.additivity.org.as3commons = false;
Now the former setup will be changed to just send to the appender named
referenced.
There is also a way to limit the setup output using the threshold
property.
log4j.threshold = "FATAL";
After setting of the threshold, any other configuration will be limited
to this log level. That means that even though we defined the targets before
as sending to "ERROR" it will be limited to "FATAL".
See also
| Property | Defined By | ||
|---|---|---|---|
| rootLogger : String [write-only]
Root logger definition
| Log4JStyleSetup | ||
| threshold : String [write-only] | Log4JStyleSetup | ||
| Method | Defined By | ||
|---|---|---|---|
| Log4JStyleSetup | |||
Compiles the setup into a HierarchialSetup
| Log4JStyleSetup | ||
| Constant | Defined By | ||
|---|---|---|---|
| additivity : AdditivitySetup
Additive setup definitions. | Log4JStyleSetup | ||
| appender : Appenders
Appender Registry. | Log4JStyleSetup | ||
| logger : LevelSetup
Logger path configuration. | Log4JStyleSetup | ||
| rootLogger | property |
rootLogger:String [write-only] Root logger definition
public function set rootLogger(value:String):void| threshold | property |
threshold:String [write-only] public function set threshold(value:String):void| Log4JStyleSetup | () | Constructor |
public function Log4JStyleSetup()| compile | () | method |
public function compile():HierarchicalSetup
Compiles the setup into a HierarchialSetup
HierarchicalSetup — Compiled HierarchialSetup with all the properties prepared.
|
| additivity | Constant |
public const additivity:AdditivitySetupAdditive setup definitions.
| appender | Constant |
public const appender:AppendersAppender Registry.
| logger | Constant |
public const logger:LevelSetupLogger path configuration.