Comments (13)
Hi 👋 @mohammadinasab-dev
Can you attach Logstash configuration as well?
from logrus-logstash-hook.
hi @boaz0
and thank for your attentions...
input{
tcp{
host => "127.0.0.1"
port => 8911
mode => server
codec => json
}
}
filter{
json{
source => "message"
}
}
output{
elasticsearch{
hosts => "http://localhost:9200/"
index => "j-06-json"
}
}
from logrus-logstash-hook.
Hi @mohammadinasab-dev I was trying to reproduce this bug but unfortunately I can not.
This is what I get:
{"@version":"1","level":"info","method":"main","type":"myappName","host":"localhost","message":"Hello World in print again!","@timestamp":"2021-06-21T16:23:58.000Z"}
I believe this is something related to how you configured the networking on the server.
If you can specify what command line you were executing, I may help you.
from logrus-logstash-hook.
@boaz0
thank you again,
i'm at windows and i use CMD to run logstash (ELK)
and another things to mention is that i have the log in stdout but i dont have it in logstash! until i add time delay.
from logrus-logstash-hook.
@mohammadinasab-dev maybe that's the problem.
I am running Linux and even without the time.Sleep
I can see the logs.
Can you try to do
func main() {
log := logrus.New()
conn, err := net.Dial("tcp", "127.0.0.1:8911")
if err != nil || conn == nil {
log.Fatal(err)
}
hook := logrustash.New(conn, logrustash.DefaultFormatter(logrus.Fields{"type": "myappName"}))
log.Hooks.Add(hook)
ctx := log.WithFields(logrus.Fields{
"method": "main",
})
for i := 0; i < 10; i++ {
ctx.Info("Hello ", i)
}
}
Do you see any logs and how many lines?
from logrus-logstash-hook.
@boaz0 yes maybe the windows is the problem!
it works as explain below:
i try your code many times and after 2nd or 3rd i have all 10 in both stdout and ES too!
and at the first time nothing then at the second time for example 9 and for 3rd tries and more i have exactly 10!
and it's better to say that after many times that i run the code it works correct but for very first tries it doesn't work correctly!
from logrus-logstash-hook.
Hi @mohammadinasab-dev
Can you put a log.Exit(1)
at the end of your main
function and see if it makes any difference?
from logrus-logstash-hook.
Hi @shojaeix and thanks for your attention
yes i did and nothing changes, just it works correct in for loop, or running the program fast and continuously for many times(it looks like a manual looping!).
am i correct by your mean?
```
func main() {
log := logrus.New()
conn, err := net.Dial("tcp", "127.0.0.1:8911")
if err != nil || conn == nil {
log.Fatal(err)
}
hook := logrustash.New(conn, logrustash.DefaultFormatter(logrus.Fields{"type": "myappName"}))
log.Hooks.Add(hook)
ctx := log.WithFields(logrus.Fields{
"method": "main",
})
// for i := 0; i < 10; i++ {
// ctx.Info("Hello", i)
// }
ctx.Info("hello")
log.Exit(1)
}
from logrus-logstash-hook.
Hi @shojaeix and thanks for your attention
yes i did and nothing changes, just it works correct in for loop, or running the program fast and continuously for many times(it looks like a manual looping!).
am i correct by your mean?
```
func main() {
log := logrus.New()
conn, err := net.Dial("tcp", "127.0.0.1:8911")
if err != nil || conn == nil {
log.Fatal(err)
}
hook := logrustash.New(conn, logrustash.DefaultFormatter(logrus.Fields{"type": "myappName"}))log.Hooks.Add(hook)
ctx := log.WithFields(logrus.Fields{
"method": "main",
})
// for i := 0; i < 10; i++ {
// ctx.Info("Hello", i)
// }
ctx.Info("hello")
log.Exit(1)}```
I though this function will wait and write all logs before exiting.
from logrus-logstash-hook.
@mohammadinasab-dev I believe this is probably a non-deterministic behavior on behalf of Go.
Would you mind opening a ticket on Go repository and see what they think?
Thanks.
from logrus-logstash-hook.
@shojaeix it seems to be, but it wasn't wait!!
from logrus-logstash-hook.
@boaz0 my go version is 1.15.2 maybe i should upgrade it to latest, and a ticket on go repository is good idea, anyway thank you again .
from logrus-logstash-hook.
You're welcome. I will colse this issue but feel free to re-open it if you disagree.
Let me know if there is any update. I would like to know what was the problem and how this plugin can help with this.
Thanks.
from logrus-logstash-hook.
Related Issues (20)
- v0.4 is not working anymore with logrus v1.0.3 HOT 4
- what kind of `input` should I config at the logstash side? HOT 3
- logstash configurationo filters HOT 8
- Reconnect to logstash on connection timeout HOT 4
- Not Working with dep HOT 6
- Doesn't work on UDP for big messages HOT 1
- New Trace log level in logrus
- set log level HOT 1
- issues with "go modules" HOT 11
- New release needed HOT 4
- Test error with Go 1.14beta1 HOT 5
- README on master out of date HOT 6
- Additional delimiter for messages HOT 6
- confusing versioning: 1.0 or 0.5 or 5.0? HOT 5
- timestamp in Unix format HOT 1
- No caller report HOT 1
- Timestamp accuracy HOT 2
- Logstash reconnection handeling HOT 1
- how to reconnect to logstash when logstash server resart or no-write long time HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from logrus-logstash-hook.