如何在Apache access_log中忽略/移除ClusterListener/1.0日志记录
I’ve dealt with this exact mod_cluster log clutter before—those ClusterListener/1.0 entries are internal component communication (like node health checks and status syncs) that don’t need to cluttering up your access log. Adjusting LogLevel won’t fix this because that setting controls error log verbosity, not what gets logged to the access log. Here’s the straightforward fix:
Step 1: Tag the Unwanted Requests
All those noisy entries have a User-Agent header set to ClusterListener/1.0. Use Apache’s SetEnvIf directive to tag these requests so we can exclude them from logging. Add this line to either your main httpd.conf or directly in your mod_jk.conf:
# Mark ClusterListener requests to skip logging SetEnvIf User-Agent "ClusterListener/1.0" dontlog
Step 2: Update Your Logging Rule
Modify your existing CustomLog directive to exclude any requests tagged with dontlog. If you’re using the standard combined log format, it should look like this:
# Only log requests that aren't marked as "dontlog" CustomLog "logs/access_log" combined env=!dontlog
If you want to apply this only to your mod_cluster VirtualHost (port 5555) without affecting other sites, add the filter directly inside that <VirtualHost> block:
<VirtualHost *:5555> # Your existing mod_cluster configuration... LogLevel warn <Directory /> Require all granted </Directory> <Location /> Order deny,allow Allow from all </Location> ManagerBalancerName mybalancer ServerAdvertise on EnableMCPMReceive On <Location /mod_cluster-manager> SetHandler mod_cluster-manager Order deny,allow Allow from all </Location> # Add these lines to filter ClusterListener logs SetEnvIf User-Agent "ClusterListener/1.0" dontlog CustomLog "logs/mod_cluster_access_log" combined env=!dontlog </VirtualHost>
Step 3: Verify the Fix
Restart Apache to apply the changes, then check your access log. Those ClusterListener/1.0 entries should disappear right away.
Quick Note on Why LogLevel Didn’t Work
To clear up confusion: LogLevel adjusts how much detail is written to Apache’s error log (e.g., hiding debug messages or showing more warnings). It has no control over which requests get recorded in the access log—those are managed by CustomLog directives and environment variables like the one we used here.
内容的提问来源于stack exchange,提问作者Thiago Chagas - Batata

