# How to print the logs of logstash execution?

**URL:** https://discuss.elastic.co/t/how-to-print-the-logs-of-logstash-execution/32539
**Category:** Logstash
**Created:** [October 19, 2015, 10:40pm UTC](https://discuss.elastic.co/t/how-to-print-the-logs-of-logstash-execution/32539 "2015-10-19T22:40:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Gaurav\_Varma](https://avatars.discourse-cdn.com/v4/letter/g/b19c9b/32.png) [@Gaurav\_Varma](https://discuss.elastic.co/u/Gaurav_Varma)
#### Post date: [October 19, 2015, 10:40pm UTC](https://discuss.elastic.co/t/how-to-print-the-logs-of-logstash-execution/32539/1 "2015-10-19T22:40:14Z")

</div>

Is there a way we can print logstash execution output to a log file? For  
example, I am using a jdbc plugin to read data as per sql\_last\_start. I  
want to know at what time the query was executed, how many records in  
response and what time was the next execution.

Assuming a table test has columns [id,name,updated\_on]  
Code below :

```
input {
    jdbc {      
        jdbc_connection_string => "jdbc:oracle:oci:MyDB"       
        jdbc_user => "testUser"
        jdbc_password => "testPassword"        
        jdbc_driver_library => "C:\app\Administrator\product\11.2.0\client_1\ojdbc6.jar"     
        jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"    
        statement => "SELECT * from test where updated_on >= :sql_last_start"
        schedule => "* * * * *"
        jdbc_fetch_size=>3
    }
}
output {
    stdout { codec => rubydebug }
    file {
             path => "C:\logstashOutput.txt"
             message_format => "%{@timestamp}: %{id} - %{name} at :sql_last_start"
       }
}
```

---

<div class="post-metadata">

### Author: ![ppf2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppf2/32/52219_2.png) [@ppf2](https://discuss.elastic.co/u/ppf2)
#### Post date: [October 20, 2015, 12:09am UTC](https://discuss.elastic.co/t/how-to-print-the-logs-of-logstash-execution/32539/2 "2015-10-20T00:09:22Z")

</div>

If you run Logstash at the debugging level (--debug), the jdbc input plugin will write out each query (SQL statement) that it issues. So you can tell from the Logstash log file to determine the time at which it executes each query. Unfortunately, the plugin [does not currently](https://github.com/logstash-plugins/logstash-input-jdbc/issues/61) provide any information on the # of records retrieved by each statement.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 5:26am UTC](https://discuss.elastic.co/t/how-to-print-the-logs-of-logstash-execution/32539/3 "2017-07-06T05:26:08Z")

</div>


