Skip to content

Commit

Permalink
added exclusions for logging at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
ai-republic committed Mar 15, 2024
1 parent 258b274 commit 50fc1b3
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 43 deletions.
38 changes: 26 additions & 12 deletions bms-to-inverter-main/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>

<properties>
<property name="name">BMS-to-Inverter</property>
<property name="pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} | %-5.5p | %-10.10t | %-20.20C:%-5.5L | %msg%n</property>
</properties>
<Properties>
<Property name="name">BMS-to-Inverter</Property>
<Property name="pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} | %-5.5p | %-10.10t | %-20.20C:%-5.5L | %msg%n</Property>
</Properties>

<appenders>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="${pattern}"/>
</Console>
Expand All @@ -20,13 +20,27 @@
<SizeBasedTriggeringPolicy size="100 MB"/> <!-- Or every 100 MB -->
</Policies>
</RollingFile>
</appenders>
<loggers>
<root level="debug"> <!-- We log everything -->
<appender-ref ref="Console"/> <!-- To console -->
<appender-ref ref="RollingFile"/> <!-- And to a rotated file -->
</root>
</loggers>
</Appenders>

<Loggers>
<Logger name="org.jboss.weld" level="error" additivity="false">
<AppenderRef ref="Console"/>
<AppenderRef ref="RollingFile"/>
</Logger>
<Logger name="io.netty" level="error" additivity="false">
<AppenderRef ref="Console"/>
<AppenderRef ref="RollingFile"/>
</Logger>
<Logger name="org.apache.activemq" level="info" additivity="false">
<AppenderRef ref="Console"/>
<AppenderRef ref="RollingFile"/>
</Logger>

<Root level="debug"> <!-- We log everything -->
<AppenderRef ref="Console"/> <!-- To console -->
<AppenderRef ref="RollingFile"/> <!-- And to a rotated file -->
</Root>
</Loggers>

</Configuration>

Binary file modified configurator/current/configurator.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -38,36 +38,50 @@ public class Configurator extends JFrame {
private final BMSPanel bmsPanel;
private final InverterPanel inverterPanel;
private final ServicesPanel servicesPanel;
private final String logConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<Configuration>\n"
+ "\n"
+ " <properties>\n"
+ " <property name=\"name\">BMS-to-Inverter</property>\n"
+ " <property name=\"pattern\">%d{yyyy-MM-dd HH:mm:ss.SSS} | %-5.5p | %-10.10t | %-20.20C:%-5.5L | %msg%n</property>\n"
+ " </properties>\n"
+ " \n"
+ " <appenders>\n"
+ " <Console name=\"Console\" target=\"SYSTEM_OUT\">\n"
+ " <PatternLayout pattern=\"${pattern}\"/>\n"
+ " </Console>\n"
+ " <RollingFile name=\"RollingFile\" fileName=\"logs/${name}.log\"\n"
+ " filePattern=\"logs/$${date:yyyy-MM}/${name}-%d{yyyy-MM-dd}-%i.log.gz\">\n"
+ " <PatternLayout>\n"
+ " <pattern>${pattern}</pattern>\n"
+ " </PatternLayout>\n"
+ " <Policies>\n"
+ " <TimeBasedTriggeringPolicy /><!-- Rotated everyday -->\n"
+ " <SizeBasedTriggeringPolicy size=\"100 MB\"/> <!-- Or every 100 MB -->\n"
+ " </Policies>\n"
+ " </RollingFile>\n"
+ " </appenders>\n"
+ " <loggers>\n"
+ " <root level=\"info\">\n"
+ " <appender-ref ref=\"Console\"/> <!-- To console -->\n"
+ " <appender-ref ref=\"RollingFile\"/> <!-- And to a rotated file -->\n"
+ " </root>\n"
+ " </loggers>\n"
+ " \n"
private final String logConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
+ "<Configuration>\r\n"
+ "\r\n"
+ " <Properties>\r\n"
+ " <Property name=\"name\">BMS-to-Inverter</Property>\r\n"
+ " <Property name=\"pattern\">%d{yyyy-MM-dd HH:mm:ss.SSS} | %-5.5p | %-10.10t | %-20.20C:%-5.5L | %msg%n</Property>\r\n"
+ " </Properties>\r\n"
+ " \r\n"
+ " <Appenders>\r\n"
+ " <Console name=\"Console\" target=\"SYSTEM_OUT\">\r\n"
+ " <PatternLayout pattern=\"${pattern}\"/>\r\n"
+ " </Console>\r\n"
+ " <RollingFile name=\"RollingFile\" fileName=\"logs/${name}.log\"\r\n"
+ " filePattern=\"logs/$${date:yyyy-MM}/${name}-%d{yyyy-MM-dd}-%i.log.gz\">\r\n"
+ " <PatternLayout>\r\n"
+ " <pattern>${pattern}</pattern>\r\n"
+ " </PatternLayout>\r\n"
+ " <Policies>\r\n"
+ " <TimeBasedTriggeringPolicy /><!-- Rotated everyday -->\r\n"
+ " <SizeBasedTriggeringPolicy size=\"100 MB\"/> <!-- Or every 100 MB -->\r\n"
+ " </Policies>\r\n"
+ " </RollingFile>\r\n"
+ " </Appenders>\r\n"
+ " \r\n"
+ " <Loggers>\r\n"
+ " <Logger name=\"org.jboss.weld\" level=\"error\" additivity=\"false\">\r\n"
+ " <AppenderRef ref=\"Console\"/>\r\n"
+ " <AppenderRef ref=\"RollingFile\"/>\r\n"
+ " </Logger>\r\n"
+ " <Logger name=\"io.netty\" level=\"error\" additivity=\"false\">\r\n"
+ " <AppenderRef ref=\"Console\"/>\r\n"
+ " <AppenderRef ref=\"RollingFile\"/>\r\n"
+ " </Logger>\r\n"
+ " <Logger name=\"org.apache.activemq\" level=\"info\" additivity=\"false\">\r\n"
+ " <AppenderRef ref=\"Console\"/>\r\n"
+ " <AppenderRef ref=\"RollingFile\"/>\r\n"
+ " </Logger>\r\n"
+ " \r\n"
+ " <Root level=\"debug\"> <!-- We log everything -->\r\n"
+ " <AppenderRef ref=\"Console\"/> <!-- To console -->\r\n"
+ " <AppenderRef ref=\"RollingFile\"/> <!-- And to a rotated file -->\r\n"
+ " </Root>\r\n"
+ " </Loggers>\r\n"
+ " \r\n"
+ "</Configuration>";

public Configurator() {
Expand Down Expand Up @@ -208,7 +222,7 @@ private void updateConfiguration() throws IOException {
Files.deleteIfExists(configDirectory.resolve("config.properties"));
Files.write(configDirectory.resolve("config.properties"), config.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
Files.deleteIfExists(configDirectory.resolve("lo4j2.xml"));
Files.write(configDirectory.resolve("log4j2.xml"), logConfig.toString().replace("<root level=\"info\">", "<root level=\"" + generalPanel.getLogLevel() + "\">").getBytes(), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
Files.write(configDirectory.resolve("log4j2.xml"), logConfig.toString().replace("<Root level=\"info\">", "<Root level=\"" + generalPanel.getLogLevel() + "\">").getBytes(), StandardOpenOption.CREATE, StandardOpenOption.WRITE);

}

Expand Down

0 comments on commit 50fc1b3

Please sign in to comment.