https://issues.apache.org/bugzilla/show_bug.cgi?id=56646
Bug ID: 56646
Summary: Appender causes StackOverflowError if final existing
path element is not writable
Product: Log4j
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: critical
Priority: P2
Component: Appender
Assignee: [email protected]
Reporter: [email protected]
In log4j 1.2.16, if the final existing path element in the properties key
log4J.appender.<FILE>.File is not writable, a StackOverflowError will occur.
Begin projectLog4j.properties file
Note: trace was only set while trying to track down the problem
-----------------------------------
# Default log level
log4j.rootCategory=trace, FILE
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%m%n
################################################
# You can set custom log levels per-package here
################################################
# Apache Commons tend to make a lot of noise which can clutter the log.
log4j.logger.org.apache=WARN
# Your custom classes
log4j.logger.com.my.company.package1=trace,FILE
log4j.logger.com.my.company.package2=trace,FILE
log4j.additivity.com.my.company.package2=false
log4j.logger.com.my.co.package1=trace,FILE
log4j.additivity.my.co.package1=false
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.File=<LOG_FILE_PATH>
log4j.appender.FILE.MaxFileSize=50MB
log4j.appender.FILE.MaxBackupIndex=3
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%-5p %d [%t] %c: %m%n
---------------------------------------------
End projectLog4j.properties file:
Examples:
1.
Setup:
<LOG_FILE_PATH> = /tmp/can/make/log/here.log
/tmp exists and has normal permissions of 7777. None of the other directories
or the log file (here.log) exist.
Result:
log file will be created and written to with no problems.
2.
Setup:
<LOG_FILE_PATH> = /tmp/root/SOE.log
/tmp exists and has normal permissions of 7777. /tmp/root exists, is owned by
root:root, and has permissions of 755. SOE.log does not exist.
Result:
java.lang.StackOverflowError
at java.io.PrintStream.write(PrintStream.java:523)
at java.io.PrintStream.print(PrintStream.java:669)
at java.io.PrintStream.println(PrintStream.java:806)
at org.apache.log4j.helpers.LogLog.error(LogLog.java:129)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:232)
at
org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:838)
at
org.apache.log4j.contribs.LoggingOutputStream.flush(LoggingOutputStream.java:199)
at java.io.PrintStream.write(PrintStream.java:482)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:207)
at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:129)
at java.io.BufferedWriter.write(BufferedWriter.java:230)
at java.io.Writer.write(Writer.java:157)
3.
Setup:
<LOG_FILE_PATH> = /tmp/root/SOE.log
/tmp exists and has normal permissions of 7777. /tmp/root exists, is owned by
root:root, and has permissions of 755. SOE.log exists and has permissions of
666
Result:
Log is written to with no problems.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]