1 package ch.qos.logback.access.pattern;
2
3 import java.util.Arrays;
4
5 import ch.qos.logback.access.spi.AccessEvent;
6 import ch.qos.logback.core.util.OptionHelper;
7
8 public class RequestParameterConverter extends AccessConverter {
9
10 String key;
11
12 public void start() {
13 key = getFirstOption();
14 if (OptionHelper.isEmpty(key)) {
15 addWarn("Missing key for the request parameter");
16 } else {
17 super.start();
18 }
19 }
20
21 public String convert(AccessEvent accessEvent) {
22 if (!isStarted()) {
23 return "INACTIVE_REQUEST_PARAM_CONV";
24 }
25
26 String[] paramArray = accessEvent.getRequestParameter(key);
27 if (paramArray.length == 1) {
28 return paramArray[0];
29 } else {
30
31
32 return Arrays.toString(paramArray);
33 }
34 }
35
36 }