You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2016/09/22 00:51:20 UTC

[jira] [Comment Edited] (LOG4J2-1604) Log4j2 TcpSocketServer in background

    [ https://issues.apache.org/jira/browse/LOG4J2-1604?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15511665#comment-15511665 ] 

Gary Gregory edited comment on LOG4J2-1604 at 9/22/16 12:50 AM:
----------------------------------------------------------------

[~colinh],

I've redone the servers so that they have a proper command line instead of the positional arguments at fixed indices.

The new way to use the servers is:

{noformat}
Usage: org.apache.logging.log4j.core.net.server.TcpSocketServer [options]
  Options:
    --backlog, -b
       Server socket backlog.
       Default: 50
    --config, -c
       Log4j configuration file location (path or URL).
    --help, -?, -h
       Prints this help.
       Default: false
    --interactive, -i
       Accepts commands on standard input ("exit" is the only command).
       Default: false
    --localbindaddress, -a
       Server socket local bind address.
    --port, -p
       Server socket port.
       Default: 0
{noformat}

and:

{noformat}
Usage: org.apache.logging.log4j.core.net.server.UdpSocketServer [options]
  Options:
    --config, -c
       Configuration file location (path or URL).
    --help, -?, -h
       Prints this help.
       Default: false
    --interactive, -i
       Accepts commands on standard input ("exit" is the only command).
       Default: false
    --localbindaddress, -a
       Socket server port. See http://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#ServerSocket(int,%20int)
    --port, -p
       Socket server port. See http://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#ServerSocket(int,%20int)
       Default: 0
{noformat}

This requires the addition of JCommander on the classpath:

{noformat}
      <dependency>
        <groupId>com.beust</groupId>
        <artifactId>jcommander</artifactId>
        <version>1.48</version>
      </dependency>
{noformat}

Please try with the latest 2.6.3-SNAPSHOT from https://repository.apache.org/content/repositories/snapshots/

If that works for you, please close this ticket.


was (Author: garydgregory):
[~colinh],

I've redone the servers so that they have a proper command line instead of the positional arguments at fixed indices.

The new way to use the servers is:

{noformat}
Usage: org.apache.logging.log4j.core.net.server.TcpSocketServer [options]
  Options:
    --config, -c
       Configuration file location (path or URL).
    --help, -?, -h
       Prints this help.
       Default: false
    --interactive, -i
       Accepts commands on standard input ("exit" is the only command).
       Default: false
    --localbindaddress, -a
       Socket server port. See http://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#ServerSocket(int,%20int)
    --port, -p
       Socket server port. See http://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#ServerSocket(int,%20int)
       Default: 0
{noformat}

and:

{noformat}
Usage: org.apache.logging.log4j.core.net.server.UdpSocketServer [options]
  Options:
    --config, -c
       Configuration file location (path or URL).
    --help, -?, -h
       Prints this help.
       Default: false
    --interactive, -i
       Accepts commands on standard input ("exit" is the only command).
       Default: false
    --localbindaddress, -a
       Socket server port. See http://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#ServerSocket(int,%20int)
    --port, -p
       Socket server port. See http://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#ServerSocket(int,%20int)
       Default: 0
{noformat}

This requires the addition of JCommander on the classpath:

{noformat}
      <dependency>
        <groupId>com.beust</groupId>
        <artifactId>jcommander</artifactId>
        <version>1.48</version>
      </dependency>
{noformat}

Please try with the latest 2.6.3-SNAPSHOT from https://repository.apache.org/content/repositories/snapshots/

If that works for you, please close this ticket.

> Log4j2 TcpSocketServer in background
> ------------------------------------
>
>                 Key: LOG4J2-1604
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1604
>             Project: Log4j 2
>          Issue Type: Question
>          Components: Core
>    Affects Versions: 2.6.2
>         Environment: Linux geotst01 2.6.32-504.3.3.el6.x86_64 #1 SMP Wed Dec 17 01:55:02 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
>            Reporter: Colin Hillman
>            Assignee: Gary Gregory
>            Priority: Minor
>
> I've been using the log4j version 1 SocketServer in background without problem. Changing to the TcpSocketServer works in foreground, but when I put it in the background, it shuts down. I've managed to get it working redirecting input from /dev/zero but as this will give continuous nulls, I'm not sure it's an ideal solution:
> exec $JAVA_HOME/bin/java -cp $LIB_DIR/log4j-api-2.6.2.jar:$LIB_DIR/log4j-core-2.6.2.jar \
>     org.apache.logging.log4j.core.net.server.TcpSocketServer \
>     $\{LOGPORT} $\{BASEDIR}/etc/log4j2.xml  </dev/zero >/dev/null 2>&1 &
> Is the code intended to be used in background and, if yes what's the recommended way to launch TcpSocketServer? Could a parameter be added to make it a daemon not needing input?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org