|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
|
|
|
Re: Are log4j and log4cxx configuration files identical?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{id@hostname} the VMID and the hostname # - %X{shortid@hostname} the short VMID and the hostname (a collision can occur between two shortids, you should use id@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{shortid@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 |
|
|
|
|
|
RE: Are log4j and log4cxx configuration files identical?Thanks for this!
Matt Zmuda Software Developer - Tools Group -----Original Message----- From: log4cxx [mailto:log4cxx@...] Sent: September 25, 2009 8:16 AM To: Log4CXX User Subject: Re: Are log4j and log4cxx configuration files identical? >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 formats are the same, but because of the answer to your third question, you may need two different files unless you add appenders programmatically, or split your loggers such that C++ loggers go to one appender and Java loggers go to another. >If I change logging level at runtime in Java will the changes also be made in c++ logger? If you are making the changes in Java, they will not have any affect on the log4cxx logging configuration. If you are making changes to the file, and you have both your Java initialization and C++ initialization both set up to configure and watch, then both should see the file change and reconfigure based on the new file settings. >Finally can both Java and C++ loggers log to the same file? Both Java and C++ will try to open the file with write permissions, so this will not work. -Andy |
| Free embeddable forum powered by Nabble | Forum Help |