Last active
October 24, 2017 18:39
-
-
Save stuart-warren/5712729 to your computer and use it in GitHub Desktop.
Log4j logging config to output JSON in Logstash json_event format or to use Socket appender
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| input { | |
| log4j { | |
| port => 56445 | |
| type => "log4j" | |
| } | |
| } | |
| output { | |
| #stdout { } | |
| # If your elasticsearch server is discoverable with multicast, use this: | |
| elasticsearch { } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # for production, you should probably set pattern to %c instead of %l. | |
| # (%l is slower.) | |
| # output messages into a rolling log file as well as stdout | |
| log4j.rootLogger=INFO,stdout,R,S | |
| # stdout | |
| log4j.appender.stdout=org.apache.log4j.ConsoleAppender | |
| log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | |
| log4j.appender.stdout.layout.ConversionPattern=%5p %d{HH:mm:ss,SSS} %m%n | |
| # rolling log file | |
| log4j.appender.R=org.apache.log4j.RollingFileAppender | |
| log4j.appender.R.maxFileSize=20MB | |
| log4j.appender.R.maxBackupIndex=5 | |
| log4j.appender.R.layout=org.apache.log4j.PatternLayout | |
| # log4j.appender.R.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) %m%n | |
| log4j.appender.R.layout.ConversionPattern={"@timestamp": "%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ}", "@message": "%m", "@fields": {"priority": "%p", "logger_name": "%c", "thread": "%t"}}%n | |
| # Edit the next line to point to your logs directory | |
| log4j.appender.R.File=/path/to/application.log | |
| # logging over the network. Set port and IP for your network | |
| log4j.appender.S=org.apache.log4j.net.SocketAppender | |
| log4j.appender.S.port=56445 | |
| log4j.appender.S.remoteHost=192.168.20.41 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi. Have you considered using https://github.com/logstash/log4j-jsonevent-layout?