New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a TCP and UDP log appenders to Dropwizard #2291

Merged
merged 3 commits into from Mar 7, 2018

Conversation

Projects
None yet
2 participants
@arteam
Member

arteam commented Mar 3, 2018

Add support for sending log events to a log management server via TCP or UDP. This is useful for applications that want ship logs to a remote machine for processing/alerting. We recently have added support for formatting messages as JSON and in combination with TCP/UDP logging it can be an interesting solution for a direct log shipping from Dropwizard without 3rd-party modules.

From the implementation side TcpSocketAppenderFactory and UdpSocketAppenderFactory are both discoverable and work with generic logging events. That means they can be configured in a YAML config file for general and request logging.

logging:
  level: INFO
  appenders:
    - type: tcp
      host: localhost
      port: 24562
server:
  requestLog:
    appenders:
      - type: tcp
        host: localhost
        port: 24562

From the reliability side, the appenders extend ResilientOutputStreamBase. That means in case if the connections drops because of network glitch or a DNS failure, it will back off and try to reopen a new connection automatically.

@jplock

This comment has been minimized.

Member

jplock commented Mar 3, 2018

This looks really good, one question though. What ends up closing the socket connections? Do we need to worry about that?

@jplock jplock added the feature label Mar 3, 2018

@jplock jplock added this to the 1.3.0 milestone Mar 3, 2018

@jplock

jplock approved these changes Mar 3, 2018

@arteam arteam force-pushed the socket-appender branch from 1b58efe to 41b4616 Mar 3, 2018

@arteam

This comment has been minimized.

Member

arteam commented Mar 3, 2018

This looks really good, one question though. What ends up closing the socket connections? Do we need to worry about that?

Both appenders extend OutputStreamAppender which closes the underneath output stream when it's stopped. So, a TCP/UDP socket should be closed during a shut down of Dropwizard/Logback.

@arteam arteam force-pushed the socket-appender branch 3 times, most recently from 674331e to 416437a Mar 3, 2018

@jplock

This comment has been minimized.

Member

jplock commented Mar 4, 2018

Can you please update the relnotes file with this too?

@arteam arteam force-pushed the socket-appender branch 7 times, most recently from 928904d to 692ed62 Mar 4, 2018

arteam added some commits Jan 7, 2018

Add a TCP and UDP log appenders to Dropwizard
Add support for sending log events to a log management server via TCP or
UDP. This is useful for applications that want to ship logs to a remote
machine. We recently have added support for formatting messages as JSON
and in combination with TCP/UDP logging it can be an interesting solution
for a direct log shipping from Dropwizard without 3rd-party modules.

From the implementation side TcpSocketAppenderFactory and
UdpSocketAppenderFactory are discoverable and work with generic logging
events. That means they can be configured in the config file both for
general and request logging.

logging:
  level: INFO
  appenders:
    - type: tcp
      host: localhost
      port: 24562

server:
  requestLog:
    appenders:
      - type: tcp
        host: localhost
        port: 24562

From the reliability side, the appenders extend
ResilientOutputStreamBase. That means in case if the connections drops
because of network glitch or a DNS failure, it will back off and try to
reopen a new connection automatically.
Reuse common code across the appenders
Add a new class `AsbtractOutputStreamAppenderFactory` which allows
us to build appenders based on `ÒutputStreamAppender`, e.g. console,
file, tcp, udp. It adds a new abstract method for building an appender
which is implemented by actual factories and takes care of enchancing
this appender with the layout encoder, filter factories and an async
appender.

@arteam arteam force-pushed the socket-appender branch from 692ed62 to 1333f69 Mar 7, 2018

@arteam arteam changed the title from [WIP] Add a TCP and UDP log appenders to Dropwizard to Add a TCP and UDP log appenders to Dropwizard Mar 7, 2018

@arteam

This comment has been minimized.

Member

arteam commented Mar 7, 2018

Sure, will do.

@arteam arteam merged commit fea44ab into master Mar 7, 2018

0 of 2 checks passed

continuous-integration/appveyor/branch Waiting for AppVeyor build to complete
Details
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details

@arteam arteam deleted the socket-appender branch Mar 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment