Skip to content

Commit

Permalink
Added file rolling to log4j configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
John MacAuley committed Jul 15, 2021
1 parent 83b8f33 commit a4b3237
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
40 changes: 31 additions & 9 deletions config/log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,65 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://logging.apache.org/log4j/2.0/config
https://raw.githubusercontent.com/apache/logging-log4j2/master/log4j-core/src/main/resources/Log4j-config.xsd">

<Appenders>
<Console name="LogToConsole" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
<PatternLayout>
<Pattern>%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n</Pattern>
</PatternLayout>
</Console>
<RollingFile name="RollingFile" fileName="/var/log/nsi-dds/nsi-dds.log" filePattern="/var/log/nsi-dds/nsi-dds.%d{MM-dd-yyyy}.log.gz"
ignoreExceptions="false">
<PatternLayout>
<Pattern>%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>

<Loggers>
<Logger name="org.springframework" level="debug" additivity="false">
<AppenderRef ref="LogToConsole"/>
<AppenderRef ref="RollingFile"/>
</Logger>

<Logger name="org.eclipse" level="debug" additivity="false">
<AppenderRef ref="LogToConsole"/>
<AppenderRef ref="RollingFile"/>
</Logger>
<!--

<Logger name="org.apache" level="debug" additivity="false">
<AppenderRef ref="LogToConsole"/>
<AppenderRef ref="RollingFile"/>
</Logger>
-->

<Logger name="org.glassfish.jersey" level="debug" additivity="false">
<AppenderRef ref="LogToConsole"/>
<AppenderRef ref="RollingFile"/>
</Logger>

<Logger name="org.glassfish.grizzly" level="debug" additivity="false">
<AppenderRef ref="LogToConsole"/>
<AppenderRef ref="RollingFile"/>
</Logger>

<Logger name="org.hibernate" level="debug" additivity="false">
<AppenderRef ref="LogToConsole"/>
<AppenderRef ref="RollingFile"/>
</Logger>

<Logger name="net.es.nsi.dds" level="debug" additivity="false">
<AppenderRef ref="LogToConsole"/>
<AppenderRef ref="RollingFile"/>
</Logger>

<Root level="debug">
<AppenderRef ref="LogToConsole"/>
<AppenderRef ref="RollingFile"/>
</Root>
</Loggers>
</Configuration>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>net.es.nsi</groupId>
<artifactId>nsi-dds</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<scm>
<developerConnection>scm:git:https://github.com/BandwidthOnDemand/nsi-dds.git</developerConnection>
Expand Down
1 change: 1 addition & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ java -Xmx1024m -Djava.net.preferIPv4Stack=true \
-Dbasedir="$BASEDIR" \
-Djava.util.logging.config.file="$BASEDIR/config/logging.properties" \
-Dcom.sun.xml.bind.v2.runtime.JAXBContextImpl.fastBoot=true \
-Dlog4j.configurationFile=$BASEDIR/config/log4j.xml \
-jar target/dds.jar \
$*
1 change: 1 addition & 0 deletions scripts/nsi-dds.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ script
exec su -l -s /bin/bash -c 'exec "$0" "$@"' $USER -- /usr/bin/java \
-Xmx1024m -Djava.net.preferIPv4Stack=true \
-Dcom.sun.xml.bind.v2.runtime.JAXBContextImpl.fastBoot=true \
-Dlog4j.configurationFile=$HOME/config/log4j.xml \
-Djava.util.logging.config.file="$HOME/config/logging.properties" \
-Dbasedir="$HOME" \
-jar "$HOME/dds.jar" \
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/config/beans.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

<!-- `<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" /> -->
<!-- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" /> -->

<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer" />

Expand Down

0 comments on commit a4b3237

Please sign in to comment.