Skip to content

Commit

Permalink
chore: update log4j2 to align with hedera repo (#274)
Browse files Browse the repository at this point in the history
Signed-off-by: Jeffrey Tang <[email protected]>
  • Loading branch information
JeffreyDallas authored May 9, 2024
1 parent 8db5999 commit a08c52f
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 25 deletions.
80 changes: 59 additions & 21 deletions resources/templates/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,103 @@
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p %-4L %c{1} - %m{nolookups}%n"/>
</Console>

<RollingFile name="RollingFile" fileName="logs/hgcaa.log"
filePattern="logs/hgcaa.log-%d{yyyy-MM-dd}-%i.log">
<RollingFile name="RollingFile" fileName="output/hgcaa.log"
filePattern="output/hgcaa.log-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p %-4L %c{1} - %m{nolookups}%n</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="100 MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
<DefaultRolloverStrategy max="1000"/>
</RollingFile>

<RollingFile name="QueriesRollingFile" fileName="logs/queries.log"
filePattern="logs/queries.log-%d{yyyy-MM-dd}-%i.log">
<RollingFile name="QueriesRollingFile" fileName="output/queries.log"
filePattern="output/queries.log-%d{yyyy-MM-dd}-%i.log">
<BurstFilter level="INFO" rate="50" maxBurst="500"/>
<PatternLayout>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p %-4L %c{1} - %m{nolookups}%n</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="100 MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
<DefaultRolloverStrategy max="1000"/>
</RollingFile>

<RollingFile name="fileLog" fileName="logs/swirlds.log"
filePattern="logs/swirlds.log-%d{yyyy-MM-dd}-%i.log">
<RollingFile name="fileLog" fileName="output/swirlds.log"
filePattern="output/swirlds.log-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-8sn %-5p %-16marker &lt;%t&gt; %c{1}: %msg{nolookups}%n</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="100 MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
<DefaultRolloverStrategy max="1000"/>
</RollingFile>

<RollingFile name="vMapLog" fileName="logs/swirlds-vmap.log"
filePattern="logs/swirlds-vmap.log-%d{yyyy-MM-dd}-%i.log">
<!-- Platform hash stream logs -->
<RollingFile name="swirldsHashStream" fileName="output/swirlds-hashstream/swirlds-hashstream.log"
filePattern="output/swirlds-hashstream/swirlds-hashstream-%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-8sn %-5p %-16marker &lt;%t&gt; %c{1}: %msg{nolookups}%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="100 MB"/>
</Policies>
<DefaultRolloverStrategy max="10">
<Delete basePath="output" maxDepth="3">
<IfFileName glob="swirlds-hashstream/swirlds-hashstream-*.log.gz">
<IfLastModified age="P3D"/>
</IfFileName>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>

<!-- Transaction state logs -->
<RollingFile name="TransactionStateLogs" fileName="output/transaction-state/state-changes.log"
filePattern="output/transaction-state/state-changes-%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} - %m{nolookups}%n</pattern>
</PatternLayout>
<SizeBasedTriggeringPolicy size="50 MB" />
<DefaultRolloverStrategy max="10"/>
</RollingFile>

</Appenders>
<Loggers>
<Root level="TRACE">
<Root level="FATAL">
<!-- <AppenderRef ref="Console"/> -->
<AppenderRef ref="fileLog"/>
</Root>

<Logger name="com.swirlds" level="TRACE" additivity="false">
<Logger name="com.swirlds" level="DEBUG" additivity="false">
<AppenderRef ref="fileLog">
<Filters>
<!-- JasperDB & Virtual Merkle -->
<MarkerFilter marker="JASPER_DB" onMatch="DENY" onMismatch="NEUTRAL"/>
<!-- MerkleDb & Virtual Merkle -->
<MarkerFilter marker="MERKLE_DB" onMatch="DENY" onMismatch="NEUTRAL"/>
<MarkerFilter marker="VIRTUAL_MERKLE_STATS" onMatch="DENY" onMismatch="NEUTRAL"/>
<MarkerFilter marker="STATE_HASH" onMatch="DENY" onMismatch="NEUTRAL"/>
</Filters>
</AppenderRef>

<AppenderRef ref="vMapLog">
<Filters>
<!-- JasperDB & Virtual Merkle -->
<MarkerFilter marker="JASPER_DB" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<!-- MerkleDb & Virtual Merkle -->
<MarkerFilter marker="MERKLE_DB" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="VIRTUAL_MERKLE_STATS" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="DISABLED" onMatch="DENY" onMismatch="DENY" />
</Filters>
</AppenderRef>

<AppenderRef ref="swirldsHashStream">
<Filters>
<!-- Hash stream log -->
<MarkerFilter marker="STATE_HASH" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="DISABLED" onMatch="DENY" onMismatch="DENY" />
</Filters>
</AppenderRef>

<!--
Due to known log4j2 issues with how Markers and LogLevels are evaluated there must be a top level <Filter> element
to ensure that the root logger does not execute all the lambda arguments erroneously. Potential work around in the
Expand Down Expand Up @@ -122,6 +149,7 @@
<MarkerFilter marker="CERTIFICATES" onMatch="DENY" onMismatch="NEUTRAL"/>
<MarkerFilter marker="LOCKS" onMatch="DENY" onMismatch="NEUTRAL"/>
<MarkerFilter marker="TIME_MEASURE" onMatch="DENY" onMismatch="NEUTRAL"/>
<MarkerFilter marker="THREADS" onMatch="ACCEPT" onMismatch="NEUTRAL"/>

<!-- Signed State Signatures -->
<MarkerFilter marker="STATE_SIG_DIST" onMatch="DENY" onMismatch="NEUTRAL"/>
Expand All @@ -141,6 +169,7 @@
<!-- Saved States -->
<MarkerFilter marker="SNAPSHOT_MANAGER" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="STATE_TO_DISK" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="STATE_HASH" onMatch="ACCEPT" onMismatch="NEUTRAL"/>

<!-- Beta Mirror -->
<MarkerFilter marker="BETA_MIRROR_NODE" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
Expand All @@ -160,14 +189,19 @@
<MarkerFilter marker="MERKLE_GENERATION" onMatch="DENY" onMismatch="NEUTRAL"/>
<MarkerFilter marker="MERKLE_LOCKS" onMatch="DENY" onMismatch="NEUTRAL"/>

<!-- JasperDB & Virtual Merkle -->
<MarkerFilter marker="JASPER_DB" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<!-- MerkleDb & Virtual Merkle -->
<MarkerFilter marker="MERKLE_DB" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="VIRTUAL_MERKLE_STATS" onMatch="ACCEPT" onMismatch="NEUTRAL"/>

<MarkerFilter marker="DISABLED" onMatch="DENY" onMismatch="DENY" />
</Filters>
</Logger>

<!-- Send transaction state logs to their own appender -->
<Logger name="com.hedera.node.app.state.logging.TransactionStateLogger" level="info" additivity="false">
<AppenderRef ref="TransactionStateLogs"/>
</Logger>

<Logger name="com.hedera" level="info" additivity="false">
<AppenderRef ref="Console"/>
<AppenderRef ref="RollingFile"/>
Expand All @@ -176,7 +210,7 @@
<AppenderRef ref="Console"/>
<AppenderRef ref="RollingFile"/>
</Logger>
<Logger name="com.hedera.services.queries.answering" level="warn" additivity="false">
<Logger name="com.hedera.services.queries.answering" level="debug" additivity="false">
<AppenderRef ref="QueriesRollingFile"/>
</Logger>

Expand Down Expand Up @@ -220,7 +254,7 @@
<!-- <AppenderRef ref="Console"/> -->
<AppenderRef ref="RollingFile"/>
</Logger>
<Logger name="com.hedera.services.legacy.config" level="info" additivity="false">
<Logger name="com.hedera.services.legacy.config" level="info" additivity="false">
<AppenderRef ref="RollingFile"/>
<AppenderRef ref="Console"/>
</Logger>
Expand Down Expand Up @@ -306,6 +340,10 @@
<!-- <AppenderRef ref="Console"/> -->
<AppenderRef ref="RollingFile"/>
</Logger>
<Logger name="io.grpc" level="ERROR" additivity="false">
<!-- <AppenderRef ref="Console"/> -->
<AppenderRef ref="RollingFile"/>
</Logger>
<Logger name="discover" level="WARN" additivity="false">
<!-- <AppenderRef ref="Console"/> -->
<AppenderRef ref="RollingFile"/>
Expand Down
8 changes: 4 additions & 4 deletions src/commands/node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class NodeCommand extends BaseCommand {
async checkNetworkNodeState (nodeId, maxAttempt = 100, status = 'ACTIVE') {
nodeId = nodeId.trim()
const podName = Templates.renderNetworkPodName(nodeId)
const logfilePath = `${constants.HEDERA_HAPI_PATH}/logs/hgcaa.log`
const logfilePath = `${constants.HEDERA_HAPI_PATH}/output/hgcaa.log`
let attempt = 0
let isActive = false

Expand Down Expand Up @@ -131,8 +131,8 @@ export class NodeCommand extends BaseCommand {
// ls the HAPI path for debugging
await this.k8.execContainer(podName, constants.ROOT_CONTAINER, `ls -la ${constants.HEDERA_HAPI_PATH}`)

// ls the logs directory for debugging
await this.k8.execContainer(podName, constants.ROOT_CONTAINER, `ls -la ${constants.HEDERA_HAPI_PATH}/logs`)
// ls the output directory for debugging
await this.k8.execContainer(podName, constants.ROOT_CONTAINER, `ls -la ${constants.HEDERA_HAPI_PATH}/output`)
}
attempt += 1
await sleep(1000)
Expand Down Expand Up @@ -1485,7 +1485,7 @@ export class NodeCommand extends BaseCommand {
subTasks.push({
title: `Start node: ${chalk.yellow(nodeId)}`,
task: async () => {
await this.k8.execContainer(podName, constants.ROOT_CONTAINER, ['bash', '-c', `rm -f ${constants.HEDERA_HAPI_PATH}/logs/*`])
await this.k8.execContainer(podName, constants.ROOT_CONTAINER, ['bash', '-c', `rm -rf ${constants.HEDERA_HAPI_PATH}/output/*`])

// copy application.env file if required
if (config.applicationEnv) {
Expand Down

0 comments on commit a08c52f

Please sign in to comment.