01 September, 2008

Access logging under Tomcat

Do you want to get "access.log" file under Apache Tomcat Server as well as under Apache HTTP Server? Like this:
192.168.1.1 - - [25/Aug/2008:15:08:11 +0400] "GET / HTTP/1.1" 200 82777
192.168.1.1 - - [25/Aug/2008:15:08:11 +0400] "GET /js/event-debug.js HTTP/1.1" 200 88582
192.168.1.1 - - [25/Aug/2008:15:08:11 +0400] "GET /js/history-debug.js HTTP/1.1" 200 28540
192.168.1.1 - - [25/Aug/2008:15:08:11 +0400] "GET /js/prototype.js HTTP/1.1" 200 126120
192.168.1.1 - - [25/Aug/2008:15:08:11 +0400] "GET /js/json2.js HTTP/1.1" 200 9490
192.168.1.1 - - [25/Aug/2008:15:08:12 +0400] "GET /css/app.css HTTP/1.1" 200 1937

Just insert one line into the "Engine" section of the "server.xml" file:
<Engine name="Catalina" defaultHost="localhost">
...
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="access." suffix=".log" pattern="common"/>
...
</Engine>


Also it is possible to collect and filter the set of raised files via this script:


access.sh
#!/bin/bash

cat access.log | cut -f2 -d"\"" access.log | cut -f2 -d" " | egrep -v -f ignore.txt | sort



ignore.txt
^/$
^/JSON-RPC$
^/JSON-RPC-GET\?
//Any other patterns

HowTo run IntelliJ IDEA from the RAM-Drive under Linux

Sometimes people need to run IntelliJ IDEA at "readonly" systems.
"Readonly" I mean - without unpacking IDEA into the local file system.

These scripts will help extract and start IDEA from the RAM-Drive and remove it after using:


idea-setup.sh
#!/bin/bash

IDEA_TAR_GZ=~/downloads/idea-7.0.3.tar.gz
IDEA_HOME=~/idea/idea
export JDK_HOME=/usr/lib/jvm/java-6-sun
export REQUIRED_JVM_ARGS="-Didea.system.path=$IDEA_HOME/system -Didea.config.path=$IDEA_HOME/config"

mkdir $IDEA_HOME

sudo mount -t ramfs none $IDEA_HOME
tar -xz --strip 1 --file $IDEA_TAR_GZ -C $IDEA_HOME

$IDEA_HOME/bin/idea.sh

./idea-clean.sh



idea-clean.sh
#!/bin/bash

IDEA_HOME=~/idea/idea

sudo umount $IDEA_HOME
rm -rf $IDEA_HOME

Of course you should buy IntelliJ IDEA license, get open source license or... use evaluation version.