}
// Open the current log file
- try {
- String pathname;
- // If no rotate - no need for dateStamp in fileName
- if (rotatable) {
- pathname = dir.getAbsolutePath() + File.separator + prefix
- + dateStamp + suffix;
- } else {
- pathname = dir.getAbsolutePath() + File.separator + prefix
- + suffix;
- }
- Charset charset = null;
- if (encoding != null) {
- try {
- charset = B2CConverter.getCharset(encoding);
- } catch (UnsupportedEncodingException ex) {
- log.error(sm.getString(
- "accessLogValve.unsupportedEncoding", encoding), ex);
- }
+ File pathname;
+ // If no rotate - no need for dateStamp in fileName
+ if (rotatable) {
+ pathname = new File(dir.getAbsoluteFile(), prefix + dateStamp
+ + suffix);
+ } else {
+ pathname = new File(dir.getAbsoluteFile(), prefix + suffix);
+ }
+ File parent = pathname.getParentFile();
+ if (!parent.exists()) {
+ if (!parent.mkdirs()) {
+ log.error(sm.getString("accessLogValve.openDirFail", parent));
}
- if (charset == null) {
- charset = Charset.defaultCharset();
+ }
+
+ Charset charset = null;
+ if (encoding != null) {
+ try {
+ charset = B2CConverter.getCharset(encoding);
+ } catch (UnsupportedEncodingException ex) {
+ log.error(sm.getString(
+ "accessLogValve.unsupportedEncoding", encoding), ex);
}
+ }
+ if (charset == null) {
+ charset = Charset.defaultCharset();
+ }
+
+ try {
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(pathname, true), charset), 128000),
false);
- currentLogFile = new File(pathname);
+ currentLogFile = pathname;
} catch (IOException e) {
writer = null;
currentLogFile = null;
+ log.error(sm.getString("accessLogValve.openFail", pathname), e);
}
}
cometConnectionManagerValve.listenerEvent=Exception processing session listener event
# Access log valve
-accessLogValve.closeFail=Failed to close log file
+accessLogValve.openFail=Failed to open access log file [{0}]
+accessLogValve.closeFail=Failed to close access log file
accessLogValve.openDirFail=Failed to create directory [{0}] for access logs
accessLogValve.rotateFail=Failed to rotate access log
accessLogValve.invalidLocale=Failed to set locale to [{0}]
// Open the current log file
writerLock.writeLock().lock();
try {
- String pathname = dir.getAbsolutePath() + File.separator +
- prefix + (rotatable ? date : "") + suffix;
+ File pathname = new File(dir.getAbsoluteFile(), prefix
+ + (rotatable ? date : "") + suffix);
+ File parent = pathname.getParentFile();
+ if (!parent.exists()) {
+ parent.mkdirs();
+ }
String encoding = getEncoding();
FileOutputStream fos = new FileOutputStream(pathname, true);
OutputStream os = bufferSize>0?new BufferedOutputStream(fos,bufferSize):fos;
When generating access logs for errors, log at the Context/Host level if
a Context or Host can be identified for the failed request. (markt)
</fix>
+ <update>
+ In JULI FileHandler and in AccessLogValve create a directory
+ automatically when it is specified as a part of the file name, e.g. in
+ the <code>prefix</code> attribute. Earlier this happened only if it was
+ specified with the <code>directory</code> attribute. (kkolinko)
+ </update>
+ <fix>
+ Log a failure if access log file cannot be opened. (kkolinko)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
<subsection name="Cluster">
<changelog>
<update>
- Remove unnecessary serverl.xml parsing code for old cluster
+ Remove unnecessary server.xml parsing code for old cluster
implementation that does not ship as part of Tomcat 7. (markt)
</update>
</changelog>