{
    "content": [
        {
            "type": "text",
            "text": "# Log::Log4perl::Appender::Socket (perldoc)\n\n## NAME\n\nLog::Log4perl::Appender::Socket - Log to a socket\n\n## SYNOPSIS\n\nuse Log::Log4perl::Appender::Socket;\nmy $appender = Log::Log4perl::Appender::Socket->new(\nPeerAddr => \"server.foo.com\",\nPeerPort => 1234,\n);\n$appender->log(message => \"Log me\\n\");\n\n## DESCRIPTION\n\nThis is a simple appender for writing to a socket. It relies on IO::Socket::INET and offers all\nparameters this module offers.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **EXAMPLE**\n- **LICENSE**\n- **AUTHOR**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Log::Log4perl::Appender::Socket",
        "section": "",
        "mode": "perldoc",
        "summary": "Log::Log4perl::Appender::Socket - Log to a socket",
        "synopsis": "use Log::Log4perl::Appender::Socket;\nmy $appender = Log::Log4perl::Appender::Socket->new(\nPeerAddr => \"server.foo.com\",\nPeerPort => 1234,\n);\n$appender->log(message => \"Log me\\n\");",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "Write a server quickly using the IO::Socket::INET module:",
            "use IO::Socket::INET;",
            "my $sock = IO::Socket::INET->new(",
            "Listen    => 5,",
            "LocalAddr => 'localhost',",
            "LocalPort => 12345,",
            "Proto     => 'tcp');",
            "while(my $client = $sock->accept()) {",
            "print \"Client connected\\n\";",
            "while(<$client>) {",
            "print \"$\\n\";",
            "Start it and then run the following script as a client:",
            "use Log::Log4perl qw(:easy);",
            "my $conf = q{",
            "log4perl.category                  = WARN, Socket",
            "log4perl.appender.Socket           = Log::Log4perl::Appender::Socket",
            "log4perl.appender.Socket.PeerAddr  = localhost",
            "log4perl.appender.Socket.PeerPort  = 12345",
            "log4perl.appender.Socket.layout    = SimpleLayout",
            "};",
            "Log::Log4perl->init(\\$conf);",
            "sleep(2);",
            "for(1..10) {",
            "ERROR(\"Quack!\");",
            "sleep(5);"
        ],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 25,
                "subsections": []
            },
            {
                "name": "EXAMPLE",
                "lines": 38,
                "subsections": []
            },
            {
                "name": "LICENSE",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 17,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Log::Log4perl::Appender::Socket - Log to a socket\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Log::Log4perl::Appender::Socket;\n\nmy $appender = Log::Log4perl::Appender::Socket->new(\nPeerAddr => \"server.foo.com\",\nPeerPort => 1234,\n);\n\n$appender->log(message => \"Log me\\n\");\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This is a simple appender for writing to a socket. It relies on IO::Socket::INET and offers all\nparameters this module offers.\n\nUpon destruction of the object, pending messages will be flushed and the socket will be closed.\n\nIf the appender cannot contact the server during the initialization phase (while running the\nconstructor \"new\"), it will \"die()\".\n\nIf the appender fails to log a message because the socket's \"send()\" method fails (most likely\nbecause the server went down), it will try to reconnect once. If it succeeds, the message will\nbe sent. If the reconnect fails, a warning is sent to STDERR and the \"log()\" method returns,\ndiscarding the message.\n\nIf the option \"silentrecovery\" is given to the constructor and set to a true value, the\nbehaviour is different: If the socket connection can't be established at initialization time, a\nsingle warning is issued. Every log attempt will then try to establish the connection and\ndiscard the message silently if it fails. If you don't even want the warning, set the\n\"nowarning\" option to a true value.\n\nConnecting at initialization time may not be the best option when running under Apache1\nApache2/prefork, because the parent process creates the socket and the connections are shared\namong the forked children--all the children writing to the same socket could intermingle\nmessages. So instead of that, you can use \"deferconnection\" which will put off making the\nconnection until the first log message is sent.\n",
                "subsections": []
            },
            "EXAMPLE": {
                "content": "Write a server quickly using the IO::Socket::INET module:\n\nuse IO::Socket::INET;\n\nmy $sock = IO::Socket::INET->new(\nListen    => 5,\nLocalAddr => 'localhost',\nLocalPort => 12345,\nProto     => 'tcp');\n\nwhile(my $client = $sock->accept()) {\nprint \"Client connected\\n\";\nwhile(<$client>) {\nprint \"$\\n\";\n}\n}\n\nStart it and then run the following script as a client:\n\nuse Log::Log4perl qw(:easy);\n\nmy $conf = q{\nlog4perl.category                  = WARN, Socket\nlog4perl.appender.Socket           = Log::Log4perl::Appender::Socket\nlog4perl.appender.Socket.PeerAddr  = localhost\nlog4perl.appender.Socket.PeerPort  = 12345\nlog4perl.appender.Socket.layout    = SimpleLayout\n};\n\nLog::Log4perl->init(\\$conf);\n\nsleep(2);\n\nfor(1..10) {\nERROR(\"Quack!\");\nsleep(5);\n}\n",
                "subsections": []
            },
            "LICENSE": {
                "content": "Copyright 2002-2013 by Mike Schilli <m@perlmeister.com> and Kevin Goess <cpan@goess.org>.\n\nThis library is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Please contribute patches to the project on Github:\n\nhttp://github.com/mschilli/log4perl\n\nSend bug reports or requests for enhancements to the authors via our\n\nMAILING LIST (questions, bug reports, suggestions/patches): log4perl-devel@lists.sourceforge.net\n\nAuthors (please contact them via the list above, not directly): Mike Schilli\n<m@perlmeister.com>, Kevin Goess <cpan@goess.org>\n\nContributors (in alphabetical order): Ateeq Altaf, Cory Bennett, Jens Berthold, Jeremy Bopp,\nHutton Davidson, Chris R. Donnelly, Matisse Enzer, Hugh Esco, Anthony Foiani, James FitzGibbon,\nCarl Franks, Dennis Gregorovic, Andy Grundman, Paul Harrington, Alexander Hartmaier David Hull,\nRobert Jacobson, Jason Kohles, Jeff Macdonald, Markus Peter, Brett Rann, Peter Rabbitson, Erik\nSelberg, Aaron Straup Cope, Lars Thegler, David Viner, Mac Yang.\n",
                "subsections": []
            }
        }
    }
}