# Filebeat can't get log written at php by “fwrite”

**URL:** <https://discuss.elastic.co/t/filebeat-cant-get-log-written-at-php-by-fwrite/123733>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [March 13, 2018, 1:15pm UTC](https://discuss.elastic.co/t/filebeat-cant-get-log-written-at-php-by-fwrite/123733 "2018-03-13T13:15:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincnetwang0736](https://avatars.discourse-cdn.com/v4/letter/v/b782af/32.png) [@vincnetwang0736](https://discuss.elastic.co/u/vincnetwang0736)\
**Post date:** [March 13, 2018, 1:15pm UTC](https://discuss.elastic.co/t/filebeat-cant-get-log-written-at-php-by-fwrite/123733/1 "2018-03-13T13:15:09Z")

</div>

My filebeat can't get the log file that written on php by "fwrite"  
Here is my php coding:

Here is my php coding:

> ```
> $date = date("Y-M-d");
> $log_path = JSON_LOG_PATH."_".$date."_".$eventid.".log";
> 
> if (!is_file($log_path)) {
> # code...
> if( ($jsonLog=fopen ($log_path,"w")) === FALSE){
> return false;
> }
> $json_string = json_encode($log_json);
> if(!fwrite ($jsonLog,"[".$json_string."]")){ 
> fclose($jsonLog);
> 
> return false;
> }
> fclose ($jsonLog); 
> } else {
> $json_string_all = file_get_contents($log_path);
> 
> if( ($jsonLog=fopen ($log_path,"w")) === FALSE){
> return false;
> }
> $data_all = json_decode($json_string_all,true);
> array_push($data_all, $log_json);
> $json_string = json_encode($data_all);
> if(!fwrite ($jsonLog,$json_string)){ 
> fclose($jsonLog);
> return false;
> }
> fclose ($jsonLog); 
> 
> ```

And here is my filebeat config:

> filebeat.prospectors:
> 
> - type: log
> 
> - type: log  
> paths:

> output.logstash:
> 
> # The Logstash hosts
> 
> hosts: ["xx.xx.xx.xxx:5044"]  
> ssl.certificate\_authorities: ["/etc/pki/tls/certs/logstash.crt"]  
> ssl.certificate: "/etc/pki/tls/certs/filebeat.crt"  
> ssl.key: "/etc/pki/tls/private/filebeat.key"

Filebeat can got nginx-access log easily but can't get "/usr/local/nginx/xxx/uploads/logs/\*.log"(written in php) at all.  
Anyone can give me som advise?thanks a lot!

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [March 14, 2018, 1:28pm UTC](https://discuss.elastic.co/t/filebeat-cant-get-log-written-at-php-by-fwrite/123733/2 "2018-03-14T13:28:16Z")

</div>

Can you enable debug logging in filebeat and share the output?

For your PHP logs: Can you check if the lines have a new line char at the end?

---

<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:** [April 11, 2018, 1:28pm UTC](https://discuss.elastic.co/t/filebeat-cant-get-log-written-at-php-by-fwrite/123733/3 "2018-04-11T13:28:28Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
