coherence-community / oracle-bedrock

Oracle Bedrock
Other
54 stars 31 forks source link

Add Logging option that leverages Discriminators #448

Open rlubke opened 3 years ago

rlubke commented 3 years ago

Consider the following:

 public static CoherenceClusterResource s_coherence =
            new CoherenceClusterResource()
                    .with(CacheConfig.of("coherence-executor-cache-config.xml"),
                          SystemProperty.of("java.util.logging.config.class", "com.oracle.coherence.executor.logging.Config"),
                          Multicast.ttl(0),
                          LocalHost.only(),
                          Logging.at(9),
                          ClusterPort.of(7574),
                          ClusterName.of(TaskExecutorServiceClusterMemberTests.class.getSimpleName()),
                          Pof.config("coherence-executor-test-pof-config.xml"),
                          JmxFeature.enabled())
                    .include(STORAGE_ENABLED_MEMBER_COUNT,
                             DisplayName.of("CacheServer"),
                             RoleName.of("storage"),
                             LocalStorage.enabled(),
                             SystemProperty.of("coherence.extend.enabled", false))
                    .include(STORAGE_DISABLED_MEMBER_COUNT,
                             DisplayName.of("ComputeServer"),
                             RoleName.of("compute"),
                             LocalStorage.disabled(),
                             SystemProperty.of("coherence.extend.enabled", false));

If you review the code for DisplayName, you'll see the use of a discriminator when starting the cache server resulting in a display name of CacheServer-1 (as an example).

Logging allows for a destination, but it doesn't use a discriminator so both cache servers would write to the same log.

I wrote something specific (see attached) to my purposes that might be useful as a starting point.

Using the example above, I would use LogOutput like: LogOutput.to(m_testName.getMethodName(), "CacheServer") while would result in CacheServer-1.log and CacheServer-2.log in a directory with the same name as m_testName.getMethodName() LogOutput.java.zip