Skip to content

Commit

Permalink
Improved logging (output structure/coloring)
Browse files Browse the repository at this point in the history
  • Loading branch information
autumoswitzerland committed Dec 23, 2023
1 parent 80ca216 commit 214b0f3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions cfg/logging-dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

<Configuration status="error" name="BeetRootConfig">
Expand All @@ -14,14 +14,14 @@
<Appenders>

<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
<PatternLayout pattern="%highlight{%-5p} : %style{%d{yyyyMMdd-HH:mm:ss.SSS}}{fg_#cccccc} | %style{%-26.26t}{magenta} | %style{%4L}{fg_#cccccc} : %style{%-30.30c{1.1.1.*}}{cyan} | %.-1000m%ex%n" />
</Console>

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

<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %level [%t] [%l] - %msg%n" />
<PatternLayout pattern="%-5p: %d{yyyyMMdd-HH:mm:ss.SSS} | %-26.26t | %4L : %-30.30c{1.1.1.*} | %.-1000m%ex%n"/>

<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
Expand Down
6 changes: 3 additions & 3 deletions cfg/logging-web-weblogic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

<Configuration status="error" name="BeetRootConfig">
Expand All @@ -14,14 +14,14 @@
<Appenders>

<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
<PatternLayout pattern="%highlight{%-5p} : %style{%d{yyyyMMdd-HH:mm:ss.SSS}}{fg_#cccccc} | %style{%-26.26t}{magenta} | %style{%4L}{fg_#cccccc} : %style{%-30.30c{1.1.1.*}}{cyan} | %.-1000m%ex%n" />
</Console>

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

<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %level [%t] [%l] - %msg%n" />
<PatternLayout pattern="%-5p : %d{yyyyMMdd-HH:mm:ss.SSS} | %-32.32t | %4L : %-30.30c{1.1.1.*} | %.-1000m%ex%n"/>

<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
Expand Down
6 changes: 3 additions & 3 deletions cfg/logging-web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

<Configuration status="error" name="BeetRootConfig">
Expand All @@ -14,14 +14,14 @@
<Appenders>

<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
<PatternLayout pattern="%highlight{%-5p} : %style{%d{yyyyMMdd-HH:mm:ss.SSS}}{fg_#cccccc} | %style{%-26.26t}{magenta} | %style{%4L}{fg_#cccccc} : %style{%-30.30c{1.1.1.*}}{cyan} | %.-1000m%ex%n" />
</Console>

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

<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %level [%t] [%l] - %msg%n" />
<PatternLayout pattern="%-5p : %d{yyyyMMdd-HH:mm:ss.SSS} | %-26.26t | %4L : %-30.30c{1.1.1.*} | %.-1000m%ex%n"/>

<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
Expand Down
7 changes: 4 additions & 3 deletions cfg/logging.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

<Configuration status="error" name="BeetRootConfig">
Expand All @@ -14,14 +14,15 @@
<Appenders>

<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
<!-- See: https://logging.apache.org/log4j/2.x/manual/layouts.html -->
<PatternLayout pattern="%highlight{%-5p} : %style{%d{yyyyMMdd-HH:mm:ss.SSS}}{fg_#cccccc} | %style{%-26.26t}{magenta} | %style{%4L}{fg_#cccccc} : %style{%-30.30c{1.1.1.*}}{cyan} | %.-1000m%ex%n" />
</Console>

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

<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %level [%t] [%l] - %msg%n" />
<PatternLayout pattern="%-5p : %d{yyyyMMdd-HH:mm:ss.SSS} | %-26.26t | %4L : %-30.30c{1.1.1.*} | %.-1000m%ex%n"/>

<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ch/autumo/beetroot/server/BaseServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ public BaseServer(String params[]) {
ansiServerName = Colors.cyan("["+ name +"]");
ansiErrServerName = Colors.red("["+ name +"]");

Thread.currentThread().setName(this.name + "-MainThread");


//------------------------------------------------------------------------------

Expand Down Expand Up @@ -412,7 +414,6 @@ protected void startServer() {
if (!start)
return;


LOG.info("Server starting...");
if (LOG.isErrorEnabled())
System.out.println(ansiServerName + " Server starting...");
Expand Down

0 comments on commit 214b0f3

Please sign in to comment.