On Thursday 24 September 2009 17:57:39 Zmuda, Matthew wrote: > I am coding a JNI project and planning to use log4j in java portion and > log4cxx in c++. Can the same configurations files be used for both? >
The same configuration file format is used for both but probably you will have different class names for C++ and Java. So you will need to define loggers depending on the class, package etc. Probably you can define a naming scheme for classes so the loggers apply to both parts. > If I change logging level at runtime in Java will the changes also be made > in c++ logger? See above > Finally can both Java and C++ loggers log to the same file? Yes I thinks so, by defining appenders that log to the same file. Scroll down for appenders http://logging.apache.org/log4cxx/index.html http://logging.apache.org/log4j/1.2/manual.html Attached is a file I'm using for logging, I think it's self explanatory. > > Thanks, > > Matt Zmuda > Software Developer - Tools Group > TVWorks - Platform Division, London, Canada > (519) 963-4304 >
# This file represents is the log4cxx config file for the ProActive linux agent. # It is given as a command line argument when starting the agent # The default logging level is INFO #log4j.rootLogger=INFO,CONSOLE log4j.logger.Action = TRACE, CONSOLE log4j.logger.ActionStarter = TRACE, CONSOLE log4j.logger.AdvertAction = TRACE, CONSOLE log4j.logger.CalendarEvent = TRACE, CONSOLE log4j.logger.ConfigHandler = DEBUG, CONSOLE log4j.logger.ConfigParser = DEBUG, CONSOLE log4j.logger.Configuration = TRACE, CONSOLE log4j.logger.Controller = TRACE, CONSOLE log4j.logger.CustomAction = TRACE, CONSOLE log4j.logger.CustomNodeStarter = TRACE, CONSOLE log4j.logger.Event = TRACE, CONSOLE log4j.logger.IdlenessEvent = TRACE, CONSOLE log4j.logger.IdlenessRunner = TRACE, CONSOLE log4j.logger.NodeStarter = TRACE, CONSOLE log4j.logger.P2PAction = TRACE, CONSOLE log4j.logger.P2PNodeStarter = TRACE, CONSOLE #log4j.logger.paagent = TRACE, CONSOLE log4j.logger.PAAgent = TRACE, CONSOLE log4j.logger.RMAction = TRACE, CONSOLE log4j.logger.RMNodeStarter = TRACE, CONSOLE log4j.logger.Runner = TRACE, CONSOLE log4j.logger.Watcher = TRACE, CONSOLE ################ Appenders #################### # # Appender output can be configured by using a pattern layout # See: http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html # # - %c the category of the logging event # - %d the date # - %m he application supplied message # - %n the platform dependent line separator character or characters # - %p the priority of the logging event # - %t the name of the thread that generated the logging event # - %X{hostname} the hostname # - %x...@hostname} the VMID and the hostname # - %x{shor...@hostname} the short VMID and the hostname (a collision can occur between two shortids, you should use i...@hostname) # - %X{runtime} the ProActive runtime url (does not work very well since a different MDC is associated to each thread) # CONSOLE appender is used by default log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.conversionpattern=%x{shor...@hostname} - [%p %20.20c{2}] %m%n # Appender FILE writes to the file "tests.log". # This file is recreated a file for each run log4j.appender.FILE=org.apache.log4j.FileAppender log4j.appender.FILE.File=tests.log log4j.appender.FILE.Append=false log4j.appender.FILE.layout=org.apache.log4j.PatternLayout log4j.appender.FILE.layout.ConversionPattern=%5p [%t]: %m%n