# irule to log googlebots

**URL:** <https://community.f5.com/t/irule-to-log-googlebots/4515>\
**Category:** Technical Forums\
**Tags:** irules, security, devops, application-delivery\
**Created:** [November 26, 2013, 7:58am UTC](https://community.f5.com/t/irule-to-log-googlebots/4515 "2013-11-26T07:58:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_S\_135288](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@Daniel\_S\_135288](https://community.f5.com/u/Daniel_S_135288)\
**Post date:** [November 26, 2013, 7:58am UTC](https://community.f5.com/t/irule-to-log-googlebots/4515/1 "2013-11-26T07:58:15Z")

</div>

Hello

My goal is to log the googlebot’s. I want to log the time and which page was crawled…

Can anybody help me?

Regards

Danisch

---

<div class="post-metadata">

**Author:** ![Daniel\_S\_135288](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@Daniel\_S\_135288](https://community.f5.com/u/Daniel_S_135288)\
**Post date:** [November 26, 2013, 8:22am UTC](https://community.f5.com/t/irule-to-log-googlebots/4515/2 "2013-11-26T08:22:01Z")

</div>

What I need exactly is: Timestamp URL requested User agent (limit to googlebot) Response code

---

<div class="post-metadata">

**Author:** ![PeteWhite](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/petewhite/32/33768_2.png) [@PeteWhite](https://community.f5.com/u/PeteWhite)\
**Post date:** [November 26, 2013, 8:53am UTC](https://community.f5.com/t/irule-to-log-googlebots/4515/3 "2013-11-26T08:53:27Z")

</div>

How about this:

```tcl
when HTTP_REQUEST {
if { [HTTP::header "User-Agent"] contains "Googlebot" } {
    log local0 "Googlebot: URI:[HTTP::uri] User-Agent [HTTP::header "User-Agent"]"
}

```

}

---

<div class="post-metadata">

**Author:** ![IheartF5\_45022](https://avatars.discourse-cdn.com/v4/letter/i/3be4f8/32.png) [@IheartF5\_45022](https://community.f5.com/u/IheartF5_45022)\
**Post date:** [November 26, 2013, 9:05am UTC](https://community.f5.com/t/irule-to-log-googlebots/4515/4 "2013-11-26T09:05:22Z")

</div>

something like (not tested);

```tcl
when HTTP_REQUEST {
    set fBot 0
    if {[HTTP::header value "User-Agent"] contains "Googlebot"} {
        set fBot 1
        set ua [HTTP::header value "User-Agent"]
        set uri [HTTP::uri]
    }
}
when HTTP_RESPONSE {
    if {$fBot} {
        log local0. "[clock clicks -milliseconds],$uri,$ua,[HTTP::status]"
    }
}

```

---

<div class="post-metadata">

**Author:** ![Daniel\_S\_135288](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@Daniel\_S\_135288](https://community.f5.com/u/Daniel_S_135288)\
**Post date:** [November 26, 2013, 9:40am UTC](https://community.f5.com/t/irule-to-log-googlebots/4515/5 "2013-11-26T09:40:48Z")

</div>

thanks guys, works perfect
