# Cipher Logging iRule

**URL:** <https://community.f5.com/t/cipher-logging-irule/29291>\
**Category:** Technical Forums\
**Tags:** irules, ltm, application-delivery\
**Created:** [October 18, 2017, 3:30pm UTC](https://community.f5.com/t/cipher-logging-irule/29291 "2017-10-18T15:30:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alan\_Johnson\_30](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@Alan\_Johnson\_30](https://community.f5.com/u/Alan_Johnson_30)\
**Post date:** [October 18, 2017, 3:30pm UTC](https://community.f5.com/t/cipher-logging-irule/29291/1 "2017-10-18T15:30:10Z")

</div>

Hi folks,

I’m currently using an iRule to log cipher usage. It works great. However, I need to modify to include the Virtual Server name in the log entry. Here’s what I’ve been using:

when HTTP\_REQUEST {

```tcl
if { [info exists logged] && $logged == 1 }{
     Do nothing. Already logged for this connection
} else {
    set host [HTTP::host]
    set useragent [HTTP::header "User-Agent"]
    set logged 1

    log local0. "[IP::client_addr] - [SSL::cipher name] - [SSL::cipher version] - [SSL::cipher bits] - [HTTP::header "User-Agent"]"

}

```

}

…and here’s what I was going to try to get the virtual server name added:

```tcl
log local0. "[virtual name] - [IP::client_addr] - [SSL::cipher name] - [SSL::cipher version] - [SSL::cipher bits] - [HTTP::header "User-Agent"]"

```

Does anyone have any thoughts on whether or not that will work? If not any suggestions?

---

<div class="post-metadata">

**Author:** ![jurgenvdmark\_14](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@jurgenvdmark\_14](https://community.f5.com/u/jurgenvdmark_14)\
**Post date:** [October 20, 2017, 4:18pm UTC](https://community.f5.com/t/cipher-logging-irule/29291/2 "2017-10-20T16:18:25Z")

</div>

It looks fine to me,

I have a similar rule which logs when the SSL handshake takes place:

```tcl
when CLIENTSSL_HANDSHAKE {
    log local0.info "virtual=[virtual name], src_ip=[IP::client_addr], ssl_cipher=[SSL::cipher name], ssl_protocol=[SSL::cipher version], ssl_bits=[SSL::cipher bits]"
}

```

Starting in version 11. A virtual consists of the partition and the virtual-name, f.i.

```tcl
/Common/test

```

using the following command you can get the virtual name without the partition:

```tcl
set env_vserver [getfield [virtual] "/" 3]

```
