Home Help Center

Logging Java process with IceGrid

joshmoorejoshmoore GermanyMember Josh MooreOrganization: Glencoe Software, Inc.Project: OME, http://openmicroscopy.org
I'm having difficulty properly capturing the standard out of a Java process in IceGrid. I'm currently using log4j via commons-logging.

When I run "java -jar blitz.jar --Ice.Config=..." from the command line I get logging to standard out via the log4j ConsoleAppender.

When IceGrid starts my server, with :
IceGrid.Node.Output=var/log
Ice.StdOut=var/log/master.out
Ice.StdErr=var/log/master.err
then initially logging of my server goes to master.out until the communicator is started and then all output ceases. (Only exceptions logged by the Ice runtime are printed to Blitz-0.err.)

Removing Ice.StdOut and Ice.StdErr makes no difference.

Setting IceGrid.Node.RedirectErrToOut=1 makes no difference.

Removing IceGrid.Node.Output does did make a difference in that standard out from the Blitz server continues being sent to master.out.

How do I properly capture the output from the server process in var/log/Blitz-0.out?


First, the server template:
    <server-template id="BlitzTemplate">
      <parameter name="index"/>
      <parameter name="exe"  default="java"/>
      <parameter name="mx"   default="256"/>
      <parameter name="port" default="8787"/>
      <server id="Blitz-${index}" exe="${exe}" activation="always">
        <target name="debug">
          <option>-Xdebug</option>
          <option>-Xrunjdwp:server=y,transport=dt_socket,address=${port},suspend=n</option>
        </target>
        <option>-Xmx${mx}m</option>
        <option>-jar</option>
        <option>blitz/blitz.jar</option>
        <adapter name="BlitzAdapter" replica-group="BlitzAdapters" register-process="true" endpoints="tcp"/>
        <properties>
          <property name="Ice.ThreadPool.Client.Size" value="2"/>
          <property name="Ice.ThreadPool.Client.SizeMax" value="50"/>
          <property name="Ice.ThreadPool.Server.Size" value="10"/>
          <property name="Ice.ThreadPool.Server.SizeMax" value="100"/>
        </properties>
      </server>
    </server-template>

Then the node configuration:
# Registry properties
IceGrid.Registry.Client.Endpoints=tcp -p 4061
IceGrid.Registry.Server.Endpoints=tcp
IceGrid.Registry.Internal.Endpoints=tcp
IceGrid.Registry.SessionManager.Endpoints=tcp
IceGrid.Registry.Data=var/registry
IceGrid.Registry.AdminPermissionsVerifier=IceGrid/NullPermissionsVerifier

# Node properties
IceGrid.Node.Endpoints=tcp
IceGrid.Node.Name=master
IceGrid.Node.Data=var/master
IceGrid.Node.Output=var/log
IceGrid.Node.CollocateRegistry=1
#IceGrid.Node.RedirectErrToOut=1

Ice.StdOut=var/log/master.out
Ice.StdErr=var/log/master.err

The generated server config:
# Configuration file (02/18/08 10:43:30.849)

# Server configuration
Ice.ServerId=Blitz-0
Ice.ProgramName=Blitz-0
# Object adapter BlitzAdapter
BlitzAdapter.Endpoints=tcp
BlitzAdapter.AdapterId=Blitz-0.BlitzAdapter
BlitzAdapter.ReplicaGroupId=BlitzAdapters
BlitzAdapter.RegisterProcess=1
# Server descriptor properties
Ice.ThreadPool.Client.Size=2
Ice.ThreadPool.Client.SizeMax=50
Ice.ThreadPool.Server.Size=10
Ice.ThreadPool.Server.SizeMax=100
Ice.StdErr=var/log/Blitz-0.err
Ice.StdOut=var/log/Blitz-0.out
Ice.Default.Locator="IceGrid/Locator" :tcp -p 4061

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Josh,

    The Ice communicator redirects the standard output and error when the communicator is initialized. I suspect the log4j output isn't correctly re-directed to the file when this occurs.

    This is most likely because this log4j bug if you use an old log4j version or because you need to set the follow parameter to true in the log4j configuration (see also this link).

    Cheers,
    Benoit.
  • joshmoorejoshmoore GermanyMember Josh MooreOrganization: Glencoe Software, Inc.Project: OME, http://openmicroscopy.org
    Thanks, Benoit.

    Understood. "follow" did make all logging post-communicator creation log to the proper file.

    My assumption was that icegridnode did the redirection, which lead to my confusion. This means there's no solution for (or perhaps better put it's not a bug that) the log output from before the Ice.Communicator creation goes to master.out whereas that after creation goes to Blitz-0.log.

    If I'm wrong, please let me know, because it's important to have all the logging in a single file. If not possible, I will revert to not using "IceGrid.Node.Output" (and optionally setting Ice.StdOut/Ice.Stderr manually on the other servers).

    Thanks again.
    ~Josh
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    That's correct, the IceGrid node doesn't take care of the re-direction but instead generates the Ice.StdErr/Ice.StdOut properties for the server if IceGrid.Node.Output is defined in the IceGrid node configuration.

    Cheers,
    Benoit.
Sign In or Register to comment.