Question about LoggerContext.putProperty and putObject

Hi, I'd like to know if it's possible to set properties and/or objects of the LoggerContext using a standard joran config file. At the moment, my own appender has a setApplicationIdentifier so I'm able to easily identify different apps running on the same host. Would it be possible to use the mentioned LoggerContext methods for this? Joern.

It is possible to set properties from a config file. This is documented at: http://logback.qos.ch/manual/configuration.html#variableSubstitution http://logback.qos.ch/manual/configuration.html#insertFromJNDI LoggerContext properties also survive serialization. However, in future releases I'd like to distinguish between "local" variables which do not survive serialization and "persistent" variables which do survive. You might also be interested to know that you can define your own parsing rules on the fly: http://logback.qos.ch/manual/configuration.html#insertFromJNDI HTH, Joern Huxhorn wrote:
Hi,
I'd like to know if it's possible to set properties and/or objects of the LoggerContext using a standard joran config file.
At the moment, my own appender has a setApplicationIdentifier so I'm able to easily identify different apps running on the same host. Would it be possible to use the mentioned LoggerContext methods for this?
Joern.
-- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch

Hi Ceki, thanks for your answer, it really helped me. I googled it but didn't find it :p Joern. Ceki Gulcu wrote:
It is possible to set properties from a config file. This is documented at:
http://logback.qos.ch/manual/configuration.html#variableSubstitution http://logback.qos.ch/manual/configuration.html#insertFromJNDI
LoggerContext properties also survive serialization. However, in future releases I'd like to distinguish between "local" variables which do not survive serialization and "persistent" variables which do survive.
You might also be interested to know that you can define your own parsing rules on the fly: http://logback.qos.ch/manual/configuration.html#insertFromJNDI
HTH,
Joern Huxhorn wrote:
Hi,
I'd like to know if it's possible to set properties and/or objects of the LoggerContext using a standard joran config file.
At the moment, my own appender has a setApplicationIdentifier so I'm able to easily identify different apps running on the same host. Would it be possible to use the mentioned LoggerContext methods for this?
Joern.

Hi Ceki, is there a similar way in case of AccessEvents? It seems like AccessEvent does not have any information about something like a LoggerContext - at least I couldn't find anything. Joern. Ceki Gulcu wrote:
It is possible to set properties from a config file. This is documented at:
http://logback.qos.ch/manual/configuration.html#variableSubstitution http://logback.qos.ch/manual/configuration.html#insertFromJNDI
LoggerContext properties also survive serialization. However, in future releases I'd like to distinguish between "local" variables which do not survive serialization and "persistent" variables which do survive.
You might also be interested to know that you can define your own parsing rules on the fly: http://logback.qos.ch/manual/configuration.html#insertFromJNDI
HTH,
Joern Huxhorn wrote:
Hi,
I'd like to know if it's possible to set properties and/or objects of the LoggerContext using a standard joran config file.
At the moment, my own appender has a setApplicationIdentifier so I'm able to easily identify different apps running on the same host. Would it be possible to use the mentioned LoggerContext methods for this?
Joern.

Hi Joern, AccessEvent does not have a field referencing its context. However, there is no reason why such a field could not be added. As a side note, all contexts have properties. Would you care to create a jira issue requesting this enhancement? BTW, assuming its not confidential, could you please briefly describe the property which you would like to transport within the access event? Joern Huxhorn wrote:
Hi Ceki, is there a similar way in case of AccessEvents? It seems like AccessEvent does not have any information about something like a LoggerContext - at least I couldn't find anything.
Joern.
-- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch
participants (2)
-
Ceki Gulcu
-
Joern Huxhorn