On 2009-04-07 13:29, Cory Riddell wrote:
Are the configuration options documented somewhere?

The log4cxx API is patterned after the log4j one and strives to be compatible with it. The most complete log4j specification, short of reading the code, is the log4j manual. I really found myself needing this documentation when I moved from the Property configuration to the DOM (xml) configuration.

https://www.qos.ch/shop/products/log4j/log4j-Manual.jsp

I've seen the
examples on the quick start page but I'd like more information.
Specifically, how do the java (log4j) properties map to the c++ classes?

Take this line as an example:
  log4j.appender.R.layout=org.apache.log4j.PatternLayout

How do you parse this line?

With a PropertyConfigurator of course. :) (Properties' PropertyParser isn't nearly as magical as the PropertySetter and OptionConverter. See PropertyConfigurator::parseAppendder)

I'm guessing that *log4j.appender* equals
the log4cxx::Appender class. *R* is an instance and *.layout* somehow
invokes Appender::setLayout(), passing it a default instance of
log4cxx::PatternLayout.


While I understand the desire to know how it all works and more importantly how to know what class you're setting properties for and what it's options are, I finally just started using the library without caring what kind of thing the appender R is in memory.

You configure appenders of arbitrary names (I prefer ones that represent the type of thing they are appending to like CONSOLE and SYSLOG) and attach them to loggers. If you're assigning log4j.appender.LOGFILE = org.apache.log4j.FileAppender, then you can look at the set* functions of FileAppenderand it's parent WriterAppender and grandparent AppenderSkeleton to see the options.

You can also check the source for the appender or layout and look at the ::setOption function.

Why do some properties have an org.apache prefix and
others do not?

When you declare appenders and layouts you specify the class on the right hand side. The rest of the properties are for setting values.

Could this line simply be written as
  R.layout = log4j.PatternLayout
? Can I use log4cxx rather than log4j?


See OptionConverter::instantiateByClassName and the code it calls. Specifically Class::forName or more simply, try it.

I use the full org.apache.log4j prefixed names just so my configuration files stay compatible with either API. Custom (local) classes probably shouldn't be loaded as org.apache.log4j to avoid the confusion and potential classpath collisions.

--
Jacob Anawalt
Gecko Software, Inc.
janaw...@geckosoftware.com
435-752-8026

Reply via email to