org.apache.loggin.log4j.core.pattern.DatePatternConverter blocking
I am using log4j2 and I am seeing almost all the threads momentarily getting blocked on org.apache.loggin.log4j.core.pattern.DatePatternConverter class. Is this expected?
Re: org.apache.loggin.log4j.core.pattern.DatePatternConverter blocking
Issue created https://issues.apache.org/jira/browse/LOG4J2-812 On Wed, Sep 3, 2014 at 4:28 PM, Ralph Goers ralph.go...@dslextreme.com wrote: The converter uses a SimpleDateFormat which is not thread safe and so is synchronized. I am sure there might be minor optimizations that could be done to this What I would do is modify DatePatternConverter to a) use Java 8’s java.time.format.DateTimeFormatter if running on Java 8 b) use Joda Time’s DateTimeFormat if it is present. c) create a pool of SimpleDateFormat objects and use those. Please create a Jira issue for this. Ralph On Sep 3, 2014, at 3:00 PM, Mohit Anchlia mohitanch...@gmail.com wrote: I am using log4j2 and I am seeing almost all the threads momentarily getting blocked on org.apache.loggin.log4j.core.pattern.DatePatternConverter class. Is this expected? - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Logging using log4j.xml 2
I have below xml but my application is not printing the logs to console. I am running through eclipse and this file is in main/resources. ?xml version=*1.0* encoding=*UTF-8*? Configuration status=*INFO* monitorInterval=*30* Appenders Console name=*Console* target=*SYSTEM_OUT* PatternLayout pattern=*%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n*/ /Console /Appenders Loggers Root level=*INFO* AppenderRef ref=*Console*/ /Root /Loggers /Configuration
Re: Logging using log4j.xml 2
I realized it later and changed it to log4j2.xml and now it works On Thu, Aug 7, 2014 at 3:35 PM, Remko Popma remko.po...@gmail.com wrote: The config file should be named log4j2.xml, not log4j.xml. Did you try that? Remko Sent from my iPhone On 2014/08/08, at 7:16, Mohit Anchlia mohitanch...@gmail.com wrote: I have below xml but my application is not printing the logs to console. I am running through eclipse and this file is in main/resources. ?xml version=*1.0* encoding=*UTF-8*? Configuration status=*INFO* monitorInterval=*30* Appenders Console name=*Console* target=*SYSTEM_OUT* PatternLayout pattern=*%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n*/ /Console /Appenders Loggers Root level=*INFO* AppenderRef ref=*Console*/ /Root /Loggers /Configuration - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Non blocking JMS appender
I am trying to configure log4j such that the jms appender is non blocking. Does this configuration make it non blocking? appender name=async class=org.apache.log4j.AsyncAppender param name=BufferSize value=4096 / param name=blocking value=false/ /appender appender name=search-indexer-async-jms class=org.apache.log4j.net.JMSAppender param name=InitialContextFactoryName value=org.apache.activemq.jndi.ActiveMQInitialContextFactory / param name=ProviderURL value=tcp://localhost:61616/ param name=TopicBindingName value=indexTopicEndpoint/ param name=TopicConnectionFactoryBindingName value=ConnectionFactory/ appender-ref ref=async / /appender
Re: Unit testing log4j JMS Appender
(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) log4j:ERROR Could not create an Appender. Reported error follows. java.lang.NullPointerException at java.util.Hashtable.put(Unknown Source) at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:141) at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153) at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:201) at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:140) at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153) at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:415) at org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:335) at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:781) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:666) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:602) at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:460) at org.apache.log4j.LogManager.clinit(LogManager.java:113) at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272) at org.mule.util.SystemUtils.clinit(SystemUtils.java:35) at org.mule.tck.junit4.AbstractMuleTestCase.clinit(AbstractMuleTestCase.java:71) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) On Tue, Apr 1, 2014 at 12:41 PM, Gary Gregory garydgreg...@gmail.comwrote: On Tue, Apr 1, 2014 at 3:13 PM, Mohit Anchlia mohitanch...@gmail.com wrote: Is there a stable version available? Yes: https://logging.apache.org/log4j/2.x/ How do I reload configuration? Please see: - https://logging.apache.org/log4j/2.x/manual/configuration.html#AutomaticReconfiguration - https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/config/Reconfigurable.html#reconfigure() I am using log4j.properties and not xml Log4j 2 does not support properties files for configuration. It might one day, but not now. Gary On Tue, Apr 1, 2014 at 12:09 PM, Gary Gregory garydgreg...@gmail.com wrote: You would be better served using version 2 which we are actively working on. Gary Original message From: Mohit Anchlia mohitanch...@gmail.com Date:04/01/2014 15:01 (GMT-05:00) To: Log4J Users List log4j-user@logging.apache.org Subject: Unit testing log4j JMS Appender I am trying to unit test log4j with jms appender, however even before I bring up the jms embedded broker service log4j.properties get loaded and it fails to connect to the broker. Is there a way to reload log4j after the broker is up? -- E-Mail: garydgreg...@gmail.com | ggreg...@apache.org Java Persistence with Hibernate, Second Edition http://www.manning.com/bauer3/ JUnit in Action, Second Edition http://www.manning.com/tahchiev/ Spring Batch in Action http://www.manning.com/templier/ Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
Re: Unit testing log4j JMS Appender
It appears that the dependency jar is trying to use log4j 1. Do you have any suggestion on how I can resolve this issue? This is my new config and error follows that: ?xml version=1.0 encoding=UTF-8? Configuration status=warn name=MyApp packages= Appenders RollingFile name=search-indexer-async-log fileName=${mule.home}/logs/mule-search-indexer-async.log filePattern=logs/app-%d{MM-dd-}.log.gz PatternLayout Pattern[%d{MM/dd/ HH:mm:ss,SSS}] %-5p %c{3} [%t](%x): %m%n/pattern /PatternLayout TimeBasedTriggeringPolicy / SizeBasedTriggeringPolicy size=500 MB/ /RollingFile Async name=async blocking=false AppenderRef ref=search-indexer-async-log/ /Async JMSTopic name=search-indexer-async-jms-topic topicBindingName=indexTopicEndpoint factoryBindingName=ConnectionFactory providerURL=tcp://localhost:61616/ Async name=async-jms blocking=false AppenderRef ref=search-indexer-async-jms-topic/ /Async /Appenders Loggers Logger name=com.intuit.cfp.search.async additivity=false level=TRACE AppenderRef ref=async-jms/ /Logger Root level=error AppenderRef ref=async/ /Root /Loggers /Configuration SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/C:/Users/manchlia/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/C:/Users/manchlia/.m2/repository/org/apache/activemq/activemq-all/5.9.0/activemq-all-5.9.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. log4j:WARN Continuable parsing error 2 and column 68 log4j:WARN Document root element Configuration, must match DOCTYPE root null. log4j:WARN Continuable parsing error 2 and column 68 log4j:WARN Document is invalid: no grammar found. log4j:ERROR DOM element is - not a log4j:configuration element. log4j:WARN No appenders could be found for logger (org.apache.activemq.broker.BrokerService). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. On Wed, Apr 2, 2014 at 10:12 AM, Gary Gregory garydgreg...@gmail.comwrote: The stack trace below shows the code trying to process an XML configuration with Log4j 1. You cannot have log4j version 1 on the classpath if you want to use version 2. The XML format between version 1 and 2 is different. Log4j 2 has a version 1 compatibility module you can use. Gary On Wed, Apr 2, 2014 at 1:07 PM, Mohit Anchlia mohitanch...@gmail.com wrote: I am trying to convert my log4.properties from 1.x to log4j.xml 2.0-rc1 but I am running into this issue log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/; appender class=org.apache.log4j.appender.TimeAndSizeRollingAppender name=search-indexer-async param value=false name=BufferedIO / param value='.'-MM-dd name=DatePattern / param value=true name=DateRollEnforced / param value=${mule.home}/logs/mule-app-client-api.log name=file / param value=500MB name=MaxFileSize / param value=10 name=MaxRollFileCount / layout class=org.apache.log4j.PatternLayout param value=[%d{MM/dd/ HH:mm:ss,SSS}] %-5p %c{3} [%t](%x): %m%n name=ConversionPattern / /layout !-- Log entries that make it past this filter will be logged -- /appender appender name=async class=org.apache.log4j.AsyncAppender param name=BufferSize value=4096 / param name=blocking value=false / appender-ref ref=search-indexer-async / /appender appender name=search-indexer-async-jms class=org.apache.log4j.net.JMSAppender param name=InitialContextFactoryName value=org.apache.activemq.jndi.ActiveMQInitialContextFactory / param name=ProviderURL value=tcp://localhost:61616 / param name=TopicBindingName value=indexTopicEndpoint / param name=TopicConnectionFactoryBindingName value=ConnectionFactory / appender-ref ref=async / /appender log4j:WARN No such property [blocking] in org.apache.log4j.AsyncAppender. log4j:ERROR Could not create an Appender. Reported error follows. java.lang.ClassNotFoundException: org.apache.log4j.appender.TimeAndSizeRollingAppender at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.apache.log4j.helpers.Loader.loadClass(Loader.java:160) at org.apache.log4j.xml.DOMConfigurator.parseAppender
Re: Unit testing log4j JMS Appender
I don't think there is any problem with that jar, the issue is that I am trying to use log4j 2 but the dependency jar that I am using is using log4j 1. When I switch back to log4j 1 everything works fine. Is there a way to avoid this compatibility issue? Not sure how others that have similar issue are able to migrate today to log4j 2 On Wed, Apr 2, 2014 at 4:48 PM, Remko Popma remko.po...@gmail.com wrote: The problem is in activemq-all-5.9.0.jar. I suggest you contact the activemq team. Sent from my iPhone On 2014/04/03, at 2:53, Gary Gregory garydgreg...@gmail.com wrote: activemq-all-5.9.0.jar - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Unit testing log4j JMS Appender
I am trying to unit test log4j with jms appender, however even before I bring up the jms embedded broker service log4j.properties get loaded and it fails to connect to the broker. Is there a way to reload log4j after the broker is up?
Re: Unit testing log4j JMS Appender
Is there a stable version available? How do I reload configuration? I am using log4j.properties and not xml On Tue, Apr 1, 2014 at 12:09 PM, Gary Gregory garydgreg...@gmail.comwrote: You would be better served using version 2 which we are actively working on. Gary Original message From: Mohit Anchlia mohitanch...@gmail.com Date:04/01/2014 15:01 (GMT-05:00) To: Log4J Users List log4j-user@logging.apache.org Subject: Unit testing log4j JMS Appender I am trying to unit test log4j with jms appender, however even before I bring up the jms embedded broker service log4j.properties get loaded and it fails to connect to the broker. Is there a way to reload log4j after the broker is up?
timestamp in rolled over files
Is there a way to get the timestamp instead of .1 .2 etc. when a log file is rolled over by log4j? - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: timestamp in rolled over files
Do you have an example of that? I couldn't find it. On Tue, Mar 3, 2009 at 1:09 PM, Simon Park simon_park_m...@yahoo.co.uk wrote: You could maybe use the org.apache.log4j.DailyRollingFileAppender to roll by time only. You use a pattern compatible with java.text.SimpleDateFormat to configure the appender's DatePattern property with the period you want files to roll, e.g. by any one of minute, hour, half-day, day, week, etc. From: Mohit Anchlia mohitanch...@gmail.com To: log4j-user@logging.apache.org Sent: Tuesday, 3 March, 2009 20:19:10 Subject: timestamp in rolled over files Is there a way to get the timestamp instead of .1 .2 etc. when a log file is rolled over by log4j? - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Log Debug and Info in 2 different files
I am trying to log DEBUG and up in one log file and INFO and up in other log file. But it doesn't seem to be working. I have tried various things like Level, Threshold, additivity, Priority etc. Nothing seems to be working. Nothing is being written to sw.log. Only INFO and up is being written to sw_infoerr.log. I just want DEBUG and up in sw.log and INFO and up in sw_infoerr.log Below is the config: ?xml version=1.0 encoding=UTF-8? !DOCTYPE log4j:configuration SYSTEM log4j.dtd log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/; debug=false appender name=SWITCH_LOG class=org.apache.log4j.RollingFileAppender param name=File value=/usr/local/tomcat/logs/sw.log/ param name=Append value=true/ !-- Keep 50 logs, 50MB each -- param name=MaxBackupIndex value=50/ param name=MaxFileSize value=52428800/ param name=DatePattern value='.'-MM-dd/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{ISO8601} %-5p [%c{3}:%t] - %m%n/ /layout /appender appender name=SWITCH_LOG_1 class=org.apache.log4j.RollingFileAppender param name=File value=/usr/local/tomcat/logs/sw_infoerr.log/ param name=Append value=true/ !-- Keep 50 logs, 50MB each -- param name=MaxBackupIndex value=50/ param name=MaxFileSize value=52428800/ param name=DatePattern value='.'-MM-dd/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{ISO8601} %-5p [%c{3}:%t] - %m%n/ /layout /appender logger name=com.in.en.ef.sw additivity=false appender-ref ref=SWITCH_LOG/ /logger logger name=com.in.en.ef.sw additivity=false level value=INFO/ appender-ref ref=SWITCH_LOG_1/ /logger /log4j:configuration - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org