log4j v1
uptimestar opened this issue · 6 comments
Hi, where is v1 on github?
(v2 does not work in jars, known issue)
Sure: in the logs on logz.io there is no hostname displayed. I can't tell what log message came from what machine.
How can I set it up so host is displayed. Here is my log4j.properties. Logz.io ticket# 2871
I can also send you screen shot of my logz.io that shows there is no hostname displayed with the logs. One there is an exception, how can I tell what server it was on?
#log4j.rootLogger=INFO, stdout
log4j.rootLogger=INFO, LogzioAppender, stdout
for prod - get token from longzo.io
log4j.appender.LogzioAppender = io.logz.log4j.LogzioAppender
log4j.appender.LogzioAppender.logzioToken = XXX
log4j.appender.LogzioAppender.logzioUrl = http://listener.logz.io:8070
#log4j.appender.LogzioAppender.logzioType = myAppName
log4j.appender.LogzioAppender.layout.type = PatternLayout
log4j.appender.LogzioAppender.layout.pattern = [%p%L] %c{1} - %m%n
IDE only
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern= [%p%L] %c{1} - %m%n
Hi @uptimestar,
You can add the hostname field to your logs in one of the following ways:
- Use the
addHostname
param:log4j.appender.LogzioAppender.addHostname = true
- Use the
additionalFields
param and add hostname yourself:log4j.appender.LogzioAppender.additionalFields = "hostname=$HOSTNAME_ENV_VAR"
I suggest you go with the second way because you can control the value that will be sent.
Works! (FYI log4jv2 does not work even by self when deployed in jar - known issue w/ them).
Thx.
@uptimestar Please let us know if this solved your issue.
@cekvenich What do you mean by log4jv2 does not work ?
What version of log4j did you try to use it with ?
Yes, I solved it, it works w/ log4j1 appender. I can see hostname in dashboard.
Log4jv2 does not work by itself - nothing to do w/ logz.io. Known bug a year old. When you deploy w/ jar. You can just make a console logger and it does not work in production. Works in IDE and development - but does not work when deployed. Don't worry about it.