Graylog log4j appender configuration in external file

Hi!!

I’m working in a java application and I want to configure graylog host and port in an external configuration file.

This is the graylog appender in my log4j.properties file:

log4j.appender.graylog2=org.graylog2.log.GelfAppender
log4j.appender.graylog2.graylogHost=172.21.242.209
log4j.appender.graylog2.graylogPort=12201
log4j.appender.graylog2.originHost=david-localhost
log4j.appender.graylog2.facility=gelf-java
log4j.appender.graylog2.layout=org.apache.log4j.PatternLayout
log4j.appender.graylog2.extractStacktrace=true
log4j.appender.graylog2.addExtendedInformation=true
log4j.appender.graylog2.Threshold=ERROR
log4j.appender.graylog2.additionalFields={‘aplicacion’: ‘REPRESENTA’}

I would like to configure .graylogHost and .graylogPort as a properties in an external properties file. Can I do it? and then, how can I? How can I refer from my log4j.properties file to the propeties of this external file?

I’m using gelfj 1.1.15 and log4j 1.2.15.

Thanks a lot!!

Which GELF appender are you using?
Which version of Log4j are you using?

Sorry. I’m using gelfj 1.1.15 and log4j 1.2.15.
Thanks!!

While Log4j 1.2 doesn’t support merging configuration files, you can use Java system properties in your log4j.properties file.

See https://wiki.apache.org/logging-log4j/SystemPropertiesInConfiguration and https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PropertyConfigurator.html for details.

Thanks for your reply. If I update log4j to the last version 2.8.2, it would be easier? I’m considering update log4j to this version…

Thanks again!!

If you have access to the source code of the application and can make modifications to it, you can read configuration properties from any file using any logging framework.

Ok, thanks very much!!!

Regards.

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