Skip to content

Commit

Permalink
Log/log-colors improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
autumoswitzerland committed Nov 6, 2024
1 parent 9012939 commit 5b22c56
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 66 deletions.
18 changes: 2 additions & 16 deletions cfg/logging-dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,47 @@

<!--
beetRoot logging configuration (log4j2 behind SLF4j)
Version: 3.0 - 2023 autumo GmbH
Version: 3.1 - 2024 autumo GmbH
-->

<Configuration status="error" name="BeetRootConfig">

<Properties>
<Property name="basePath">${sys:ROOTPATH}/log</Property>
</Properties>

<Appenders>

<Console name="console" target="SYSTEM_OUT">
<!-- See: https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout -->
<PatternLayout pattern="%highlight{%-5p}{TRACE=white} %style{%d{yyyyMMdd-HH:mm:ss.SSS}}{bright_black} %style{[%-26.26t]}{magenta} %style{%-30.30c{1.1.1.*}}{cyan} %style{:}{bright_black} %.-1000m%ex%n" disableAnsi="false" />
</Console>

<RollingFile name="file"
fileName="${basePath}/beetroot.log"
filePattern="${basePath}/beetroot-%d{yyyyMMdd}.log">

<PatternLayout pattern="%-5p %d{yyyyMMdd-HH:mm:ss.SSS} [%-26.26t] %-30.30c{1.1.1.*} : %.-1000m%ex%n" />

<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
<SizeBasedTriggeringPolicy size="10MB" />
</Policies>

<!-- Max 10 files will be created everyday -->
<DefaultRolloverStrategy max="10">
<Delete basePath="${basePath}" maxDepth="10">
<!-- Delete all files older than 30 days -->
<IfLastModified age="30d" />
</Delete>
</DefaultRolloverStrategy>

</RollingFile>

<!-- Used to show server log on the web, remove if not needed -->
<LogEventAppender name="logEventAppender" />

</Appenders>

<Loggers>

<Logger name="ch.autumo.beetroot" level="info" additivity="false">
<AppenderRef ref="console" />
<!-- Used to show server log on the web, remove if not needed -->
<AppenderRef ref="logEventAppender" />
</Logger>

<Root level="info" additivity="false">
<AppenderRef ref="console" />
<!-- Used to show server log on the web, remove if not needed -->
<AppenderRef ref="logEventAppender" />
</Root>

</Loggers>

</Configuration>
17 changes: 2 additions & 15 deletions cfg/logging-web-weblogic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,41 @@

<!--
beetRoot logging configuration (log4j2 behind SLF4j)
Version: 3.0 - 2023 autumo GmbH
Version: 3.1 - 2024 autumo GmbH
-->

<Configuration status="error" name="BeetRootConfig">

<Properties>
<Property name="basePath">servers/${env:SERVER_NAME}/logs</Property>
</Properties>

<Appenders>

<Console name="console" target="SYSTEM_OUT">
<!-- See: https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout -->
<PatternLayout pattern="%highlight{%-5p}{TRACE=white} %style{%d{yyyyMMdd-HH:mm:ss.SSS}}{bright_black} %style{[%-26.26t]}{magenta} %style{%-30.30c{1.1.1.*}}{cyan} %style{:}{bright_black} %.-1000m%ex%n" disableAnsi="false" />
</Console>

<RollingFile name="file"
fileName="${basePath}/beetroot.log"
filePattern="${basePath}/beetroot-%d{yyyyMMdd}.log">

<PatternLayout pattern="%-5p %d{yyyyMMdd-HH:mm:ss.SSS} [%-26.26t] %-30.30c{1.1.1.*} : %.-1000m%ex%n" />

<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
<SizeBasedTriggeringPolicy size="10MB" />
</Policies>

<!-- Max 10 files will be created everyday -->
<DefaultRolloverStrategy max="10">
<Delete basePath="${basePath}" maxDepth="10">
<!-- Delete all files older than 30 days -->
<IfLastModified age="30d" />
</Delete>
</DefaultRolloverStrategy>

</RollingFile>

</Appenders>

<Loggers>

<Logger name="ch.autumo.beetroot" level="info" additivity="false">
<AppenderRef ref="file" />
</Logger>

<Root level="info" additivity="false">
<AppenderRef ref="file" />
</Root>

</Loggers>

</Configuration>
17 changes: 2 additions & 15 deletions cfg/logging-web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,41 @@

<!--
beetRoot logging configuration (log4j2 behind SLF4j)
Version: 3.0 - 2023 autumo GmbH
Version: 3.1 - 2024 autumo GmbH
-->

