[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [onionoo/master] logging changes for build.xml, added logback config.
commit 9f39597fecd7c420a4496fa6c46a3b755f0a73e8
Author: iwakeh <iwakeh@xxxxxxxxxxxxxxxxxxxx>
Date: Mon Sep 1 17:30:00 2014 +0000
logging changes for build.xml, added logback config.
---
build.xml | 35 ++++++++++++++++++++------
etc/logback.xml | 57 +++++++++++++++++++++++++++++++++++++++++++
logback.xml | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
vagrant/bootstrap.sh | 3 ++-
4 files changed, 153 insertions(+), 8 deletions(-)
diff --git a/build.xml b/build.xml
index 0d04892..bfe1067 100644
--- a/build.xml
+++ b/build.xml
@@ -12,6 +12,7 @@
value="${config}/web.xml.template"/>
<property name="webxml" value="${config}/web.xml"/>
<property name="warfile" value="onionoo.war"/>
+ <property name="source-and-target-java-version" value="1.6" />
<path id="classpath">
<pathelement path="${classes}"/>
<fileset dir="/usr/share/java">
@@ -21,25 +22,41 @@
<include name="gson.jar"/>
<include name="junit4.jar"/>
<include name="servlet-api-3.0.jar"/>
+ <include name="logback-classic.jar"/>
+ <include name="logback-core.jar"/>
+ <include name="slf4j-api.jar"/>
</fileset>
<fileset dir="deps/metrics-lib">
<include name="descriptor.jar"/>
</fileset>
+ <fileset dir="${config}">
+ <include name="logback.xml"/>
+ </fileset>
</path>
+
<target name="init">
<copy file="${contextxmltemplate}" tofile="${contextxml}"/>
<copy file="${webxmltemplate}" tofile="${webxml}"/>
<mkdir dir="${classes}"/>
</target>
+
+ <target name="clean" >
+ <delete includeEmptyDirs="true">
+ <fileset dir="${classes}" defaultexcludes="false" includes="**" />
+ </delete>
+ <delete file="${warfile}"/>
+ </target>
+
<target name="metrics-lib">
<ant dir="deps/metrics-lib"/>
</target>
+
<target name="compile"
depends="metrics-lib, init">
<javac destdir="${classes}"
srcdir="${javasources}"
- source="1.5"
- target="1.5"
+ source="${source-and-target-java-version}"
+ target="${source-and-target-java-version}"
debug="true"
deprecation="true"
optimize="false"
@@ -48,11 +65,12 @@
<classpath refid="classpath"/>
</javac>
</target>
+
<target name="test" depends="compile">
<javac destdir="${classes}"
srcdir="${tests}"
- source="1.5"
- target="1.5"
+ source="${source-and-target-java-version}"
+ target="${source-and-target-java-version}"
debug="true"
deprecation="true"
optimize="false"
@@ -78,6 +96,9 @@
<include name="descriptor.jar"/>
</lib>
<lib dir="/usr/share/java">
+ <include name="slf4j-api.jar"/>
+ <include name="logback-classic.jar"/>
+ <include name="logback-core.jar"/>
<include name="commons-codec.jar"/>
<include name="commons-compress.jar"/>
<include name="commons-lang.jar"/>
@@ -86,16 +107,16 @@
<classes dir="${classes}"/>
<zipfileset dir="${config}"
prefix="WEB-INF/classes"
- includes="logging.properties"/>
+ includes="logback.xml"/>
<metainf dir="${config}"
includes="context.xml"/>
</war>
</target>
<target name="run" depends="compile">
+ <copy file="logback.xml" todir="${classes}" />
<java fork="true"
maxmemory="${maxmemory.value}"
- classname="org.torproject.onionoo.cron.Main"
- error="errors">
+ classname="org.torproject.onionoo.cron.Main">
<classpath refid="classpath"/>
</java>
</target>
diff --git a/etc/logback.xml b/etc/logback.xml
new file mode 100644
index 0000000..812c7c9
--- /dev/null
+++ b/etc/logback.xml
@@ -0,0 +1,57 @@
+<configuration debug="false">
+
+ <!-- don't forget the trailing slash! -->
+ <property name="logfile-base" value="/var/log/tomcat6/" />
+ <property name="utc-date-pattern" value="%date{yyyy-MM-dd HH:mm:ss, UTC}" />
+
+ <appender name="FILEALL" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logfile-base}onionoo-all.log</file>
+ <encoder>
+ <pattern>${utc-date-pattern} %level %logger{25}:%line %msg%n</pattern>
+ </encoder>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <!-- rollover daily -->
+ <FileNamePattern>${logfile-base}onionoo-all.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
+ <maxHistory>10</maxHistory>
+ <timeBasedFileNamingAndTriggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+ <!-- or whenever the file size reaches 1MB -->
+ <maxFileSize>1MB</maxFileSize>
+ </timeBasedFileNamingAndTriggeringPolicy>
+ </rollingPolicy>
+ </appender>
+
+ <appender name="FILEERR" class="ch.qos.logback.core.FileAppender">
+ <file>${logfile-base}onionoo-err.log</file>
+ <encoder>
+ <pattern>%date %level %logger{30}(%line): %msg%n</pattern>
+ </encoder>
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>ERROR</level>
+ </filter>
+ </appender>
+ <appender name="FILESTATISTICS" class="ch.qos.logback.core.FileAppender">
+ <file>${logfile-base}onionoo-statistics.log</file>
+ <encoder>
+ <pattern>${utc-date-pattern} %msg%n</pattern>
+ </encoder>
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>INFO</level>
+ </filter>
+ </appender>
+
+ <logger name="org.torproject" >
+ <appender-ref ref="FILEERR" />
+ </logger>
+ <logger name="org.torproject.onionoo.server.PerformanceMetrics" >
+ <appender-ref ref="FILESTATISTICS" />
+ </logger>
+ <logger name="statistics" >
+ <appender-ref ref="FILESTATISTICS" />
+ </logger>
+
+ <root level="ALL">
+ <appender-ref ref="FILEALL" />
+ </root>
+</configuration>
+
diff --git a/logback.xml b/logback.xml
new file mode 100644
index 0000000..f6d16d0
--- /dev/null
+++ b/logback.xml
@@ -0,0 +1,66 @@
+<configuration debug="false">
+
+ <!-- don't forget the trailing slash! -->
+ <property name="logfile-base" value="/srv/onionoo.torproject.org/onionoo/" />
+ <property name="utc-date-pattern" value="%date{yyyy-MM-dd HH:mm:ss, UTC}" />
+
+ <appender name="FILEALL" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logfile-base}onionoo-all.log</file>
+ <encoder>
+ <pattern>${utc-date-pattern} %level [runtime: %r] %logger{20}:%line %msg%n</pattern>
+ </encoder>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <!-- rollover daily -->
+ <FileNamePattern>${logfile-base}onionoo-all.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
+ <maxHistory>10</maxHistory>
+ <timeBasedFileNamingAndTriggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+ <!-- or whenever the file size reaches 1MB -->
+ <maxFileSize>1MB</maxFileSize>
+ </timeBasedFileNamingAndTriggeringPolicy>
+ </rollingPolicy>
+ </appender>
+
+ <appender name="FILEERR" class="ch.qos.logback.core.FileAppender">
+ <file>${logfile-base}onionoo-err.log</file>
+ <encoder>
+ <pattern>${utc-date-pattern} %level %logger{30}(%line): %msg%n</pattern>
+ </encoder>
+
+ <!-- ERROR or worse -->
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>ERROR</level>
+ </filter>
+ </appender>
+
+ <appender name="FILESTATISTICS" class="ch.qos.logback.core.FileAppender">
+ <file>${logfile-base}onionoo-statistics.log</file>
+ <encoder>
+ <pattern>${utc-date-pattern} [runtime: %r] %msg%n</pattern>
+ </encoder>
+
+ <!-- only INFO level -->
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>INFO</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ </appender>
+
+ <logger name="org.torproject" >
+ <appender-ref ref="FILEERR" />
+ </logger>
+ <logger name="org.torproject.onionoo.cron.Main" >
+ <appender-ref ref="FILESTATISTICS" />
+ </logger>
+
+ <!-- a named logger -->
+ <logger name="statistics" >
+ <appender-ref ref="FILESTATISTICS" />
+ </logger>
+
+ <root level="ALL">
+ <appender-ref ref="FILEALL" />
+ </root>
+</configuration>
+
diff --git a/vagrant/bootstrap.sh b/vagrant/bootstrap.sh
index f3f0118..d4b1724 100644
--- a/vagrant/bootstrap.sh
+++ b/vagrant/bootstrap.sh
@@ -9,7 +9,7 @@ apt-get -y upgrade
echo "Installing required packages."
apt-get install -y libcommons-codec-java libcommons-compress-java \
libcommons-lang-java libgoogle-gson-java junit4 libservlet3.0-java \
-openjdk-6-jdk ant liblog4j1.2-java tomcat6
+openjdk-6-jdk ant tomcat6 libslf4j-java liblogback-java
echo "Setting up paths and creating symbolic links."
mkdir -p /srv/onionoo.torproject.org/onionoo/
@@ -21,6 +21,7 @@ ln -s /vagrant/etc
ln -s /vagrant/geoip
ln -s /vagrant/src
ln -s /vagrant/web
+ln -s /vagrant/logback.xml
ln -s /srv/onionoo.torproject.org/onionoo/onionoo.war \
/var/lib/tomcat6/webapps/onionoo.war
chown -R vagrant:vagrant /srv/onionoo.torproject.org/
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits