On Feb 28, 2011, at 4:41 AM, Martin Nyolt wrote:
> No idea, anyone?
> Appearently, this has to work somehow, since using a configuration file you
> can set the follow-option to be true without closing any stream.
> But I never found any hint how to do this.
>
> Am 18.02.2011 15:01, schrieb Martin Nyolt:
>> Hello,
>>
>> I use the following code to load a default configuration in case no
>> configuration was set using the log4j.configuration property:
>>
>> static {
>> LOGGER = Logger.getLogger(MyClass.class);
>> Logger root = Logger.getRootLogger();
>> boolean inited = root.getAllAppenders().hasMoreElements();
>>
>> if (!inited) {
>> Layout layout = new PatternLayout("%-5p [%t]: %m%n");
>> // create Appender to System.err
>> ConsoleAppender app = new ConsoleAppender(layout,
>> ConsoleAppender.SYSTEM_ERR);
The preceding call is the problem. The configurators call the default
constructor (in this case, new ConsoleAppender()), then call property setters,
then call activateOptions(). The non-default constructors are convenience
functions that result in a fully activated appender ready to go in one call.
However, in this case, that behavior is not desired. Switch this to a default
constructor and calls to setLayout, setTarget, setFollow and then
activateOptions.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]