{"action":"created","issue":{"url":"https://api.github.com/repos/mp911de/logstash-gelf/issues/48","labels_url":"https://api.github.com/repos/mp911de/logstash-gelf/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/mp911de/logstash-gelf/issues/48/comments","events_url":"https://api.github.com/repos/mp911de/logstash-gelf/issues/48/events","html_url":"https://github.com/mp911de/logstash-gelf/issues/48","id":95746220,"number":48,"title":"Gelf Appender not working when running on same machine as graylog","user":{"login":"ChristianAE","id":7354162,"avatar_url":"https://avatars.githubusercontent.com/u/7354162?v=3","gravatar_id":"","url":"https://api.github.com/users/ChristianAE","html_url":"https://github.com/ChristianAE","followers_url":"https://api.github.com/users/ChristianAE/followers","following_url":"https://api.github.com/users/ChristianAE/following{/other_user}","gists_url":"https://api.github.com/users/ChristianAE/gists{/gist_id}","starred_url":"https://api.github.com/users/ChristianAE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChristianAE/subscriptions","organizations_url":"https://api.github.com/users/ChristianAE/orgs","repos_url":"https://api.github.com/users/ChristianAE/repos","events_url":"https://api.github.com/users/ChristianAE/events{/privacy}","received_events_url":"https://api.github.com/users/ChristianAE/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"mp911de","id":1035015,"avatar_url":"https://avatars.githubusercontent.com/u/1035015?v=3","gravatar_id":"","url":"https://api.github.com/users/mp911de","html_url":"https://github.com/mp911de","followers_url":"https://api.github.com/users/mp911de/followers","following_url":"https://api.github.com/users/mp911de/following{/other_user}","gists_url":"https://api.github.com/users/mp911de/gists{/gist_id}","starred_url":"https://api.github.com/users/mp911de/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mp911de/subscriptions","organizations_url":"https://api.github.com/users/mp911de/orgs","repos_url":"https://api.github.com/users/mp911de/repos","events_url":"https://api.github.com/users/mp911de/events{/privacy}","received_events_url":"https://api.github.com/users/mp911de/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2015-07-17T21:11:28Z","updated_at":"2015-07-18T20:10:32Z","closed_at":null,"body":"I am using log4j and log4j2 in my application.\r\n\r\nThe Appender in my log4j2.xml looks like this:\r\n```java\r\n<Gelf name=\"Gelf\" host=\"udp:devbox\" port=\"12202\"\r\n\t\t\textractStackTrace=\"true\" filterStackTrace=\"true\" maximumMessageSize=\"8192\"\r\n\t\t\toriginHost=\"server_dev_log4j2\">\r\n\t\t\t<Field name=\"level\" pattern=\"INFO\" />\r\n</Gelf>\r\n```\r\nIn log4j.properties it looks like this:\r\n```java\r\nlog4j.appender.gelf=biz.paluch.logging.gelf.log4j.GelfLogAppender\r\nlog4j.appender.gelf.Threshold=INFO\r\nlog4j.appender.gelf.Host=udp:devbox\r\nlog4j.appender.gelf.Port=12202\r\nlog4j.appender.gelf.OriginHost=server_dev_log4j\r\nlog4j.appender.gelf.ExtractStackTrace=true\r\nlog4j.appender.gelf.FilterStackTrace=true\r\nlog4j.appender.gelf.MaximumMessageSize=8192\r\n```\r\n\"devbox\" is the name of the maschine (Ubuntu 14.04) running the server. The graylog server runs inside a Docker container on the same machine.\r\n\r\nThis configuration works when I start it locally(eclipse). On the server only log4j is sending logs to the graylog server. In addition to the Gelf Appender a RollingFile Appender is defined in the log4j2.xml. This works as expected.\r\n\r\nHere the dependencies of the application:\r\n```java\r\ndependencies {\r\n    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'\r\n    compile 'biz.paluch.logging:logstash-gelf:1.6.0'\r\n    compile 'org.eclipse.jetty:jetty-server:9.3.0.v20150612'\r\n    compile 'org.eclipse.jetty:jetty-servlet:9.3.0.v20150612'\r\n    compile 'org.glassfish.jersey.core:jersey-server:2.19'\r\n    compile 'org.glassfish.jersey.containers:jersey-container-jetty-http:2.19'\r\n    compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.19'\r\n    compile 'org.glassfish.jersey.media:jersey-media-moxy:2.19'\r\n    compile 'org.mongodb:mongo-java-driver:3.0.2'\r\n    compile 'com.google.code.gson:gson:2.3.1'\r\n    compile 'org.slf4j:slf4j-log4j12:1.7.12'\r\n    compile 'org.slf4j:jul-to-slf4j:1.7.12'\r\n    compile 'org.apache.logging.log4j:log4j-core:2.3'\r\n    testCompile group: 'junit', name: 'junit', version: '4.+'\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/mp911de/logstash-gelf/issues/comments/122589962","html_url":"https://github.com/mp911de/logstash-gelf/issues/48#issuecomment-122589962","issue_url":"https://api.github.com/repos/mp911de/logstash-gelf/issues/48","id":122589962,"user":{"login":"mp911de","id":1035015,"avatar_url":"https://avatars.githubusercontent.com/u/1035015?v=3","gravatar_id":"","url":"https://api.github.com/users/mp911de","html_url":"https://github.com/mp911de","followers_url":"https://api.github.com/users/mp911de/followers","following_url":"https://api.github.com/users/mp911de/following{/other_user}","gists_url":"https://api.github.com/users/mp911de/gists{/gist_id}","starred_url":"https://api.github.com/users/mp911de/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mp911de/subscriptions","organizations_url":"https://api.github.com/users/mp911de/orgs","repos_url":"https://api.github.com/users/mp911de/repos","events_url":"https://api.github.com/users/mp911de/events{/privacy}","received_events_url":"https://api.github.com/users/mp911de/received_events","type":"User","site_admin":false},"created_at":"2015-07-18T20:10:32Z","updated_at":"2015-07-18T20:10:32Z","body":"Thanks for the update and sorry for misleading you. The script from above did not work for me either. So, if log4j 1.2 works and log4j 2.3 not, it's not a network issue. About the TCP issue:\r\nChange your log4j2 config to:\r\n\r\n```\r\n<Gelf name=\"Gelf\" host=\"tcp:devbox\" port=\"12201\"\r\n            extractStackTrace=\"true\" filterStackTrace=\"true\" maximumMessageSize=\"8192\"\r\n            originHost=\"server_dev_log4j2\">\r\n            <Field name=\"level\" pattern=\"INFO\" />\r\n</Gelf>\r\n```\r\nto give it a try.\r\n\r\nI checked with boot2docker and it's working for me. I used a very simple setup with a `main` and just a bunch of jars:\r\n\r\n```\r\njson-simple-1.1.1.jar\r\nlog4j-api-2.3.jar\r\nlog4j-core-2.3.jar\r\nlogstash-gelf-1.6.0.jar\r\nlog4j2.xml\r\nTestMyLogger.java\r\n```\r\n\r\nand a simple log4j2 config. I shared it at https://www.dropbox.com/s/o2a216kc08ah4e8/log4j2-test.zip?dl=0\r\n\r\n\r\nI currently have no real clue about the reason. Enable log4j2's config debug logging by setting \r\n```\r\n<Configuration status=\"debug\" strict=\"true\">\r\n```\r\n\r\nand check the logs please. Then you should see a line like\r\n\r\n```\r\n2015-07-18 21:56:04,634 DEBUG Found factory method [createAppender]: public static biz.paluch.logging.gelf.log4j2.GelfLogAppender ...\r\n```\r\n\r\nA good test, to check, whether the appender is used is by just using an invalid host name and that should cause two log line:\r\n\r\n```\r\n2015-07-18 21:56:04,641 ERROR Unknown GELF server hostname:udp:devbox\r\n```\r\n\r\nand later on\r\n\r\n```\r\n2015-07-18 21:56:04,654 ERROR Could not send GELF message\r\n```\r\n"}}