Configure log4j Appender Properties
I'm using log4j1.2.8, is there anyway to check for a particular appender, say RollingFileAppender, whether it has a property, say datePattern programmatically? And then my check is passed, then i need to configure any values... Will this be possible with log4j API's? Your help appreciated. Regards Sankar -- View this message in context: http://www.nabble.com/Configure-log4j-Appender-Properties-tf3974496.html#a11281956 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Urgent Please--How to create different log files with different property files in same webapplication
Hi, I have a requirement to create different log files in same application.Our application will be used in a different web application.Even the other application is using log4j.We have our own log4j configuration property(WEB-INF/config.properties) file and separate log file in a particular directory(WEB-INF/logs/xxx.log). At present the problem is we are getting logs from other application to our log file. Our application(Giving as jar files) is under other application. For example our application is abc and others is xyz. The directory structure is webapps/xyz/WEB-INF where it contains xyz's log4j property file as well abc's log4j property file.abc's logs are supposed to go webappas/xyz/WEB-INF/logs/abc.log and xyz's logs are supposed to go different file(Which we dont know , exactly where it goes). But at present xyz's logs are coming into abc's logs means , they are coming into webapps/xyz/WEB-INF/logs/abc.log Can you please tell me how can get logs only from my applicaiton(may not be from my application..only from my classes). Its little urgent. Thanks in advacne. Regards, Sivamma. -- View this message in context: http://www.nabble.com/Urgent-Please--How-to-create-different-log-files-with-different-property-files-in-same-webapplication-tf3974952.html#a11283346 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Urgent Please--How to create different log files with different property files in same webapplication
If xyz and abc are different web apps then moving log4j.jar and log4j.xml from common to WEB-INF/lib should keep the logs separate. If they are in the same web app then they probably have different logger name roots so you can configure each to use a different appender. (i.e com.abc uses one appender and com.xyz uses another appender). On 6/25/07, sivamma [EMAIL PROTECTED] wrote: Hi, I have a requirement to create different log files in same application.Our application will be used in a different web application.Even the other application is using log4j.We have our own log4j configuration property(WEB-INF/config.properties) file and separate log file in a particular directory(WEB-INF/logs/xxx.log). At present the problem is we are getting logs from other application to our log file. Our application(Giving as jar files) is under other application. For example our application is abc and others is xyz. The directory structure is webapps/xyz/WEB-INF where it contains xyz's log4j property file as well abc's log4j property file.abc's logs are supposed to go webappas/xyz/WEB-INF/logs/abc.log and xyz's logs are supposed to go different file(Which we dont know , exactly where it goes). But at present xyz's logs are coming into abc's logs means , they are coming into webapps/xyz/WEB-INF/logs/abc.log Can you please tell me how can get logs only from my applicaiton(may not be from my application..only from my classes). Its little urgent. Thanks in advacne. Regards, Sivamma. -- View this message in context: http://www.nabble.com/Urgent-Please--How-to-create-different-log-files-with-different-property-files-in-same-webapplication-tf3974952.html#a11283346 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- James Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JUnit testing of output logged with log4j?
One option would be to using a test log4j.xml file that has appender filters that filter out expected error messages. Maintaining that might not be easy. On 6/23/07, Bob Jacobsen [EMAIL PROTECTED] wrote: I've got a bunch of code that uses log4j for logging, and a large number of unit tests done with JUnit. As is the nature of these tests, they test a lot of error conditions, which results in lots of error and warning messages logged when running the tests. Up until now, we just ignored those: If the tests passed, nobody looked at the test output. If the tests failed, then we started looking at the output for abnormal errors, which is really a mess. My co-developers and I would like to clean this whole situation up, so that the tests run with no error or warning messages appearing in the output log. But we still want to _test_ the conditions that are errors, and in the code as it exists will throw those messages. And we still want to see if _other_ error and warning messages start appearing when the tests are run. Anybody know how to Do This Right? So far, we've got a couple suggestions: 1) Go through and find all the places where the error messages are logged, and make then log through a service routine which can be over-ridden. E.g. class Mine { void doSomething() { ... if (bad) log.error(Oops); } } becomes class Mine { void doSomething() { ... if (bad) report(Oops); } void report(String msg) { log.error(msg); } } Then we can test it with new Mine(){ void report(String msg) { if (!msg.equals(Oops)) // assert error } } The subclassing lets us intercept the error _before_ it gets to log4j, and test it manually. But there's a _huge_ amount of this. It seems a complete pain to do all this, and since we'd be putting in a cover layer in front of log4j in each class, it seems far from a best practice. 2) Instead of suppressing the good messages, learn to ignore them. To do this, we'd just take a log from normal tests, and built into our testing that we diff the current output with the normal log. New or missing lines would be visible to the author; the same old stuff would pass through the diff. Of course, this is a maintenance nightmare. As code changes, we'd have to keep the master error log synchronized, but it would be easy for somebody to pass a Really Bad Thing as a new normal error. This is currently the most popular choice, mostly because it doesn't need to rework the existing code, but I really don't like it. 3) Do something via log4j itself. I'm not even sure what I'm asking here, but can we somehow programmatically access a stream of log4j log entries, and manipulate it? What I'm imagining is a test like this: a) Push all existing stuff in log to whatever outputs are configured. b) Temporarily stop output of log entries c) run test d) Check through log entries accumulated since (b), which come from the test, and remove the ones that are expected (optionally, tell JUnit to fail if something is missing) e) Allow all other log entries to continue to their configured outputs If there was some way to do this, we could have unexpected messages still go to the usual places, as configured, but remove expected messages from the log stream. Is there a way to do this? Or is there a better solution to the whole need? Thanks in advance. Bob -- Bob Jacobsen, UC Berkeley [EMAIL PROTECTED] +1-510-486-7355 fax +1-510-643-8497 AIM, Skype JacobsenRG - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- James Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Urgent Please--How to create different log files with different property files in same webapplication
Can you better explain the relationship between abc and xyz? It sounds like xyz uses abc as a library and that abc also runs by itself. Repository selectors might help. On 6/25/07, sivamma [EMAIL PROTECTED] wrote: We dont know exactly how log4j is handled at XYZ(They are our customers).But in abc , we are referring a config file through our code. Please find our java code. == package com.CK; import java.io.File; import org.apache.log4j.Logger; import org.apache.log4j.Level; import org.apache.log4j.PropertyConfigurator; public class Log4jSetup { public static String rPath = null; public Log4jSetup(String realPath) { rPath = realPath; } public Log4jSetup() { String filePath = rPath+File.separator+WEB-INF+File.separator+config.properties; String logfilePath = rPath+File.separator+WEB-INF+File.separator+logs+File.separator; if( !(new File(filePath)).isFile()) { System.err.println([CK]ERROR:Log4jSetUp::Cannot read the Log4J configuration file. ); } System.setProperty(ck.base,logfilePath); PropertyConfigurator.configure(filePath); Logger log = Logger.getLogger(Log4jSetup.class); } } = Thanks Regards, Sivamma. James Stauffer wrote: How exactly is log4j configured from abc and xyz? Directly through code? Code referencing a config file? log4j automatically finding a config file? On 6/25/07, sivamma [EMAIL PROTECTED] wrote: Hi, Thank you for immediate reply. The problem is little different here.XYZ and abc are in same application.XYZ is using abc's jar files and jsps. Our application(abc) have our own log4j configuration property file at WEB-INF folder of XYZ(WEB-INF is common for both of XYZ and abc). We are configuring log4j from java class file.We can not add/modify/delete XYZ's log4j configuration property file.At present we are getting even the XYZ's logs in our log files. Please find our log4j configuration(abc's) log4j.appender.mail.layout=org.apache.log4j.PatternLayout [EMAIL PROTECTED] log4j.appender.mail=org.apache.log4j.net.SMTPAppender log4j.appender.mail.SMTPPassword=xx log4j.appender.mail.BufferSize=512 log4j.appender.R.layout.ConversionPattern=%d{ MMM dd HH\:mm\:ss} -- %p -- %m%n log4j.appender.mail.evaluatorClass=com.CK.Evaluator log4j.appender.mail.SMTPUsername=siva log4j.appender.R.File=${ck.base}ck_logs.log log4j.rootCategory=debug, R,mail [EMAIL PROTECTED] log4j.appender.R.MaxBackupIndex=10 log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.mail.Threshold=WARN log4j.appender.mail.layout.ConversionPattern=%d{ MMM dd HH\:mm\:ss} -- %p -- %m%n log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.MaxFileSize=100KB log4j.appender.mail.Subject=\=[SMTPAppender] Application message log4j.appender.mail.SMTPHost=mail.abc.com It(abc) works fine as a single application in tomcat6. But when XYZ starts using abc the problem occurs(XYZ is using Weblogic Application server). Is there way to get separate the logs in a same application with different log4j configuration property files. Thanks Regards, Sivamma James Stauffer wrote: If xyz and abc are different web apps then moving log4j.jar and log4j.xml from common to WEB-INF/lib should keep the logs separate. If they are in the same web app then they probably have different logger name roots so you can configure each to use a different appender. (i.e com.abc uses one appender and com.xyz uses another appender). On 6/25/07, sivamma [EMAIL PROTECTED] wrote: Hi, I have a requirement to create different log files in same application.Our application will be used in a different web application.Even the other application is using log4j.We have our own log4j configuration property(WEB-INF/config.properties) file and separate log file in a particular directory(WEB-INF/logs/xxx.log). At present the problem is we are getting logs from other application to our log file. Our application(Giving as jar files) is under other application. For example our application is abc and others is xyz. The directory structure is webapps/xyz/WEB-INF where it contains xyz's log4j property file as well abc's log4j property file.abc's logs are supposed to go webappas/xyz/WEB-INF/logs/abc.log and xyz's logs are supposed to go different file(Which we dont know , exactly where it goes). But at present xyz's logs are coming into abc's logs means , they are coming into webapps/xyz/WEB-INF/logs/abc.log Can you please tell me how can get logs only from my applicaiton(may not be from my application..only from my classes). Its little
Re: Urgent Please--How to create different log files with different property files in same webapplication
- Original Message - From: sivamma [EMAIL PROTECTED] To: log4j-user@logging.apache.org log4j-user@logging.apache.org Sent: Mon Jun 25 09:11:16 2007 Subject: Re: Urgent Please--How to create different log files with different property files in same webapplication Hi, Thank you for immediate reply. The problem is little different here.XYZ and abc are in same application.XYZ is using abc's jar files and jsps. Our application(abc) have our own log4j configuration property file at WEB-INF folder of XYZ(WEB-INF is common for both of XYZ and abc). We are configuring log4j from java class file.We can not add/modify/delete XYZ's log4j configuration property file.At present we are getting even the XYZ's logs in our log files. Please find our log4j configuration(abc's) log4j.appender.mail.layout=org.apache.log4j.PatternLayout [EMAIL PROTECTED] log4j.appender.mail=org.apache.log4j.net.SMTPAppender log4j.appender.mail.SMTPPassword=xx log4j.appender.mail.BufferSize=512 log4j.appender.R.layout.ConversionPattern=%d{ MMM dd HH\:mm\:ss} -- %p -- %m%n log4j.appender.mail.evaluatorClass=com.CK.Evaluator log4j.appender.mail.SMTPUsername=siva log4j.appender.R.File=${ck.base}ck_logs.log log4j.rootCategory=debug, R,mail [EMAIL PROTECTED] log4j.appender.R.MaxBackupIndex=10 log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.mail.Threshold=WARN log4j.appender.mail.layout.ConversionPattern=%d{ MMM dd HH\:mm\:ss} -- %p -- %m%n log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.MaxFileSize=100KB log4j.appender.mail.Subject=\=[SMTPAppender] Application message log4j.appender.mail.SMTPHost=mail.abc.com It(abc) works fine as a single application in tomcat6. But when XYZ starts using abc the problem occurs(XYZ is using Weblogic Application server). Is there way to get separate the logs in a same application with different log4j configuration property files. Thanks Regards, Sivamma James Stauffer wrote: If xyz and abc are different web apps then moving log4j.jar and log4j.xml from common to WEB-INF/lib should keep the logs separate. If they are in the same web app then they probably have different logger name roots so you can configure each to use a different appender. (i.e com.abc uses one appender and com.xyz uses another appender). On 6/25/07, sivamma [EMAIL PROTECTED] wrote: Hi, I have a requirement to create different log files in same application.Our application will be used in a different web application.Even the other application is using log4j.We have our own log4j configuration property(WEB-INF/config.properties) file and separate log file in a particular directory(WEB-INF/logs/xxx.log). At present the problem is we are getting logs from other application to our log file. Our application(Giving as jar files) is under other application. For example our application is abc and others is xyz. The directory structure is webapps/xyz/WEB-INF where it contains xyz's log4j property file as well abc's log4j property file.abc's logs are supposed to go webappas/xyz/WEB-INF/logs/abc.log and xyz's logs are supposed to go different file(Which we dont know , exactly where it goes). But at present xyz's logs are coming into abc's logs means , they are coming into webapps/xyz/WEB-INF/logs/abc.log Can you please tell me how can get logs only from my applicaiton(may not be from my application..only from my classes). Its little urgent. Thanks in advacne. Regards, Sivamma. -- View this message in context: http://www.nabble.com/Urgent-Please--How-to-create-different-log-files-with-different-property-files-in-same-webapplication-tf3974952.html#a11283346 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- James Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Urgent-Please--How-to-create-different-log-files-with-different-property-files-in-same-webapplication-tf3974952.html#a11286397 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Urgent Please--How to create different log files with different property files in same webapplication
- Original Message - From: sivamma [EMAIL PROTECTED] To: log4j-user@logging.apache.org log4j-user@logging.apache.org Sent: Mon Jun 25 09:11:16 2007 Subject: Re: Urgent Please--How to create different log files with different property files in same webapplication Hi, Thank you for immediate reply. The problem is little different here.XYZ and abc are in same application.XYZ is using abc's jar files and jsps. Our application(abc) have our own log4j configuration property file at WEB-INF folder of XYZ(WEB-INF is common for both of XYZ and abc). We are configuring log4j from java class file.We can not add/modify/delete XYZ's log4j configuration property file.At present we are getting even the XYZ's logs in our log files. Please find our log4j configuration(abc's) log4j.appender.mail.layout=org.apache.log4j.PatternLayout [EMAIL PROTECTED] log4j.appender.mail=org.apache.log4j.net.SMTPAppender log4j.appender.mail.SMTPPassword=xx log4j.appender.mail.BufferSize=512 log4j.appender.R.layout.ConversionPattern=%d{ MMM dd HH\:mm\:ss} -- %p -- %m%n log4j.appender.mail.evaluatorClass=com.CK.Evaluator log4j.appender.mail.SMTPUsername=siva log4j.appender.R.File=${ck.base}ck_logs.log log4j.rootCategory=debug, R,mail [EMAIL PROTECTED] log4j.appender.R.MaxBackupIndex=10 log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.mail.Threshold=WARN log4j.appender.mail.layout.ConversionPattern=%d{ MMM dd HH\:mm\:ss} -- %p -- %m%n log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.MaxFileSize=100KB log4j.appender.mail.Subject=\=[SMTPAppender] Application message log4j.appender.mail.SMTPHost=mail.abc.com It(abc) works fine as a single application in tomcat6. But when XYZ starts using abc the problem occurs(XYZ is using Weblogic Application server). Is there way to get separate the logs in a same application with different log4j configuration property files. Thanks Regards, Sivamma James Stauffer wrote: If xyz and abc are different web apps then moving log4j.jar and log4j.xml from common to WEB-INF/lib should keep the logs separate. If they are in the same web app then they probably have different logger name roots so you can configure each to use a different appender. (i.e com.abc uses one appender and com.xyz uses another appender). On 6/25/07, sivamma [EMAIL PROTECTED] wrote: Hi, I have a requirement to create different log files in same application.Our application will be used in a different web application.Even the other application is using log4j.We have our own log4j configuration property(WEB-INF/config.properties) file and separate log file in a particular directory(WEB-INF/logs/xxx.log). At present the problem is we are getting logs from other application to our log file. Our application(Giving as jar files) is under other application. For example our application is abc and others is xyz. The directory structure is webapps/xyz/WEB-INF where it contains xyz's log4j property file as well abc's log4j property file.abc's logs are supposed to go webappas/xyz/WEB-INF/logs/abc.log and xyz's logs are supposed to go different file(Which we dont know , exactly where it goes). But at present xyz's logs are coming into abc's logs means , they are coming into webapps/xyz/WEB-INF/logs/abc.log Can you please tell me how can get logs only from my applicaiton(may not be from my application..only from my classes). Its little urgent. Thanks in advacne. Regards, Sivamma. -- View this message in context: http://www.nabble.com/Urgent-Please--How-to-create-different-log-files-with-different-property-files-in-same-webapplication-tf3974952.html#a11283346 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- James Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Urgent-Please--How-to-create-different-log-files-with-different-property-files-in-same-webapplication-tf3974952.html#a11286397 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Urgent Please--How to create different log files with different property files in same webapplication
How exactly is log4j configured from abc and xyz? Directly through code? Code referencing a config file? log4j automatically finding a config file? On 6/25/07, sivamma [EMAIL PROTECTED] wrote: Hi, Thank you for immediate reply. The problem is little different here.XYZ and abc are in same application.XYZ is using abc's jar files and jsps. Our application(abc) have our own log4j configuration property file at WEB-INF folder of XYZ(WEB-INF is common for both of XYZ and abc). We are configuring log4j from java class file.We can not add/modify/delete XYZ's log4j configuration property file.At present we are getting even the XYZ's logs in our log files. Please find our log4j configuration(abc's) log4j.appender.mail.layout=org.apache.log4j.PatternLayout [EMAIL PROTECTED] log4j.appender.mail=org.apache.log4j.net.SMTPAppender log4j.appender.mail.SMTPPassword=xx log4j.appender.mail.BufferSize=512 log4j.appender.R.layout.ConversionPattern=%d{ MMM dd HH\:mm\:ss} -- %p -- %m%n log4j.appender.mail.evaluatorClass=com.CK.Evaluator log4j.appender.mail.SMTPUsername=siva log4j.appender.R.File=${ck.base}ck_logs.log log4j.rootCategory=debug, R,mail [EMAIL PROTECTED] log4j.appender.R.MaxBackupIndex=10 log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.mail.Threshold=WARN log4j.appender.mail.layout.ConversionPattern=%d{ MMM dd HH\:mm\:ss} -- %p -- %m%n log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.MaxFileSize=100KB log4j.appender.mail.Subject=\=[SMTPAppender] Application message log4j.appender.mail.SMTPHost=mail.abc.com It(abc) works fine as a single application in tomcat6. But when XYZ starts using abc the problem occurs(XYZ is using Weblogic Application server). Is there way to get separate the logs in a same application with different log4j configuration property files. Thanks Regards, Sivamma James Stauffer wrote: If xyz and abc are different web apps then moving log4j.jar and log4j.xml from common to WEB-INF/lib should keep the logs separate. If they are in the same web app then they probably have different logger name roots so you can configure each to use a different appender. (i.e com.abc uses one appender and com.xyz uses another appender). On 6/25/07, sivamma [EMAIL PROTECTED] wrote: Hi, I have a requirement to create different log files in same application.Our application will be used in a different web application.Even the other application is using log4j.We have our own log4j configuration property(WEB-INF/config.properties) file and separate log file in a particular directory(WEB-INF/logs/xxx.log). At present the problem is we are getting logs from other application to our log file. Our application(Giving as jar files) is under other application. For example our application is abc and others is xyz. The directory structure is webapps/xyz/WEB-INF where it contains xyz's log4j property file as well abc's log4j property file.abc's logs are supposed to go webappas/xyz/WEB-INF/logs/abc.log and xyz's logs are supposed to go different file(Which we dont know , exactly where it goes). But at present xyz's logs are coming into abc's logs means , they are coming into webapps/xyz/WEB-INF/logs/abc.log Can you please tell me how can get logs only from my applicaiton(may not be from my application..only from my classes). Its little urgent. Thanks in advacne. Regards, Sivamma. -- View this message in context: http://www.nabble.com/Urgent-Please--How-to-create-different-log-files-with-different-property-files-in-same-webapplication-tf3974952.html#a11283346 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- James Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Urgent-Please--How-to-create-different-log-files-with-different-property-files-in-same-webapplication-tf3974952.html#a11286397 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- James Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Urgent Please--How to create different log files with different property files in same webapplication
Hi, Thank you for immediate reply. The problem is little different here.XYZ and abc are in same application.XYZ is using abc's jar files and jsps. Our application(abc) have our own log4j configuration property file at WEB-INF folder of XYZ(WEB-INF is common for both of XYZ and abc). We are configuring log4j from java class file.We can not add/modify/delete XYZ's log4j configuration property file.At present we are getting even the XYZ's logs in our log files. Please find our log4j configuration(abc's) log4j.appender.mail.layout=org.apache.log4j.PatternLayout [EMAIL PROTECTED] log4j.appender.mail=org.apache.log4j.net.SMTPAppender log4j.appender.mail.SMTPPassword=xx log4j.appender.mail.BufferSize=512 log4j.appender.R.layout.ConversionPattern=%d{ MMM dd HH\:mm\:ss} -- %p -- %m%n log4j.appender.mail.evaluatorClass=com.CK.Evaluator log4j.appender.mail.SMTPUsername=siva log4j.appender.R.File=${ck.base}ck_logs.log log4j.rootCategory=debug, R,mail [EMAIL PROTECTED] log4j.appender.R.MaxBackupIndex=10 log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.mail.Threshold=WARN log4j.appender.mail.layout.ConversionPattern=%d{ MMM dd HH\:mm\:ss} -- %p -- %m%n log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.MaxFileSize=100KB log4j.appender.mail.Subject=\=[SMTPAppender] Application message log4j.appender.mail.SMTPHost=mail.abc.com It(abc) works fine as a single application in tomcat6. But when XYZ starts using abc the problem occurs(XYZ is using Weblogic Application server). Is there way to get separate the logs in a same application with different log4j configuration property files. Thanks Regards, Sivamma James Stauffer wrote: If xyz and abc are different web apps then moving log4j.jar and log4j.xml from common to WEB-INF/lib should keep the logs separate. If they are in the same web app then they probably have different logger name roots so you can configure each to use a different appender. (i.e com.abc uses one appender and com.xyz uses another appender). On 6/25/07, sivamma [EMAIL PROTECTED] wrote: Hi, I have a requirement to create different log files in same application.Our application will be used in a different web application.Even the other application is using log4j.We have our own log4j configuration property(WEB-INF/config.properties) file and separate log file in a particular directory(WEB-INF/logs/xxx.log). At present the problem is we are getting logs from other application to our log file. Our application(Giving as jar files) is under other application. For example our application is abc and others is xyz. The directory structure is webapps/xyz/WEB-INF where it contains xyz's log4j property file as well abc's log4j property file.abc's logs are supposed to go webappas/xyz/WEB-INF/logs/abc.log and xyz's logs are supposed to go different file(Which we dont know , exactly where it goes). But at present xyz's logs are coming into abc's logs means , they are coming into webapps/xyz/WEB-INF/logs/abc.log Can you please tell me how can get logs only from my applicaiton(may not be from my application..only from my classes). Its little urgent. Thanks in advacne. Regards, Sivamma. -- View this message in context: http://www.nabble.com/Urgent-Please--How-to-create-different-log-files-with-different-property-files-in-same-webapplication-tf3974952.html#a11283346 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- James Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Urgent-Please--How-to-create-different-log-files-with-different-property-files-in-same-webapplication-tf3974952.html#a11286397 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Urgent Please--How to create different log files with different property files in same webapplication
We dont know exactly how log4j is handled at XYZ(They are our customers).But in abc , we are referring a config file through our code. Please find our java code. == package com.CK; import java.io.File; import org.apache.log4j.Logger; import org.apache.log4j.Level; import org.apache.log4j.PropertyConfigurator; public class Log4jSetup { public static String rPath = null; public Log4jSetup(String realPath) { rPath = realPath; } public Log4jSetup() { String filePath = rPath+File.separator+WEB-INF+File.separator+config.properties; String logfilePath = rPath+File.separator+WEB-INF+File.separator+logs+File.separator; if( !(new File(filePath)).isFile()) { System.err.println([CK]ERROR:Log4jSetUp::Cannot read the Log4J configuration file. ); } System.setProperty(ck.base,logfilePath); PropertyConfigurator.configure(filePath); Logger log = Logger.getLogger(Log4jSetup.class); } } = Thanks Regards, Sivamma. James Stauffer wrote: How exactly is log4j configured from abc and xyz? Directly through code? Code referencing a config file? log4j automatically finding a config file? On 6/25/07, sivamma [EMAIL PROTECTED] wrote: Hi, Thank you for immediate reply. The problem is little different here.XYZ and abc are in same application.XYZ is using abc's jar files and jsps. Our application(abc) have our own log4j configuration property file at WEB-INF folder of XYZ(WEB-INF is common for both of XYZ and abc). We are configuring log4j from java class file.We can not add/modify/delete XYZ's log4j configuration property file.At present we are getting even the XYZ's logs in our log files. Please find our log4j configuration(abc's) log4j.appender.mail.layout=org.apache.log4j.PatternLayout [EMAIL PROTECTED] log4j.appender.mail=org.apache.log4j.net.SMTPAppender log4j.appender.mail.SMTPPassword=xx log4j.appender.mail.BufferSize=512 log4j.appender.R.layout.ConversionPattern=%d{ MMM dd HH\:mm\:ss} -- %p -- %m%n log4j.appender.mail.evaluatorClass=com.CK.Evaluator log4j.appender.mail.SMTPUsername=siva log4j.appender.R.File=${ck.base}ck_logs.log log4j.rootCategory=debug, R,mail [EMAIL PROTECTED] log4j.appender.R.MaxBackupIndex=10 log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.mail.Threshold=WARN log4j.appender.mail.layout.ConversionPattern=%d{ MMM dd HH\:mm\:ss} -- %p -- %m%n log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.MaxFileSize=100KB log4j.appender.mail.Subject=\=[SMTPAppender] Application message log4j.appender.mail.SMTPHost=mail.abc.com It(abc) works fine as a single application in tomcat6. But when XYZ starts using abc the problem occurs(XYZ is using Weblogic Application server). Is there way to get separate the logs in a same application with different log4j configuration property files. Thanks Regards, Sivamma James Stauffer wrote: If xyz and abc are different web apps then moving log4j.jar and log4j.xml from common to WEB-INF/lib should keep the logs separate. If they are in the same web app then they probably have different logger name roots so you can configure each to use a different appender. (i.e com.abc uses one appender and com.xyz uses another appender). On 6/25/07, sivamma [EMAIL PROTECTED] wrote: Hi, I have a requirement to create different log files in same application.Our application will be used in a different web application.Even the other application is using log4j.We have our own log4j configuration property(WEB-INF/config.properties) file and separate log file in a particular directory(WEB-INF/logs/xxx.log). At present the problem is we are getting logs from other application to our log file. Our application(Giving as jar files) is under other application. For example our application is abc and others is xyz. The directory structure is webapps/xyz/WEB-INF where it contains xyz's log4j property file as well abc's log4j property file.abc's logs are supposed to go webappas/xyz/WEB-INF/logs/abc.log and xyz's logs are supposed to go different file(Which we dont know , exactly where it goes). But at present xyz's logs are coming into abc's logs means , they are coming into webapps/xyz/WEB-INF/logs/abc.log Can you please tell me how can get logs only from my applicaiton(may not be from my application..only from my classes). Its little urgent. Thanks in advacne. Regards, Sivamma. -- View this message in context:
Re: Urgent Please--How to create different log files with different property files in same webapplication
So does only your customer have the problem of mixed logs? It sounds like they just need to change their config if they don't want mixed logs. But knowing how customers can be repository selectors might keep the logs separate without the customer changing their config. On 6/25/07, sivamma [EMAIL PROTECTED] wrote: Yes thats true. xyz uses abc as a library and abc runs by itself. Can you better explain the relationship between abc and xyz? It sounds like xyz uses abc as a library and that abc also runs by itself. -- View this message in context: http://www.nabble.com/Urgent-Please--How-to-create-different-log-files-with-different-property-files-in-same-webapplication-tf3974952.html#a11287148 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- James Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Urgent Please--How to create different log files with different property files in same webapplication
Can you please explain me more.How to implement repository selectors.Please send me some examples. I tried to find in FAQs and some docs.But its not clear to me. Thanks Regards, Sivamma. So does only your customer have the problem of mixed logs? It sounds like they just need to change their config if they don't want mixed logs. But knowing how customers can be repository selectors might keep the logs separate without the customer changing their config. -- View this message in context: http://www.nabble.com/Urgent-Please--How-to-create-different-log-files-with-different-property-files-in-same-webapplication-tf3974952.html#a11288789 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Log4j Configuration
Hi Hopefully someone can help me. I want to configure log4j from a properties file. I am writing a little java application. I have several log4j appenders and everything works well. However I want the option to exit application if ANY of log4j configuration fails. By default I am seeing a warning message from Log4j but application continues to run... Do you know of a property to set for log4j that application exits if log4j properties are not correct? OR should I attempt this programmicatally. Rgds Ed Howard --- This e-mail was sent by GlaxoSmithKline Services Unlimited (registered in England and Wales No. 1047315), which is a member of the GlaxoSmithKline group of companies. The registered address of GlaxoSmithKline Services Unlimited is 980 Great West Road, Brentford, Middlesex TW8 9GS. ---
Re: Urgent Please--How to create different log files with different property files in same webapplication
Search the mailing list archives. I have never used them -- I am just somewhat familiar with what they do. On 6/25/07, sivamma [EMAIL PROTECTED] wrote: Can you please explain me more.How to implement repository selectors.Please send me some examples. I tried to find in FAQs and some docs.But its not clear to me. Thanks Regards, Sivamma. So does only your customer have the problem of mixed logs? It sounds like they just need to change their config if they don't want mixed logs. But knowing how customers can be repository selectors might keep the logs separate without the customer changing their config. -- View this message in context: http://www.nabble.com/Urgent-Please--How-to-create-different-log-files-with-different-property-files-in-same-webapplication-tf3974952.html#a11288789 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- James Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JUnit testing of output logged with log4j?
Bob -- Have you considered using an appender that doesn't write to any files but simply collects all messages for later analysis? Here's how: 1) Create an appender that simply stores all logging messages in a static array. This appender should also provide static methods to (a) retrieve all messages that were logged and (b) clear out the static message array. Something like this: package com.fwl; import java.util.ArrayList; import java.util.List; import org.apache.log4j.AppenderSkeleton; import org.apache.log4j.spi.LoggingEvent; public class AppenderForTesting extends AppenderSkeleton { private static List messages = new ArrayList(); protected void append(LoggingEvent event) { messages.add(event.getRenderedMessage()); } public void close() {} public boolean requiresLayout() {return false;} public static String[] getMessages() { return (String[]) messages.toArray(new String[messages.size()]); } public static void clear() { messages.clear(); } } BTW, fwl is my TLA for fun with logging. 2) Configure log4j so that this appender is attached to all loggers are used by the target of your test. I'm taking a very simplistic approach here and just attaching this appender to the root logger: log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' appender name=PrimaryAppender class=com.fwl.AppenderForTesting layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%m%n / /layout /appender root level value=debug / appender-ref ref=PrimaryAppender / /root /log4j:configuration 3) In the setUp method in your test harness, clear out the message list that's used by the appender: protected void setUp() throws Exception { super.setUp(); AppenderForTesting.clear(); } You also may want to include this logic in the tearDown method as well, just to ensure that the message list is kept to a minimum. 4) In your test, after you invoke the method that should generate logging messages, validate the actual output. Here is the code for a simple class I wrote that just divides two numbers and a test harness for that class. package com.fwl; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; public class MyMath { private static final Logger LOG = LogManager.getLogger(MyMath.class); public static double divide(int numerator, int denominator) { LOG.debug(dividing + numerator + by + denominator); try { return (numerator / denominator); } catch (Exception e) { LOG.error(Unable to divide + numerator + by + denominator, e); if (denominator==0){ LOG.error(You should never attempt to divide by 0); } return 0; } } } package com.fwl; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import junit.framework.TestCase; public class MyMathTest extends TestCase { public void testDivideDenominatorIsZero() { MyMath.divide(2, 0); String[] expectedMessage = new String[]{dividing 2 by 0}; validateMessages(expectedMessage); } private void validateMessages(String expectedMessages[]) { // Build a list of expected messages. List expected = new ArrayList(); for (int i = 0; i expectedMessages.length; i++) { if (expectedMessages[i] != null) { expected.add(expectedMessages[i]); } } // Evaluate the actual messages that were recorded. List unexpected = new ArrayList(); String actual[] = AppenderForTesting.getMessages(); for (int i = 0; i actual.length; i++) { if (actual[i] != null) { if (expected.contains(actual[i])) { expected.remove(actual[i]); } else { unexpected.add(actual[i]); } } } // Fail if any expected messages were not found. if (!expected.isEmpty()) { StringBuffer sb = new StringBuffer(); for (Iterator iter = expected.iterator(); iter.hasNext();) { sb.append(\n).append((String) iter.next()); } fail(did not receive the following message(s): + sb); } // Fail if any unexpected messages were found. if (!unexpected.isEmpty()) { StringBuffer sb = new StringBuffer(); for (Iterator iter = unexpected.iterator(); iter.hasNext();) { sb.append(\n).append((String) iter.next()); } fail(received the following unexpected message(s): + sb); } } } In the testDivideDenominatorIsZero method, we are only expecting the message dividing 2 by 0. However, the actual test writes out two extra messages when the denominator is 0: * Unable to divide 2 by 0 * You
Use of NDC in chainsaw config
Hi there, I have several Tomcats running and generating logs. Within each Tomcat I have several Web-apps that generates logs. All these logs are going into chainsaw, However I want to differentiate the source of all logs. That is It should display in the log message it self that this log comes from ABC Web-app of Tomcat 1.. or this log is coming from XYZ web-app from Tomcat 2. (for example) I can use NDC for this but I dont know how to use it. Please help me in solving this problem. If possible please explain me by some relevant example. Thanks in advance. - Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.
logweb?
Did the updated version of logweb ever come out? The web site appears to be out of date and unmaintained. The the live demo link is broken, CVS web browse is broken, etc. In February, Nathan Coast wrote: Hi all, the current logweb is quite old, a new updated version with many usability enhancements is just around the corner. new features: searching and sorting of loggers (loggers can run into the thousands) exporting config to log4j.xml persisting and loading xml to db for clustered configuration hopefully the next version will be available in 2-3 weeks. cheers Nathan Traeder, Philipp wrote: On Saturday 10 February 2007 17:14, Jacob Kjome wrote: At 08:03 AM 2/10/2007, you wrote: Is there something in java for log4j similar to this web interface that exists for l4n ? http://www.l4ndash.com/ Hi Ricardo, I'm working on a similar project right now. Not to discourage your work, but are you sure you aren't reinventing the wheel? http://www.codeczar.com/products/logweb/ There's certainly a few things that could be improved in LogWeb, such as support for multiple logger repositories instead of just displaying info about the default logger repository. But the core is there and works well. I wonder if you could build on it instead of creating something from scratch? Then again, maybe you have something much better and need to do it from scratch, in which case I eagerly await the fruits of your labor :-) Hi Jake, thanks for the hint - I wouldn't claim that I am not reinventing the wheel...that's one of my favourite hobbies ;-) I haven't worked with LogWeb yet, but according to their website, LogWeb is a web interface for configuring Log4J at runtime within a servlet container. The Live Demo on the LogWeb page isn't working and so far I have been too lazy to download and install it, but from what I've read on their page it is more about configuring the loggers of an application at runtime than about analyzing the logs themselves. As of now, I'm more interested in having the log files or our 60+ servers in a central database in a format which I can run queries against. That's why I responded to Ricardo's posting - to me it looks as if l4n is working in a similar direction, though in a different language and on a different level of granularity. Anyway: Thanks for letting me know, I'll take a look at LogWeb these days. Have a nice weekend, Philipp - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Luggage? GPS? Comic books? Check out fitting gifts for grads at Yahoo! Search http://search.yahoo.com/search?fr=oni_on_mailp=graduation+giftscs=bz