Sorry for not replying earlier. Not having looked into the ATDF code for about a million years, I can't really comment on the technical issues you raised with any semblance of accuracy. So I'll pass for the time being but will get back to you later. More below.
AbsoluteTimeDateFormat, DateTimeDateFormat, and ISO8601DateFormat all ignore timezone in their cache logic and have problems with pre-1970 dates in case you ever set your clock back that far. The approach that I have taken is to create a CachedDateFormat that wraps an arbitrary DateFormat and have removed the flawed cache logic. It does not attempt to share the same cached value among multiple layouts, but it would be difficult to do safely and I'm guessing that extra optimization would not offer a noticiable performance gain.
One of the benefits of this approach is that SimpleDateFormat's also benefit from caching. However, when running "ant -f performance.xml null" with Sun JDK 1.4.2 on Linux and the existing log4j, the SimpleDateFormat test appears competitive with ISO8601DateFormat. The log4j documentation suggested that SimpleDateFormat was substantially more expensive. So perhaps, the later JDK implementations have implemented similar logic internally or improved their performance or I am misreading the test. I'll try to run the performance test with an earlier JVM's or other platforms to see if the relative performance changes.
It would make log4cxx a lot simpler if all I have to worry about is the current default machine timezone and UTC and don't have to try to parse /usr/share/zoneinfo or other platform specific approaches. to support arbitrary timezones.
Makes sense to me. In any case, if a certain log4j feature is too hard to reproduce in another language, then punting on that specific feature sounds reasonable to me.
Doing arbitrary timezones correctly would add a lot of non-trivial, non-portable code to log4cxx. For the immediate future, log4cxx will only support default local time and UTC. Doing that will be better than log4j has been doing up till this point.
Since java makes it rather easy do deal with multiple timezones, I'd go for something like
%d{ABSOLUTE, UTC}, "%d{ISO8601, UTC} or %d{ABSOLUTE, X} where X is any timezone string recognized by Java.
Digging a little deeper, it looks like I can set the timezone on the layout in the configuration. I haven't confirmed this with a test case yet.
recommends the use of ',' regardless of locale. Anyway, the separator string could be a third parameter, as in %d{ISO8601, UTC, '.'}.
True. Since it looks like the performance difference between ISO8601DateFormat and SimpleDateFormat won't be as significant (either due to JVM improvements or caching), if you want to use an ISO format with a period, you could just specify a "yyyy-MM-dd HH:mm:ss.SSS" pattern to SimpleDateFormat.
I've written up some log4j test cases to support my efforts. I had thought that just adding the files into the tests/src/java hierarchy might do the trick, but apparently not.
??? Why not? What went wrong?
I was hoping that just dropping the files into tests/src/java/... would cause them to be run. I've now added them to my tests/build.xml and are able to run them fine.
Also, the org.apache.log4j.rolling.SizeBasedRollingTest was failing when I tried to run the self-tests.
Yeah, the SizeBasedRollingTest is known to be fragile. If you can, please send me the failure report, so I can fix the SizeBasedRollingTest.
SizeBasedRollingTest.test2 fails on Linux because it is unable to find a file named output/sizeBased-2.1. The file output/sizeBased-2 exists and contains all 24 log messages. The log appears at the end of the message. Test passed on Win32, but the still lacks a sizeBased-2.1 output file and the contents of output/sizeBased-2 seems the same.
I'd be willing to work up a patch that addresses these issues with the test cases that I've written in order to support the log4cxx effort.
You've written test cases for log4j or log4cxx? In any case, thanks for the offer. If it does not takes too much of your time, please do submit your patch.
I've written tests of log4j for the benefit of the log4cxx project. Once I characterize the expected behavior of log4j, I'll transliterate the tests and add them to log4cxx.
Result of "ant SizeBasedRolling"
-------------
parentBuild:
init:
jndiCheck:
build.core:
build.examples:
jaxpCheck:
jaxp:
[echo] JAXP present.build.xml:
javamailCheck:
javamail:
build.javamail:
jmsCheck:
jms:
jndi:
[echo] JNDI is present.build.jms:
jmxCheck:
jmx:
build.jmx:
avalonFrameworkCheck:
avalonFramework:
build.avalonFramework:
servletAPICheck:
servletAPI:
[echo] Servlet API is present.build.servletAPI:
jdbcExtensionCheck:
jdbcExtension:
[echo] JDBC Standard Extension is present.build.db:
oroCheck:
chainsawCheck:
build.chainsaw:
build:
prepare:
build:
cleanOutputDir:
[delete] Deleting 2 files from /home/curta/log4j-new/logging-log4j/tests/output
SizeBasedRolling:
[junit] Running org.apache.log4j.rolling.SizeBasedRollingTest
[junit] Tests run: 3, Failures: 0, Errors: 1, Time elapsed: 50.168 sec
[junit] Testsuite: org.apache.log4j.rolling.SizeBasedRollingTest
[junit] Tests run: 3, Failures: 0, Errors: 1, Time elapsed: 50.168 sec
[junit] ------------- Standard Output ---------------
[junit] The active file name option must be set before using this rolling policy.
[junit] Active log file name: output/sizeBased-test2
[junit] Hello 0
[junit] Hello 1
[junit] Hello 2
[junit] Hello 3
[junit] Hello 4
[junit] Hello 5
[junit] Hello 6
[junit] Hello 7
[junit] Hello 8
[junit] Hello 9
[junit] Hello 10
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] Hello 11
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] Hello 12
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] Hello 13
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] Hello 14
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] Hello 15
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] Hello 16
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] Hello 17
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] Hello 18
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] Hello 19
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] Hello 20
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] Hello 21
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] Hello 22
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] Hello 23
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] Hello 24
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test2].
[junit] ================GZ
[junit] ==================================
[junit] Active log file name: output/sizeBased-test3
[junit] Hello 0
[junit] Hello 1
[junit] Hello 2
[junit] Hello 3
[junit] Hello 4
[junit] Hello 5
[junit] Hello 6
[junit] Hello 7
[junit] Hello 8
[junit] Hello 9
[junit] Hello 10
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] Hello 11
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] Hello 12
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] Hello 13
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] Hello 14
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] Hello 15
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] Hello 16
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] Hello 17
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] Hello 18
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] Hello 19
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] Hello 20
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] Hello 21
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] Hello 22
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] Hello 23
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] Hello 24
[junit] About to rollover
[junit] Active file name is now [output/sizeBased-test3].
[junit] ------------- ---------------- ---------------
[junit] ------------- Standard Error -----------------
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] log4j:WARN RolloverFailure occurred. Deferring rollover.
[junit] ------------- ---------------- ---------------
[junit] Testcase: test1 took 0.018 sec
[junit] Testcase: test2 took 25.075 sec
[junit] Caused an ERROR
[junit] output/sizeBased-test2.1 (No such file or directory)
[junit] java.io.FileNotFoundException: output/sizeBased-test2.1 (No such file or directory)
[junit] at java.io.FileInputStream.open(Native Method)
[junit] at java.io.FileInputStream.<init>(FileInputStream.java:106)
[junit] at java.io.FileInputStream.<init>(FileInputStream.java:66)
[junit] at java.io.FileReader.<init>(FileReader.java:41)
[junit] at org.apache.log4j.util.Compare.compare(Compare.java:34)
[junit] at org.apache.log4j.rolling.SizeBasedRollingTest.test2(SizeBasedRollingTest .java:112)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:25)
[junit] Testcase: test3 took 25.067 sec
BUILD FAILED
/home/curta/log4j-new/logging-log4j/tests/build.xml:437: Test org.apache.log4j.rolling.SizeBasedRollingTest failed
Total time: 52 seconds
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
