Thorbjørn Ravn Andersen wrote:
>
> JethroXT skrev den 27-07-2008 19:16:
> Is this at program start time or dynamically changing while running?
>
> If it is at program start time you can set a system property which can
> then be expanded in the log4j.properties file. From
> PropertyConfigurator javadoc
>
> "All option /values/ admit variable substitution. The syntax of variable
> substitution is similar to that of Unix shells. The string between an
> opening *"${"* and closing *"}"* is interpreted as a key. The value of
> the substituted variable can be defined as a system property or in the
> configuration file itself. The value of the key is first searched in the
> system properties, and if not found there, it is then searched in the
> configuration file being parsed. The corresponding value replaces the
> ${variableName} sequence. For example, if |java.home| system property is
> set to |/home/xyz|, then every occurrence of the sequence |${java.home}|
> will be interpreted as |/home/xyz|. "
>
> Is this what you need?
>
> --
> Thorbjørn
>
>
Hi,
first of all thanks for the quick reply.
The number of nodes is indeed clear directly after program start.
I managed to solve the problem while trying to follow your proposition, yet
the way I did it seems quite unsual to me.
First I thought of letting the nodes set a system-property with their Id and
refer to this
property in the log4j.properties to create independent loggers. However I
first used a usual logger with no
references to any variables (so no $-reference). Then I let every node refer
to it by using Logger.getLogger() BUT using a name for the logger, that
consisted of its name (as in the log4j.properties) AND the specific nodeID.
Surprisingly this resulted in the desired behaviour. I don't quite know why,
because there simply aren't any loggers with that names, but I anyhow I get
independent loggers, add appenders to them by every node and get single
files with only node-relevant data. Still there is a bad taste about it,
because I don't know why it works and if it will keep working if I add new
loggers..
Any ideas?
--
View this message in context:
http://www.nabble.com/Using-independent-logs-at-runtime-tp18678394p18689236.html
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]