Log requests that match a named matcher only?

1. The problem I’m having:

I am trying to figure out how to log requests that match a certain named matcher to a specific log file.

I have a named matcher with a bunch of IP Address matches called @blocked that have a matching

reverse_proxy @blocked http://some-special-ip

Is it possible to write those requests to their own log file?

This is the snippet I have configured

(blocked) {
  @blocked {
   client_ip 47.76.0.0/14 47.80.0.0/13 47.74.0.0/15
  }

  reverse_proxy @blocked http://some-special-ip
}

It’s hard to figure out just from the documentation.

(blocked) {
	
	log blocked_log {
		output file ./blocked.log
		no_hostname
	}

	@blocked {
		client_ip 47.76.0.0/14 47.80.0.0/13 47.74.0.0/15
	}

	handle @blocked {
		reverse_proxy http://some-special-ip
		log_name blocked_log
	}
}

You can also put the following somewhere else than inside (blocked):

	log blocked_log {
		output file ./blocked.log
		no_hostname
	}

Take a look at no_hostname and log_name.

2 Likes

Excellent thank you, did not realize I could use handle like that!