return;
if (_fileOut == null)
return;
Utf8StringBuffer u8buf;
StringBuffer buf;
synchronized(_writer)
{
int size=_buffers.size();
u8buf = size==0?new Utf8StringBuffer(160):(Utf8StringBuffer)_buffers.remove(size-1);
buf = u8buf.getStringBuffer();
}
synchronized(buf) // for efficiency until we can use StringBuilder
{
if (_logServer)
{
buf.append(request.getServerName());
buf.append(' ');
}
String addr = null;
if (_preferProxiedForAddress)
{
addr = request.getHeader(HttpHeaders.X_FORWARDED_FOR);
}
if (addr == null)
addr = request.getRemoteAddr();
buf.append(addr);
buf.append(" - ");
String user = request.getRemoteUser();
buf.append((user == null)? " - " : user);
buf.append(" [");
if (_logDateCache!=null)
buf.append(_logDateCache.format(request.getTimeStamp()));
else
buf.append(request.getTimeStampBuffer().toString());
buf.append("] \"");
buf.append(request.getMethod());
buf.append(' ');
request.getUri().writeTo(u8buf);
buf.append(' ');
buf.append(request.getProtocol());
buf.append("\" ");
int status = response.getStatus();
if (status<=0)
status=404;
buf.append((char)('0'+((status/100)%10)));
buf.append((char)('0'+((status/10)%10)));
buf.append((char)('0'+(status%10)));
long responseLength=response.getContentCount();
if (responseLength >=0)
{
buf.append(' ');
if (responseLength > 99999)
buf.append(Long.toString(responseLength));
else
{
if (responseLength > 9999)
buf.append((char)('0' + ((responseLength / 10000)%10)));
if (responseLength > 999)
buf.append((char)('0' + ((responseLength /1000)%10)));
if (responseLength > 99)
buf.append((char)('0' + ((responseLength / 100)%10)));
if (responseLength > 9)
buf.append((char)('0' + ((responseLength / 10)%10)));
buf.append((char)('0' + (responseLength)%10));
}
buf.append(' ');
}
else
buf.append(" - ");
}
if (!_extended && !_logCookies && !_logLatency)
{
synchronized(_writer)
{
buf.append(StringUtil.__LINE_SEPARATOR);
int l=buf.length();
if (l>_copy.length)
l=_copy.length;
buf.getChars(0,l,_copy,0);
_writer.write(_copy,0,l);
_writer.flush();
u8buf.reset();
_buffers.add(u8buf);
}
}
else
{
synchronized(_writer)
{
int l=buf.length();
if (l>_copy.length)
l=_copy.length;
buf.getChars(0,l,_copy,0);
_writer.write(_copy,0,l);
u8buf.reset();
_buffers.add(u8buf);
// TODO do outside synchronized scope
if (_extended)
logExtended(request, response, _writer);