<Configuration status="error" name="BeetRootConfig">

<Properties>
<Property name="basePath">${env:CATALINA_BASE}/logs</Property>
</Properties>

<Appenders>

<Console name="console" target="SYSTEM_OUT">
<!-- See: https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout -->
<PatternLayout pattern="%highlight{%-5p}{TRACE=white} %style{%d{yyyyMMdd-HH:mm:ss.SSS}}{bright_black} %style{[%-26.26t]}{magenta} %style{%-30.30c{1.1.1.*}}{cyan} %style{:}{bright_black} %.-1000m%ex%n" disableAnsi="false" />
</Console>

<RollingFile name="file"
fileName="${basePath}/beetroot.log"
filePattern="${basePath}/beetroot-%d{yyyyMMdd}.log">

<PatternLayout pattern="%-5p %d{yyyyMMdd-HH:mm:ss.SSS} [%-26.26t] %-30.30c{1.1.1.*} : %.-1000m%ex%n" />

<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
<SizeBasedTriggeringPolicy size="10MB" />
</Policies>

<!-- Max 10 files will be created everyday -->
<DefaultRolloverStrategy max="10">
<Delete basePath="${basePath}" maxDepth="10">
<!-- Delete all files older than 30 days -->
<IfLastModified age="30d" />
</Delete>
</DefaultRolloverStrategy>

</RollingFile>

</Appenders>

<Loggers>

<Logger name="ch.autumo.beetroot" level="info" additivity="false">
<AppenderRef ref="console" />
</Logger>

<Root level="info" additivity="false">
<AppenderRef ref="console" />
</Root>

</Loggers>

</Configuration>
19 changes: 2 additions & 17 deletions cfg/logging.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,47 @@

<!--
beetRoot logging configuration (log4j2 behind SLF4j)
Version: 3.0 - 2023 autumo GmbH
Version: 3.1 - 2024 autumo GmbH
-->

<Configuration status="error" name="BeetRootConfig">

<Properties>
<Property name="basePath">${sys:ROOTPATH}/log</Property>
</Properties>

<Appenders>

<Console name="console" target="SYSTEM_OUT">
<!-- See: https://logging.apache.org/log4j/2.x/manual/layouts.html -->
<!-- See: https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout -->
<PatternLayout pattern="%highlight{%-5p}{TRACE=white} %style{%d{yyyyMMdd-HH:mm:ss.SSS}}{bright_black} %style{[%-26.26t]}{magenta} %style{%-30.30c{1.1.1.*}}{cyan} %style{:}{bright_black} %.-1000m%ex%n" disableAnsi="false" />
</Console>

<RollingFile name="file"
fileName="${basePath}/beetroot.log"
filePattern="${basePath}/beetroot-%d{yyyyMMdd}.log">

<PatternLayout pattern="%-5p %d{yyyyMMdd-HH:mm:ss.SSS} [%-26.26t] %-30.30c{1.1.1.*} : %.-1000m%ex%n" />

<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
<SizeBasedTriggeringPolicy size="10MB" />
</Policies>

<!-- Max 10 files will be created everyday -->
<DefaultRolloverStrategy max="10">
<Delete basePath="${basePath}" maxDepth="10">
<!-- Delete all files older than 30 days -->
<IfLastModified age="30d" />
</Delete>
</DefaultRolloverStrategy>

</RollingFile>

<!-- Used to show server log on the web, remove if not needed -->
<LogEventAppender name="logEventAppender" />

</Appenders>

<Loggers>

<Logger name="ch.autumo.beetroot" level="info" additivity="false">
<AppenderRef ref="console" />
<!-- Used to show server log on the web, remove if not needed -->
<AppenderRef ref="logEventAppender" />
</Logger>

<Root level="info" additivity="false">
<AppenderRef ref="console" />
<!-- Used to show server log on the web, remove if not needed -->
<AppenderRef ref="logEventAppender" />
</Root>

</Loggers>

</Configuration>
Binary file not shown.
8 changes: 5 additions & 3 deletions src/main/java/ch/autumo/beetroot/utils/common/Colors.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
*/
public final class Colors {

/** show ANSI colors? */
private static boolean showAnsiColors = false;
/** Show ANSI colors? */
private static boolean showAnsiColors = true;
static {
showAnsiColors = BeetRootConfigurationManager.getInstance().getYesOrNo("console_colors");
if (BeetRootConfigurationManager.isInitialized()) {
showAnsiColors = BeetRootConfigurationManager.getInstance().getYesOrNo("console_colors");
}
}

/**
Expand Down

0 comments on commit 5b22c56

Please sign in to comment.