https://issues.apache.org/bugzilla/show_bug.cgi?id=51588

--- Comment #2 from Rod <r...@vagg.org> 2011-07-30 12:49:30 UTC ---
I want to add a %f and %F as possible options in the custom log pattern to log
IP address and name safely extracted from the X-Forwarded-For header with a
fallback to HttpServletRequest.getRemoteAddr().

Just to back up and clarify my original bug report in case it wasn't clear (now
that I re-read it I think I could have been clearer):

At the bottom of org.apache.catalina.valves.AccessLogValve, the last two
private methods are:

private AccessLogElement createAccessLogElement(char pattern)

and

private AccessLogElement createAccessLogElement(String header, char pattern)

If you want to add another 'field' to the custom log format pattern by
subclassing AccessLogValve then you have to go up to the 3rd last method:

protected AccessLogElement[] createLogElements()

but unfortunately it contains a lot of good logic that would have to be either
completely copied or duplicated in some way. Overriding one or both of the two
private methods lets you simply plug in your addition and not replace any of
the functionality of the original AccessLogValve.

This is the same for both the version 6 and 7 sources.

So my suggestions is simply to replace 'private' with 'protected' in the last 2
methods in AccessLogValve.

Of course I'd love the new options to be added to the Catalina core but I
suspected that they may be slightly peripheral? Perhaps not. I've just finished
writing up the details for anyone else that may have a use for this
functionality at:
http://rod.vagg.org/2011/07/handling-x-forwarded-for-in-java-and-tomcat/

If you think this would be useful to integrate into Catalina then I'd be more
than happy to refactor it all into AccessLogValve (it uses an additional
utility class as it is now) and post a patch here; please let me know what you
think about that option.

I think changing those access modifiers would be useful in either case by the
way.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to