Tuesday, November 11, 2008

Eclipse WST / WTP

When working with eclipse and WTP most of us encounter the problem of tomcat shared libs. One good way to solve this would be to use

WTP Server Config --> Server locations --> Use tomcat Installation

Ref:
http://wiki.eclipse.org/WTP_Tomcat_FAQ#How_do_I_modify_the_Tomcat_server.27s_configuration.3F

Monday, November 3, 2008

Logrotate and log4j

I discovered the power of linux logroate today. A simple config file and you get automatic rotation + retaintion policy for your application logs. Take a look...

http://linuxcommand.org/man_pages/logrotate8.html

Things get interesting when you want to use this one with log4j. log4j has DailyFileAppender

org.apache.log4j.DailyFileAppender

This is the one everybody ends up using, But the trouble here is you can never configure it correctly to work with logroatate. Nor should you try, It's like two programs are trying to do the same thing...

The closest thing to logroate in log4j is
org.apache.log4j.RollingFileAppender

you can configure it to a very high max size (say 1 GB) and set Maxbackupindex to zero ! . It is kind of an way of using it as a FileAppender with a max cap on size. After this it's logroate's job to take care of rotation and retaintion.

Typical log4j Appender
*(log4j.xml)
<appender name="MyAppender" class="org.apache.log4j.RollingFileAppender">
<param name="MaxFileSize" value="1GB" />
<param name="MaxBackupIndex" value="0" />
<param name="File" value="/path/to/log" />
....
</appender>
(myApp_logroate.conf)

Retain 4 weeks worth of log.

"/path/to/log" {
missingok
notifempty
copytruncate
compress
size 100M
weekly
rotate 4
}

Sunday, November 2, 2008

Problems with mod_mem_cache

mod_mem_cache does not seem to work as expected with virtual hosts. Looking at the code (2.2.7), it does not have a merge_server_config when that is a necessity for modules supporting virtual hosts. Documentation does not say it supports vhosts though.

External digest-auth

I was looking at the possibility of doing external auth from apache mod_digest. Looks like it is quite a possibility. I don't know if anyone has ever done this...

typedef struct {
authn_status (*check_password)(request_rec *r, const char *user,const char *password);
authn_status (*get_realm_hash)(request_rec *r, const char *user, const char *realm, char **rethash);
} authn_provider;

basically any module that registers itself in AUTHN_PROVIDER_GROUP needs to implement *check_password* and *get_realm_hash*, so it can get that information from any place it likes to .... One possibility is to get it from an external RESTful http service (using libcurl).