RE: Passing log-time values to the Appender
If your calling class which knows about the involved city runs in a separate thread context (for each city) you can use the MDC construct which is maintained on a per thread basis. Just put your city into MDC somewhere at the thread start when the city is known, and then in the MultifileAppender you ask for this value again (MDC.put() and MDC.get(), it's just a HashMap). If you do not want to work with the not released MultifileAppender you could also use your own RepositorySelector which is also based on the MDC. Look the archive, was discussed a lot. If it is always the same thread which covers different cities you cannot use MDC for distinguishing it. You have to wrap your log message into an own object (with members LogMessage and City) which you supply to the log calls instead of the message (it's formally an object and not a string). Additionally you have to provide a custom renderer for this wrapper class which returns the embedded Message member. Heri -Original Message- From: Bruno Melloni [mailto:[EMAIL PROTECTED] Sent: Friday, August 15, 2008 11:43 PM To: Log4J Users List Subject: RE: Passing log-time values to the Appender This looks very promising, whether I use it as is or as the basis to customize my appender further. Thank you. I am still not clear as to how to submit the variables in the application (about the time I call Logger.info()) so that they arrive at the Appender's subAppend() method inside the LoggingEvent. Could you clarify? I hope it is not a dumb question. bruno -Original Message- From: Curt Arnold [mailto:[EMAIL PROTECTED] Sent: Friday, August 15, 2008 3:39 PM To: Log4J Users List Subject: Re: Passing log-time values to the Appender On Aug 15, 2008, at 3:19 PM, Bruno Melloni wrote: I have an app that makes all Logger calls happen from a single class and it uses a custom appender. I need to modify the appender so that it splits the logging to separate logs for each city. The city code is available in the calling class and is also being prefixed as the first 3 characters of every message. I know I could create an appender for each city... but that would be insane since there are too many cities. I suspect that the cleanest way would be to 'somehow' pass the city as a parameter when calling logger.info() and 'somehow' customize the appender so that it can read the value and select which file to add it to. Is this possible with log4j? If so, how? Or, is there a better way to separate the logs? Thanks, bruno There has been intermittent activity on a MultiFileAppender which supports multiple open files by one appender. It is not released and is subject to substantial change, but you may want to look at it. See https://issues.apache.org/bugzilla/show_bug.cgi?id=45165 and search the mailing list archives for MultiFileAppender. The source is available in the SVN at http://svn.apache.org/repos/asf/logging/sandbox/log4j/multifile . - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Thread org.apache.log4j.xml.XMLWatchdog
Hi folks, When I use the profiling tool off the Netbeans 6.1 IDE, I see lots of Threads that got the name org.apache.log4j.xml.XMLWatchdog. Unfortunately I didn't find much documentation about that, that's why I'm posting here. My problem is that there's lot's of threads (about 5 per instance of B) with this name when I profile code that looks like the code below. Why is that? Does log4j really need them? The profiler says they are waiting all the time. Regards, Martin java-code: class A{ DOMConfigurator.configure(log4j_config.xml); Logger loggerA = Logger.getLogger(loggerA); B b1 = new B(); B b2 = new B(); B b3 = new B(); } class B{ Logger loggerB = Logger.getLogger(loggerB); } log4j_config.xml: ?xml version=1.0 encoding=UTF-8 ? !DOCTYPE log4j:configuration SYSTEM log4j.dtd log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/; appender name=drfa class=org.apache.log4j.RollingFileAppender param name=File value=C:\\Root.log/ param name=Append value=true/ param name=MaxFileSize value=100KB/param param name=MaxBackupIndex value=5/param layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{dd/MMM/ HH:mm:ss,} [%t] - %p - %m%n/ /layout /appender appender name=rfa_a class=org.apache.log4j.RollingFileAppender param name=File value=C:\\A.log/ param name=Append value=true/ param name=MaxFileSize value=200KB/param param name=MaxBackupIndex value=10/param layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{dd/MMM/ HH:mm:ss,} [%t] - %p - %m%n/ /layout /appender appender name=rfa_b class=org.apache.log4j.RollingFileAppender param name=File value=C:\\B.log/ param name=Append value=true/ param name=MaxFileSize value=200KB/param param name=MaxBackupIndex value=10/param layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{dd/MMM/ HH:mm:ss,} [%t] - %p - %m%n/ /layout /appender logger name=loggerA additivity=false level value =all / appender-ref ref=rfa_a/ /logger logger name=loggerB additivity=false level value =all / appender-ref ref=rfa_b/ /logger root priority value =info/ appender-ref ref=drfa/ /root /log4j:configuration -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ChainSaw - accessing a file on a VM
Thank you to all those who kindly responded (ie Jacob, Scott and Curt). A question for Scott. I'm trying to use Jakarta Commons VFS but can't get it to work (java.lang.ClassNotFoundException: org.apache.log4j.chainsaw.vfs.VFSLogFilePatternReceiver)! Is there anywhere a straightforward 101 checklist that I can use instead? I have Win2000 installed on the VM (where the log file is) and XP on the workstation with the ChainSaw. Thanks once again, Doost/Mehyar 2008/8/14 Curt Arnold [EMAIL PROTECTED] On Aug 14, 2008, at 11:04 AM, Curt Arnold wrote: Looks like you'd be better off using the shared folders capabilities of your VM software and access the log file with a local path name. Or you could use NET USE to map the share to a drive letter and then use the drive letter in the URL. c:\ NET USE q: \\192.168.1.100\folder /USER:foo /PASSWORD:bar Then use file:///q:/share-path - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Using a rolling log file across multiple .ear/.war files
I have used log4j in the past, but I am trying to use it now for something where I am running into problems. Any suggestions/advice would be appreciated. I can't get a file logger to roll files. When the file reaches its preset size, it overwrites the original file instead of rolling. This situation involves a web app that includes multiple .ear files. Each .ear file has its own log, and there is a common log file across the web app. I would like to create a separate log file which can be accessed by specific pieces of each application, e.g., a special purpose log file. My current attempts have not been able to define a rolling log file. The environment is Websphere 6.0.2.x running on Windows 2003 Server. My google attempts have indicated a possible problem with multiple .ear/.war attachments to a single log file may cause problems with rolling, but there didn't seem to be a work-around. Having separate log files for this specific event log across multiple .ear/.war files would be a nightmare to debug. So, how can I use a single rolling log file to function properly across multiple .ear/.war components in a single web app? Thanks, Brent Friedman
Re: Thread org.apache.log4j.xml.XMLWatchdog
On Aug 18, 2008, at 6:35 AM, Martin Kalany wrote: Hi folks, When I use the profiling tool off the Netbeans 6.1 IDE, I see lots of Threads that got the name org.apache.log4j.xml.XMLWatchdog. Unfortunately I didn't find much documentation about that, that's why I'm posting here. My problem is that there's lot's of threads (about 5 per instance of B) with this name when I profile code that looks like the code below. Why is that? Does log4j really need them? The profiler says they are waiting all the time. Regards, Martin XMLWatchdog implement the file change monitoring in DOMConfigurator.configureAndWatch. One new instance would be created each time you call configureAndWatch, but should not be created if you just call configure. When they are used, they sleep for a specified period of time, wake up, check if the configuration file has changed and call configure if it has and then sleep again, so it would be normal for them to be waiting. I would suggest checking your code for calls to configureAndWatch to see where they are being created. If you can't find any instances in your code, set a breakpoint on the XMLWatchdog constructor and then look at the stack trace to see where they are being created. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ChainSaw - accessing a file on a VM
OK, here are the details: Follow the instructions here: http://logging.apache.org/chainsaw/distributionnotes.html The $user.home/.chainsaw folder will already exist, but you'll have to create the $user.home/.chainsaw/plugins folder and copy the required jars into that folder. I have these jars in my .chainsaw/plugins folder: commons-logging-1.1.1.jar commons-vfs-1.0.jar log4j-chainsaw-vfs.jar You'll need to add the jCIFs jar to that folder Also, under application-wide settings, there is a 'remove security manager' checkbox that you need to check. Restart Chainsaw and it should work. The chainsaw-log tab will contain additional information if you don't see the receiver in the receivers panel or no tab is created containing the events. For those of you using VFS to access ssh-accessible files with the WebStart version of Chainsaw: Add the target server to your $user.home/.ssh/known_hosts file (this requirement is removed in trunk but that version has not yet been released). Scott Deboy Principal Engineer COMOTIV SYSTEMS 111 SW Columbia Street Ste. 950 Portland, OR 97201 Office: 503.224.7496 Direct Line: 503.821.6482 Cell: 503.997.1367 Fax: 503.222.0185 [EMAIL PROTECTED] www.comotivsystems.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Aux Board Sent: Monday, August 18, 2008 6:53 AM To: Log4J Users List Subject: Re: ChainSaw - accessing a file on a VM Thank you to all those who kindly responded (ie Jacob, Scott and Curt). A question for Scott. I'm trying to use Jakarta Commons VFS but can't get it to work (java.lang.ClassNotFoundException: org.apache.log4j.chainsaw.vfs.VFSLogFilePatternReceiver)! Is there anywhere a straightforward 101 checklist that I can use instead? I have Win2000 installed on the VM (where the log file is) and XP on the workstation with the ChainSaw. Thanks once again, Doost/Mehyar 2008/8/14 Curt Arnold [EMAIL PROTECTED] On Aug 14, 2008, at 11:04 AM, Curt Arnold wrote: Looks like you'd be better off using the shared folders capabilities of your VM software and access the log file with a local path name. Or you could use NET USE to map the share to a drive letter and then use the drive letter in the URL. c:\ NET USE q: \\192.168.1.100\folder /USER:foo /PASSWORD:bar Then use file:///q:/share-path - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Can custom appender override the log4j.xml configuration
Hi I am writing a custom JDBC appender for log4j for my application. I want this custom appender NOT to be affected in any way by the loggign levels / appenders in the application log4j.xml file. The custom Logger instance has only the one appender (the custom JDBC appender which I wrote). It has no console appender etc. But, when logging happens, log statements get printed on the server console and also in the application log files. I should mention that the application log4j.xml file does have the console and file appender. I initialise the Logger instance as follows: Logger customLogger = Logger.getLogger(myCustomLogger); / / remove all appenders associated with customLogger customLogger.removeAllAppenders(); // add JDBCAppenderService to customLogger customLogger .addAppender(new JDBCAppenderService(ds)); //ds is the datasource name Now, I use customLogger to log the information as follows: customLogger.info(logObject) //logObject contains the data to be logged I want customLogger to remained unaffected by the settings in the log4j.xml file. So, if the logging level in log4j.xml is set to OFF, I still want the JDBC appneder to work i.e log data in the database. Please let me know if there any way to achieve this ?? Or does the log4j.xml configuration overrides the settings in the class files ?? Thanks and Regards, Aneez Backer - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]