Replacement for RequestDumperValve in Tomcat 7

后端 未结 2 1340
逝去的感伤
逝去的感伤 2020-12-05 18:31

Tomcat 7 does not support the RequestDumperValve that was available Tomcat 6 and earlier.

What is its recommended replacement in Tomcat 7?

相关标签:
2条回答
  • 2020-12-05 18:39

    As an addendum to the original answer, here is a little bit more detail. It isn't fully clear how to get this configured and actually dumping to a file unless you are familiar with the way the logging.properties file is set up in Tomcat 7. Here is how I was able to get the dumper working:

    1. Configure the web.xml as shown in the link to the tomcat 7.0 docs
    2. Modify the logging.properties as follows:

    a. Add the request dumper file handler to the list of handlers

    handlers = ... , 5request-dumper.org.apache.juli.FileHandler, ...
    

    b. Add in the appropriate file handling code for the request-dumper log file

    # request dumper configuration
    5request-dumper.org.apache.juli.FileHandler.level = INFO
    5request-dumper.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
    5request-dumper.org.apache.juli.FileHandler.prefix = request-dumper.
    5request-dumper.org.apache.juli.FileHandler.formatter = org.apache.juli.VerbatimFormatter
    org.apache.catalina.filters.RequestDumperFilter.level = INFO
    org.apache.catalina.filters.RequestDumperFilter.handlers = 5request-dumper.org.apache.juli.FileHandler
    

    I believe the key step is adding in your reference to the "handlers" list. If you just add in the section with the logging configuration it doesn't appear to pick up the changes and create the file.

    -rOcK

    0 讨论(0)
  • 2020-12-05 19:00

    And to answer my own question, more extensive Googling came up with this:

    RequestDumperValve has been replaced by RequestDumperFilter, part of an effort to replace Valves with Filters to be more spec-compliant, and therefore more flexible. This is the class you want: org.apache.catalina.filters.RequestDumperFilter

    Also see: http://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#Request_Dumper_Filter

    Note that you will configure this component in web.xml, now, and not in context.xml.

    0 讨论(0)
提交回复
热议问题