@Nullable
        @Override
        public Object getMessage0(RequestLog log) {
            switch (type) {
                case LOCAL_IP_ADDRESS:
                    final InetSocketAddress local = log.context().localAddress();
                    return local == null || local.isUnresolved() ? null : local.getAddress().getHostAddress();

                case REMOTE_IP_ADDRESS:
                    if ("c".equals(variable)) {
                        // %{c}a means the remote address of the underlying channel.
                        final InetSocketAddress remote = log.context().remoteAddress();
                        return remote == null || remote.isUnresolved() ? null
                                                                       : remote.getAddress().getHostAddress();
                    } else {
                        // %a means the client address who initiated a request.
                        final ServiceRequestContext ctx = (ServiceRequestContext) log.context();
                        return ctx.clientAddress().getHostAddress();
                    }
                case REMOTE_HOST:
                    final InetSocketAddress ra = log.context().remoteAddress();
                    return ra != null ? ra.getHostString() : null;

                case RFC931:
                    // We do not support this log type now.
                    return null;
                case AUTHENTICATED_USER:
                    return log.authenticatedUser();
                case REQUEST_LINE:
                    final String httpMethodName = log.requestHeaders().method().name();
                    final String path = log.requestHeaders().path();
                    final String name = log.name();
                    final RpcRequest rpcRequest = log.context().rpcRequest();
                    final boolean isGrpc = rpcRequest != null &&
                                           GRPC_SERVICE_NAME.equals(rpcRequest.serviceType().getName());

                    final String logName;
                    if (!isGrpc) {
                        String serviceName = log.serviceName();
                        if (serviceName != null) {
                            final int idx = serviceName.lastIndexOf('.') + 1;
                            if (idx > 0) {
                                serviceName = serviceName.substring(idx);
                            }
                        }

                        if (rpcRequest == null && httpMethodName.equals(name)) {
                            logName = serviceName;
                        } else {
                            logName = serviceName + '/' + name;
                        }
                    } else {
                        logName = null;
                    }

                    final String protocol = firstNonNull(log.sessionProtocol(),
                                                         log.context().sessionProtocol()).uriText();

                    try (TemporaryThreadLocals tempThreadLocals = TemporaryThreadLocals.acquire()) {
                        final StringBuilder requestLine = tempThreadLocals.stringBuilder();
                        requestLine.append(httpMethodName).append(' ').append(path);

                        if (logName != null) {
                            requestLine.append('#')
                                       .append(UrlEscapers.urlFragmentEscaper().escape(logName));
                        }
                        return requestLine.append(' ').append(protocol).toString();
                    }
                case RESPONSE_STATUS_CODE:
                    return log.responseHeaders().status().code();
                case RESPONSE_LENGTH:
                    return log.responseLength();
                case REQUEST_ID:
                    final RequestId id = log.context().id();
                    if ("short".equals(variable)) {
                        return id.shortText();
                    } else {
                        return id.text();
                    }
            }
            return null;
        }
Common log components of a log message.
core/src/main/java/com/linecorp/armeria/server/logging/AccessLogComponent.java