Re: Unnecessary garbage
On Jan 24, 2007, at 12:17 AM, Chris wrote: Why does the logger force you to use Strings? logger.info("some string here" + someValue); In most cases, you're going to be creating some dynamic value that must be constructed, which means that you are always better off using a char array or a StringBuffer to build it. These buffers can be reused. A String, on the other hand, always creates unnecessary garbage. Am I crazy, or was this just a poor design decision? It seems pretty clear that there ought to be a method like this: // initialized once StringBuffer buf = ... // to log a new message buf.clear(); buf.append("some string here"); buf.append(someValue); logger.info(buf); Actually that should work, all the logging methods take an Object and call the toString() method to get a string when resolving the final message. However if you are doing a lot of that type of stuff, I would suggest looking at the formatter project in the log4j sandbox, where you would do something like: LogMF.info(logger, "some string here{0}", someValue); log4j 1.3 has its own unusual formatting specification which would be something like: logger.info("some string here{}", someValue); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Unnecessary garbage
Why does the logger force you to use Strings? logger.info("some string here" + someValue); In most cases, you're going to be creating some dynamic value that must be constructed, which means that you are always better off using a char array or a StringBuffer to build it. These buffers can be reused. A String, on the other hand, always creates unnecessary garbage. Am I crazy, or was this just a poor design decision? It seems pretty clear that there ought to be a method like this: // initialized once StringBuffer buf = ... // to log a new message buf.clear(); buf.append("some string here"); buf.append(someValue); logger.info(buf); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to use log4j (log4j.xml) and Maven and Junit??
Jacob Kjome visi.com> writes: > > > Change: > -Dlog4j.configuration=c:\tmp\log4j.xml test > > To: > -Dlog4j.configuration=file:///c:/tmp/log4j.xml test > > Or, just copy log4j.xml to the root directory of your compiled test > classes and let Log4j autoconfigure itself. > > Jake > > Still no luck with either option mentioned. I searched on where maven stuck the .class files and copied my log4j.xml there in the same directory. No luck. I did a $which mvn and found mvn, which is a text file and edited it where it runs maven, specifically: exec "$JAVACMD" \ $MAVEN_OPTS \ -classpath "${M2_HOME}"/core/boot/classworlds-*.jar \ "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \ "-Dmaven.home=${M2_HOME}" \ "-Dlog4j.configuration=file:///C:/tmp/log4j.xml" \ "-Dlog4j.debug" \ ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS no luck with the above. Trying to run maven, which is using the surefire plugin to run tests (.java) which contain log.debug(msg) and have tried everything. I am sure this is the script that is running mvn. I commented out the exec "JAVACMD" section completely and nothing ran so I know it is hitting this code to run mvn. When I run the test cases it always says: [INFO] [surefire:test] [INFO] Surefire report directory: C:\home\projects\branches\rel\sql\target\surefire-reports log4j:WARN No appenders could be found for logger (com.presence.sql.DbTestCase). log4j:WARN Please initialize the log4j system properly. --- my log4j.xml has an appender like so (copied from another area where log4j is working with a file just like this on another system): http://jakarta.apache.org/log4j/"; disable="debug" debug="true"> - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to use log4j (log4j.xml) and Maven and Junit??
James Stauffer gmail.com> writes: > > Try putting the log4j.xml in the working directory and not providing a > path (just the filename). Also run with -Dlog4j.debug to see what > log4j finds. > > Thanks, where do I put -Dlog4j.debug? I put it in the shell script that is run when I type "mvn" but nothing happened. I did a "which mvn" and edited that file (mvn execution code listed in previous post beginning with exec "$JAVACMD" \), but did not see anything different. Also where is my working directory? Is it the directory I run mvn in? I put log4j.xml in about every place I could think of with no luck. Currently the log4j.xml is in the same directory as pom.xml where I run mvn test from. thanks, still trying to figure this one out with no luck. Lisa - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to use log4j (log4j.xml) and Maven and Junit??
Change: -Dlog4j.configuration=c:\tmp\log4j.xml test To: -Dlog4j.configuration=file:///c:/tmp/log4j.xml test Or, just copy log4j.xml to the root directory of your compiled test classes and let Log4j autoconfigure itself. Jake At 04:16 PM 1/23/2007, you wrote: >I have written some JUnit tests and put them in the standard layout for test >cases under Maven. The tests use log.debug(msg), log.info(msg) etc. > >The tests run OK. > >So now I created a simple log4j.xml file with an appender and a logger that >filters only the logging messages in my test case (by package). > >When I run maven (mvn test), how do I tell it where my log4j.xml is and how to >use log4j logging? > >I have tried everything. I edited the "mvn" script under the install directory >to include the following: > > exec "$JAVACMD" \ > $MAVEN_OPTS \ > -classpath "${M2_HOME}"/core/boot/classworlds-*.jar \ > "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \ > "-Dmaven.home=${M2_HOME}" \ > "-Dmaven.junit.sysproperties=log4j.configuration" \ > "-Dlog4j.configuration=file:C:\tmp\log4j.xml" \ > ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS > > >this does not work (have tried with and without file:. > >--- >I have included a something similiar on the mvn command line: > mvn -Dlog4j.configuration=c:\tmp\log4j.xml test > >this does not work (have included =file:c:\tmp... as well > >--- >I have also tried setting properties in the pom.xml like so: > > >org.apache.maven.plugins >maven-surefire-plugin > >false >false > > > >maven.junit.sysproperties >log4j.configuration > > >log4j.configuration >file=:c:\tmp\log4j.xml > > > > > >--- >and > > >org.apache.maven.plugins >maven-surefire-plugin > >false >false > > > >maven.junit.sysproperties >log4j.configuration > > >log4j.configuration >c:\tmp\log4j.xml > > > > > >--- and (log4j.xml is in same directory as pom.xml) this does not work either. > > > >org.apache.maven.plugins >maven-surefire-plugin > >false >false > > > >maven.junit.sysproperties >log4j.configuration > > >log4j.configuration >log4j.xml > > > > > > >--- >none of these work. Any ideas on how to integrate Maven2, Log4J and >Junit would >be greatly appreciated. > > >- >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]
Re: How to use log4j (log4j.xml) and Maven and Junit??
Try putting the log4j.xml in the working directory and not providing a path (just the filename). Also run with -Dlog4j.debug to see what log4j finds. On 1/23/07, Lisa <[EMAIL PROTECTED]> wrote: I have written some JUnit tests and put them in the standard layout for test cases under Maven. The tests use log.debug(msg), log.info(msg) etc. The tests run OK. So now I created a simple log4j.xml file with an appender and a logger that filters only the logging messages in my test case (by package). When I run maven (mvn test), how do I tell it where my log4j.xml is and how to use log4j logging? I have tried everything. I edited the "mvn" script under the install directory to include the following: exec "$JAVACMD" \ $MAVEN_OPTS \ -classpath "${M2_HOME}"/core/boot/classworlds-*.jar \ "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \ "-Dmaven.home=${M2_HOME}" \ "-Dmaven.junit.sysproperties=log4j.configuration" \ "-Dlog4j.configuration=file:C:\tmp\log4j.xml" \ ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS this does not work (have tried with and without file:. --- I have included a something similiar on the mvn command line: mvn -Dlog4j.configuration=c:\tmp\log4j.xml test this does not work (have included =file:c:\tmp... as well --- I have also tried setting properties in the pom.xml like so: org.apache.maven.plugins maven-surefire-plugin false false maven.junit.sysproperties log4j.configuration log4j.configuration file=:c:\tmp\log4j.xml --- and org.apache.maven.plugins maven-surefire-plugin false false maven.junit.sysproperties log4j.configuration log4j.configuration c:\tmp\log4j.xml --- and (log4j.xml is in same directory as pom.xml) this does not work either. org.apache.maven.plugins maven-surefire-plugin false false maven.junit.sysproperties log4j.configuration log4j.configuration log4j.xml --- none of these work. Any ideas on how to integrate Maven2, Log4J and Junit would be greatly appreciated. - 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]
How to use log4j (log4j.xml) and Maven and Junit??
I have written some JUnit tests and put them in the standard layout for test cases under Maven. The tests use log.debug(msg), log.info(msg) etc. The tests run OK. So now I created a simple log4j.xml file with an appender and a logger that filters only the logging messages in my test case (by package). When I run maven (mvn test), how do I tell it where my log4j.xml is and how to use log4j logging? I have tried everything. I edited the "mvn" script under the install directory to include the following: exec "$JAVACMD" \ $MAVEN_OPTS \ -classpath "${M2_HOME}"/core/boot/classworlds-*.jar \ "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \ "-Dmaven.home=${M2_HOME}" \ "-Dmaven.junit.sysproperties=log4j.configuration" \ "-Dlog4j.configuration=file:C:\tmp\log4j.xml" \ ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS this does not work (have tried with and without file:. --- I have included a something similiar on the mvn command line: mvn -Dlog4j.configuration=c:\tmp\log4j.xml test this does not work (have included =file:c:\tmp... as well --- I have also tried setting properties in the pom.xml like so: org.apache.maven.plugins maven-surefire-plugin false false maven.junit.sysproperties log4j.configuration log4j.configuration file=:c:\tmp\log4j.xml --- and org.apache.maven.plugins maven-surefire-plugin false false maven.junit.sysproperties log4j.configuration log4j.configuration c:\tmp\log4j.xml --- and (log4j.xml is in same directory as pom.xml) this does not work either. org.apache.maven.plugins maven-surefire-plugin false false maven.junit.sysproperties log4j.configuration log4j.configuration log4j.xml --- none of these work. Any ideas on how to integrate Maven2, Log4J and Junit would be greatly appreciated. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Logger (not Appender) Filter
Is there a good reason why the default log4j implementation does not allow for a filter at the Logger level? I know we can add filters to Appenders, but there are certain scenarios where this can be quite wasteful on resources. Perhaps I am attacking this situation all wrong? Scenario: -Using code developed by a different company. -The code from package com.xyz.dostuff generates a log.error, including the stack trace, whenever an exception occurs. -If the Exception descends from a certain type of exception, I do not want the exception to clutter up the log with the stack trace, nor be logged at the error level. -The root logger has 3 appenders (file, console, and email) Possible Solution: -Add a filter to all 3 appenders to filter out the undesired log.error's Cons: -Repeatitive declarations (adding filter to all 3 appenders) -Every single log statement that goes through the root logger must go through the filter -For every single log statment, the filter is executed 3 times, once for each filter Proposed Solution: -Add a filter (not possible using default log4j) to the specific logger com.xyz.dostuff Pros: -Only need to add the filter to one logger vs. three appenders -Only log messages from the specific package com.xyz.dostuff must pass through the filter -The filter is executed only once for each log statement. 1) Am I overlooking this functionality, and is it already built into log4j? 2) Am I looking at this problem completely wrong, and is there a better approach? 3) If 1) and 2) are no, are there any drawbacks to me wrapping the org.apache.log4j.Logger class and adding the functionality for filters? I assume I would need to override the default configuration classes as well? -- View this message in context: http://www.nabble.com/Logger-%28not-Appender%29-Filter-tf3077715.html#a8550568 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: Chainsaw V2
Events are routed to individual tabs based on the 'tab identifier' expression - available from the application-wide preferences menu. Notice the default is: PROP.hostname - PROP.application If this expression is used, Chainsaw examines each received logging event for both 'hostname' and 'application' properties (usually MDC entries). If these properties exist, a tab is created if necessary and the event is added to that tab. Some receivers add properties to the event to facilitate this routing (the socket-based receivers and file-based receivers) - UDPReceiver doesn't. There is another feature you can use: the 'view, create custom expression logpanel' menu will create a new tab based on an expression (think of it as a 'view' of events, ignoring the 'tab identifier' based routing). Using the custom expression logpanel feature, you could create a new tab which contains only your events - use this expression to receive all events except chainsaw/log4j events in a new tab (all of your events); ! ( logger ~= org.apache ) Yes, you need the spaces around operators, keywords and parens. This says: Give me all events where the logger doesn't contain org.apache Hope that helps Scott Deboy COMOTIV SYSTEMS 111 SW Columbia Street Ste. 950 Portland, OR 97201 Telephone: 503.224.7496 Cell: 503.997.1367 Fax:503.222.0185 [EMAIL PROTECTED] www.comotivsystems.com -Original Message- From: Dietmar Winkler, T-AU [mailto:[EMAIL PROTECTED] Sent: Tue 1/23/2007 2:58 AM To: log4j-user@logging.apache.org Subject: Chainsaw V2 Hello everybody, I recently tried Chainsaw V2 as a log-viewer for my C# application (using log4net). In principle it works fine so far (using the UDP-Receiver) Unfortunately all my logging messages from all my loggers are placed in the "chainsaw-log" tab (together with log-messages from Chainsaw itself). I did the tutorial and recognized that there a few new tabs for various loggers are generated. How can I implement a similar behavior? I place it here because I think this is not related to log4net as the logging source (knowing that there is a seperate list for log4net users) Best regards, Mit freundlichen Grüßen Dietmar Winkler Software Engineer _ Tecan Austria GmbH Untersbergstr. 1a, 5082 Grödig, Austria T +43 6246 8933 167, F +43 6246 8933 6167 mailto:[EMAIL PROTECTED], www.tecan.com _ This message is intended for the named addressee(s) only. It may contain privileged and confidential information. Any disclosure, copying or distribution of this message is prohibited and may be unlawful. If you are not the intended recipient, please destroy this message and notify us immediately. Thank you for your cooperation. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Chainsaw V2
Hello everybody, I recently tried Chainsaw V2 as a log-viewer for my C# application (using log4net). In principle it works fine so far (using the UDP-Receiver) Unfortunately all my logging messages from all my loggers are placed in the "chainsaw-log" tab (together with log-messages from Chainsaw itself). I did the tutorial and recognized that there a few new tabs for various loggers are generated. How can I implement a similar behavior? I place it here because I think this is not related to log4net as the logging source (knowing that there is a seperate list for log4net users) Best regards, Mit freundlichen Grüßen Dietmar Winkler Software Engineer _ Tecan Austria GmbH Untersbergstr. 1a, 5082 Grödig, Austria T +43 6246 8933 167, F +43 6246 8933 6167 mailto:[EMAIL PROTECTED], www.tecan.com _ This message is intended for the named addressee(s) only. It may contain privileged and confidential information. Any disclosure, copying or distribution of this message is prohibited and may be unlawful. If you are not the intended recipient, please destroy this message and notify us immediately. Thank you for your cooperation.